diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-03-28 00:22:51 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-03-28 00:22:51 +0100 |
commit | f234d51eaba861edea925eabb564a0bee41b96a0 (patch) | |
tree | 3334f36a91fe81ec704f2980ab169231f52c41d0 /spec/ruby/core/symbol/match_spec.rb | |
parent | 296f68816cf575b3ff920f92aec8a4109a7d81d4 (diff) | |
download | ruby-f234d51eaba861edea925eabb564a0bee41b96a0.tar.gz |
Update to ruby/spec@ec84479
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 |