diff options
Diffstat (limited to 'spec/ruby/core/matchdata/equal_value_spec.rb')
| -rw-r--r-- | spec/ruby/core/matchdata/equal_value_spec.rb | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/spec/ruby/core/matchdata/equal_value_spec.rb b/spec/ruby/core/matchdata/equal_value_spec.rb index 0d33d0acf2..74d3a5adcd 100644 --- a/spec/ruby/core/matchdata/equal_value_spec.rb +++ b/spec/ruby/core/matchdata/equal_value_spec.rb @@ -1,6 +1,26 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/eql', __FILE__) +require_relative '../../spec_helper' describe "MatchData#==" do - it_behaves_like(:matchdata_eql, :==) + it "returns true if both operands have equal target strings, patterns, and match positions" do + a = 'haystack'.match(/hay/) + b = 'haystack'.match(/hay/) + a.==(b).should == true + end + + it "returns false if the operands have different target strings" do + a = 'hay'.match(/hay/) + b = 'haystack'.match(/hay/) + a.==(b).should == false + end + + it "returns false if the operands have different patterns" do + a = 'haystack'.match(/h.y/) + b = 'haystack'.match(/hay/) + a.==(b).should == false + end + + it "returns false if the argument is not a MatchData object" do + a = 'haystack'.match(/hay/) + a.==(Object.new).should == false + end end |
