Sha256: ce8744c76af68ec8bec2950ad31e2066e5e734882b02ec55729373f41c492f3e

Contents?: true

Size: 1002 Bytes

Versions: 5

Compression:

Stored size: 1002 Bytes

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

module Spec
  module Matchers
    [:be_kind_of, :be_a_kind_of].each do |method|
      describe "#{method}" do
        it "passes if object is instance of given class" do
          5.should send(method, Fixnum)
        end

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

        it "fails with failure message unless object is kind of given class" do
          lambda { "foo".should send(method, Array) }.should fail_with(%Q{expected kind of Array, got "foo"})
        end

        it "fails with negative failure message if object is kind of given class" do
          lambda { "foo".should_not send(method, String) }.should fail_with(%Q{expected "foo" not to be a kind of String})
        end

        it "provides a description" do
          Spec::Matchers::BeKindOf.new(Class).description.should == "be a kind of Class"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
dchelimsky-rspec-1.1.99.13 spec/spec/matchers/be_kind_of_spec.rb
dchelimsky-rspec-1.1.99.7 spec/spec/matchers/be_kind_of_spec.rb
dchelimsky-rspec-1.1.99.8 spec/spec/matchers/be_kind_of_spec.rb
dchelimsky-rspec-1.1.99.9 spec/spec/matchers/be_kind_of_spec.rb
rspec-1.2.0 spec/spec/matchers/be_kind_of_spec.rb