summaryrefslogtreecommitdiff
path: root/spec/ruby/core/range/case_compare_spec.rb
blob: 9a33c5b73b595306f808b8f1d8dbae260b1c4081 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require_relative '../../spec_helper'
require_relative 'shared/cover_and_include'
require_relative 'shared/cover'

describe "Range#===" do
  ruby_version_is ""..."2.6" do
    it "returns the result of calling #include? on self" do
      range = 0...10
      range.should_receive(:include?).with(2).and_return(:true)
      (range === 2).should == :true
    end
  end

  ruby_version_is "2.6" do
    it "returns the result of calling #cover? on self" do
      range = RangeSpecs::Custom.new(0)..RangeSpecs::Custom.new(10)
      (range === RangeSpecs::Custom.new(2)).should == true
    end
  end
end