summaryrefslogtreecommitdiff
path: root/spec/rubyspec/core/kernel/not_match_spec.rb
blob: 42bd45c1061c1b605bc8b5faee1094e3b8548c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

describe "Kernel#!~" do
  class KernelSpecs::NotMatch
    def !~(obj)
      :foo
    end
  end

  it 'calls =~ internally and negates the result' do
    obj = Object.new
    obj.should_receive(:=~).and_return(true)
    (obj !~ :foo).should == false
  end

  it 'can be overridden in subclasses' do
    obj = KernelSpecs::NotMatch.new
    (obj !~ :bar).should == :foo
  end
end