diff options
Diffstat (limited to 'spec/ruby/core/matchdata/shared')
| -rw-r--r-- | spec/ruby/core/matchdata/shared/captures.rb | 13 | ||||
| -rw-r--r-- | spec/ruby/core/matchdata/shared/eql.rb | 8 |
2 files changed, 17 insertions, 4 deletions
diff --git a/spec/ruby/core/matchdata/shared/captures.rb b/spec/ruby/core/matchdata/shared/captures.rb new file mode 100644 index 0000000000..de5870f543 --- /dev/null +++ b/spec/ruby/core/matchdata/shared/captures.rb @@ -0,0 +1,13 @@ +require_relative '../../../spec_helper' +require_relative '../fixtures/classes' + +describe :matchdata_captures, shared: true do + it "returns an array of the match captures" do + /(.)(.)(\d+)(\d)/.match("THX1138.").send(@method).should == ["H","X","113","8"] + end + + it "returns instances of String when given a String subclass" do + str = MatchDataSpecs::MyString.new("THX1138: The Movie") + /(.)(.)(\d+)(\d)/.match(str).send(@method).each { |c| c.should.instance_of?(String) } + end +end diff --git a/spec/ruby/core/matchdata/shared/eql.rb b/spec/ruby/core/matchdata/shared/eql.rb index e021baa178..e4bb8797b7 100644 --- a/spec/ruby/core/matchdata/shared/eql.rb +++ b/spec/ruby/core/matchdata/shared/eql.rb @@ -4,23 +4,23 @@ describe :matchdata_eql, shared: true do it "returns true if both operands have equal target strings, patterns, and match positions" do a = 'haystack'.match(/hay/) b = 'haystack'.match(/hay/) - a.send(@method, b).should be_true + a.send(@method, b).should == true end it "returns false if the operands have different target strings" do a = 'hay'.match(/hay/) b = 'haystack'.match(/hay/) - a.send(@method, b).should be_false + a.send(@method, b).should == false end it "returns false if the operands have different patterns" do a = 'haystack'.match(/h.y/) b = 'haystack'.match(/hay/) - a.send(@method, b).should be_false + a.send(@method, b).should == false end it "returns false if the argument is not a MatchData object" do a = 'haystack'.match(/hay/) - a.send(@method, Object.new).should be_false + a.send(@method, Object.new).should == false end end |
