Sha256: 1d3a0af87e81befafd41e784c9862baf390c44dff5ec8f0b48fb35703cf9f06d

Contents?: true

Size: 1.32 KB

Versions: 44

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

module RSpec
  module Matchers
    [:be_a_kind_of, :be_kind_of].each do |method|
      describe "expect(actual).to #{method}(expected)" do
        it_behaves_like "an RSpec matcher", :valid_value => 5, :invalid_value => "a" do
          let(:matcher) { send(method, Fixnum) }
        end

        it "passes if actual is instance of expected class" do
          expect(5).to send(method, Fixnum)
        end

        it "passes if actual is instance of subclass of expected class" do
          expect(5).to send(method, Numeric)
        end

        it "fails with failure message for should unless actual is kind of expected class" do
          expect {
            expect("foo").to send(method, Array)
          }.to fail_with(%Q{expected "foo" to be a kind of Array})
        end

        it "provides a description" do
          matcher = be_a_kind_of(String)
          matcher.matches?("this")
          expect(matcher.description).to eq "be a kind of String"
        end
      end

      describe "expect(actual).not_to #{method}(expected)" do
        it "fails with failure message for should_not if actual is kind of expected class" do
          expect {
            expect("foo").not_to send(method, String)
          }.to fail_with(%Q{expected "foo" not to be a kind of String})
        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 12 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/be_kind_of_spec.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/be_kind_of_spec.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/be_kind_of_spec.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/be_kind_of_spec.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/be_kind_of_spec.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/be_kind_of_spec.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/be_kind_of_spec.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/be_kind_of_spec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-expectations-2.14.5/spec/rspec/matchers/be_kind_of_spec.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-expectations-2.13.0/spec/rspec/matchers/be_kind_of_spec.rb
rspec-expectations-2.99.2 spec/rspec/matchers/be_kind_of_spec.rb
dxruby_rp5-0.0.4 spec/vendor/rspec-expectations-2.14.4/spec/rspec/matchers/be_kind_of_spec.rb
rspec-expectations-2.99.1 spec/rspec/matchers/be_kind_of_spec.rb
rspec-expectations-2.99.0 spec/rspec/matchers/be_kind_of_spec.rb
rspec-expectations-2.99.0.rc1 spec/rspec/matchers/be_kind_of_spec.rb
rspec-expectations-3.0.0.beta2 spec/rspec/matchers/built_in/be_kind_of_spec.rb
rspec-expectations-2.99.0.beta2 spec/rspec/matchers/be_kind_of_spec.rb
rspec-expectations-2.14.5 spec/rspec/matchers/be_kind_of_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-expectations-2.14.4/spec/rspec/matchers/be_kind_of_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-expectations-2.14.4/spec/rspec/matchers/be_kind_of_spec.rb