Sha256: 741ba45cce0d74d31b534ec1dbed4e5f2db06f149abda83a42712c05c87c57aa

Contents?: true

Size: 1.02 KB

Versions: 36

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([double("actual", :happy? => true)]).to include( be_happy )
        expect([double("actual", :happy? => false)]).not_to include( be_happy )
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/include_matcher_integration_spec.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/include_matcher_integration_spec.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/include_matcher_integration_spec.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/include_matcher_integration_spec.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/include_matcher_integration_spec.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/include_matcher_integration_spec.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/include_matcher_integration_spec.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/include_matcher_integration_spec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-expectations-2.14.5/spec/rspec/matchers/include_matcher_integration_spec.rb
rspec-expectations-2.99.2 spec/rspec/matchers/include_matcher_integration_spec.rb
dxruby_rp5-0.0.4 spec/vendor/rspec-expectations-2.14.4/spec/rspec/matchers/include_matcher_integration_spec.rb
rspec-expectations-2.99.1 spec/rspec/matchers/include_matcher_integration_spec.rb
rspec-expectations-2.99.0 spec/rspec/matchers/include_matcher_integration_spec.rb
rspec-expectations-2.99.0.rc1 spec/rspec/matchers/include_matcher_integration_spec.rb
rspec-expectations-2.99.0.beta2 spec/rspec/matchers/include_matcher_integration_spec.rb
rspec-expectations-2.14.5 spec/rspec/matchers/include_matcher_integration_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-expectations-2.14.4/spec/rspec/matchers/include_matcher_integration_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-expectations-2.14.4/spec/rspec/matchers/include_matcher_integration_spec.rb
dxruby_rp5-0.0.3 spec/vendor/rspec-expectations-2.14.4/spec/rspec/matchers/include_matcher_integration_spec.rb
tuktuk-rails-0.0.10 vendor/bundle/ruby/2.0.0/gems/rspec-expectations-2.14.4/spec/rspec/matchers/include_matcher_integration_spec.rb