Sha256: 0629a2a38a6cf96c50292bc804b484c658bab68c214d4c99ae51da537dc047cb

Contents?: true

Size: 754 Bytes

Versions: 13

Compression:

Stored size: 754 Bytes

Contents

class LifeUniverseAndEverything
  def include?(obj)
    obj == 42
  end
end


describe 'array' do
  describe "in?" do
    it "should support arrays" do
      1.in?([1,2,3]).should == true
      0.in?([1,2,3]).should == false
    end

    it "should support hashes" do
      :a.in?({a:1,b:2,c:3}).should == true
      1.in?({a:1,b:2,c:3}).should == false
    end

    it "should support ranges" do
      1.in?(1..3).should == true
      0.in?(1..3).should == false
    end

    it "should support strings" do
      'a'.in?("apple").should == true
    end

    it "should support anything that implements `include?`" do
      42.in?(LifeUniverseAndEverything.new).should == true
      0.in?(LifeUniverseAndEverything.new).should == false
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
motion-support-1.2.1 spec/motion-support/core_ext/object/inclusion_spec.rb
motion-support-1.1.1 spec/motion-support/core_ext/object/inclusion_spec.rb
motion-support-1.2.0 spec/motion-support/core_ext/object/inclusion_spec.rb
motion-support-1.1.0 spec/motion-support/core_ext/object/inclusion_spec.rb
motion-support-1.0.0 spec/motion-support/core_ext/object/inclusion_spec.rb
motion-support-0.3.0 spec/motion-support/core_ext/object/inclusion_spec.rb
motion_blender-support-0.2.8 spec/motion-support/core_ext/object/inclusion_spec.rb
motion_blender-support-0.2.7 spec/motion-support/core_ext/object/inclusion_spec.rb
motion-support-0.2.6 spec/motion-support/core_ext/object/inclusion_spec.rb
motion-support-0.2.5 spec/motion-support/core_ext/object/inclusion_spec.rb
motion-support-0.2.4 spec/motion-support/core_ext/object/inclusion_spec.rb
motion-support-0.2.3 spec/motion-support/core_ext/object/inclusion_spec.rb
motion-support-0.2.2 spec/motion-support/core_ext/object/inclusion_spec.rb