diff options
Diffstat (limited to 'spec/ruby/core/enumerable/grep_v_spec.rb')
-rw-r--r-- | spec/ruby/core/enumerable/grep_v_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/ruby/core/enumerable/grep_v_spec.rb b/spec/ruby/core/enumerable/grep_v_spec.rb index 892640efa4..35fde27eb6 100644 --- a/spec/ruby/core/enumerable/grep_v_spec.rb +++ b/spec/ruby/core/enumerable/grep_v_spec.rb @@ -45,6 +45,18 @@ describe "Enumerable#grep_v" do ["abc", "def"].grep_v(/e/).should == ["abc"] Regexp.last_match[0].should == "z" end + + it "correctly handles non-string elements" do + 'set last match' =~ /set last (.*)/ + [:a, 'b', 'z', :c, 42, nil].grep_v(/[a-d]/).should == ['z', 42, nil] + $1.should == 'match' + + o = Object.new + def o.to_str + 'hello' + end + [o].grep_v(/mm/).first.should.equal?(o) + end end describe "without block" do |