Sha256: e6510f6fb2a43903a94f93b06552aba6f09ea0f5668176a4595b1f4e28966887

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

module RSpec
  module Matchers
    [:be_a_kind_of, :be_kind_of].each do |method|
      RSpec.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

      RSpec.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

9 entries across 9 versions & 2 rubygems

Version Path
opal-rspec-0.6.2 rspec-expectations/spec/rspec/matchers/built_in/be_kind_of_spec.rb
opal-rspec-0.6.1 rspec-expectations/spec/rspec/matchers/built_in/be_kind_of_spec.rb
opal-rspec-0.6.0 rspec-expectations/spec/rspec/matchers/built_in/be_kind_of_spec.rb
opal-rspec-0.6.0.beta1 rspec-expectations/spec/rspec/matchers/built_in/be_kind_of_spec.rb
opal-connect-rspec-0.5.0 rspec-expectations/spec/rspec/matchers/built_in/be_kind_of_spec.rb
opal-rspec-0.5.0 rspec-expectations/spec/rspec/matchers/built_in/be_kind_of_spec.rb
opal-rspec-0.5.0.beta3 rspec-expectations/spec/rspec/matchers/built_in/be_kind_of_spec.rb
opal-rspec-0.5.0.beta2 rspec-expectations/spec/rspec/matchers/built_in/be_kind_of_spec.rb
opal-rspec-0.5.0.beta1 rspec-expectations/spec/rspec/matchers/built_in/be_kind_of_spec.rb