diff options
Diffstat (limited to 'spec/ruby/core/symbol/match_spec.rb')
-rw-r--r-- | spec/ruby/core/symbol/match_spec.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/ruby/core/symbol/match_spec.rb b/spec/ruby/core/symbol/match_spec.rb index d37155537b..41e058f977 100644 --- a/spec/ruby/core/symbol/match_spec.rb +++ b/spec/ruby/core/symbol/match_spec.rb @@ -34,6 +34,23 @@ describe "Symbol#match" do :a.match(/(.)/)[0].should == 'a' $1.should == "a" end + + describe "when passed a block" do + it "yields the MatchData" do + :abc.match(/./) {|m| ScratchPad.record m } + ScratchPad.recorded.should be_kind_of(MatchData) + end + + it "returns the block result" do + :abc.match(/./) { :result }.should == :result + end + + it "does not yield if there is no match" do + ScratchPad.record [] + :b.match(/a/) {|m| ScratchPad << m } + ScratchPad.recorded.should == [] + end + end end describe "Symbol#match?" do |