Sha256: 155f92bce695ff04d99f973ba4d3201f257640b68a150502a94a8e148829e624

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

module RSpec
  module Matchers
    describe "include() interaction with built-in matchers" do
      it "works with be_within(delta).of(expected)" do
        expect([10, 20, 30]).to include( be_within(5).of(24) )
        expect([10, 20, 30]).not_to include( be_within(3).of(24) )
      end

      it "works with be_instance_of(klass)" do
        expect(["foo", 123, {:foo => "bar"}]).to include( be_instance_of(Hash) )
        expect(["foo", 123, {:foo => "bar"}]).not_to include( be_instance_of(Range) )
      end

      it "works with be_kind_of(klass)" do
        class StringSubclass < String; end
        class NotHashSubclass; end

        expect([StringSubclass.new("baz")]).to include( be_kind_of(String) )
        expect([NotHashSubclass.new]).not_to include( be_kind_of(Hash) )
      end

      it "works with be_[some predicate]" do
        expect([stub("actual", :happy? => true)]).to include( be_happy )
        expect([stub("actual", :happy? => false)]).not_to include( be_happy )
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 5 rubygems

Version Path
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-expectations-2.13.0/spec/rspec/matchers/include_matcher_integration_spec.rb
sshp-0.0.2 vendor/ruby/1.9.1/gems/rspec-expectations-2.13.0/spec/rspec/matchers/include_matcher_integration_spec.rb
sshp-0.0.1 vendor/ruby/1.9.1/gems/rspec-expectations-2.13.0/spec/rspec/matchers/include_matcher_integration_spec.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/rspec-expectations-2.13.0/spec/rspec/matchers/include_matcher_integration_spec.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/rspec-expectations-2.13.0/spec/rspec/matchers/include_matcher_integration_spec.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/rspec-expectations-2.13.0/spec/rspec/matchers/include_matcher_integration_spec.rb
rspec-expectations-2.13.0 spec/rspec/matchers/include_matcher_integration_spec.rb