Sha256: 19ded7aac68542ea3ceb4b3d5a8d14ae4853bd21480a1b78564d9f53a8e62530

Contents?: true

Size: 1.23 KB

Versions: 32

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

module Spec
  module Matchers
    [:be_an_instance_of, :be_instance_of].each do |method|
      describe "actual.should #{method}(expected)" do
        it "passes if actual is instance of expected class" do
          5.should send(method, Fixnum)
        end

        it "fails if actual is instance of subclass of expected class" do
          lambda { 5.should send(method, Numeric) }.should fail_with(%Q{expected 5 to be an instance of Numeric})
        end

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

        it "provides a description" do
          matcher = be_an_instance_of(Fixnum)
          matcher.matches?(Numeric)
          matcher.description.should == "be an instance of Fixnum"
        end
      end
      
      describe "actual.should_not #{method}(expected)" do
        
        it "fails with failure message for should_not if actual is instance of expected class" do
          lambda { "foo".should_not send(method, String) }.should fail_with(%Q{expected "foo" not to be an instance of String})
        end

      end

    end
  end
end

Version data entries

32 entries across 32 versions & 11 rubygems

Version Path
rspec-instructure-1.3.3 spec/spec/matchers/be_instance_of_spec.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/spec/spec/matchers/be_instance_of_spec.rb
rspec-1.3.2 spec/spec/matchers/be_instance_of_spec.rb
rspec-1.3.1 spec/spec/matchers/be_instance_of_spec.rb
rspec-1.3.1.rc spec/spec/matchers/be_instance_of_spec.rb
rspec-1.3.0 spec/spec/matchers/be_instance_of_spec.rb
hubbub-0.0.11 lib/vendor/plugins/rspec/spec/spec/matchers/be_instance_of_spec.rb
hubbub-0.0.10 lib/vendor/plugins/rspec/spec/spec/matchers/be_instance_of_spec.rb
hubbub-0.0.9 lib/vendor/plugins/rspec/spec/spec/matchers/be_instance_of_spec.rb
hubbub-0.0.8 lib/vendor/plugins/rspec/spec/spec/matchers/be_instance_of_spec.rb
hubbub-0.0.6 lib/vendor/plugins/rspec/spec/spec/matchers/be_instance_of_spec.rb
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/spec/spec/matchers/be_instance_of_spec.rb
media-path-0.1.2 vendor/rspec/spec/spec/matchers/be_instance_of_spec.rb
simple-templater-0.0.1.3 vendor/rspec/spec/spec/matchers/be_instance_of_spec.rb
pupu-0.0.2.pre vendor/rspec/spec/spec/matchers/be_instance_of_spec.rb
media-path-0.1.1.pre vendor/rspec/spec/spec/matchers/be_instance_of_spec.rb
simple-templater-0.0.1.2 vendor/rspec/spec/spec/matchers/be_instance_of_spec.rb
media-path-0.1.1 vendor/rspec/spec/spec/matchers/be_instance_of_spec.rb
simple-templater-0.0.1.1 vendor/rspec/spec/spec/matchers/be_instance_of_spec.rb
pupu-0.0.2 vendor/rspec/spec/spec/matchers/be_instance_of_spec.rb