Sha256: 84d6e32dad9d92a58cbf35747e019b700155eec33837af397c06e23f7092355a

Contents?: true

Size: 1.24 KB

Versions: 238

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

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

238 entries across 137 versions & 15 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.9.1/spec/rspec/matchers/be_instance_of_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.10.0/spec/rspec/matchers/be_instance_of_spec.rb
classiccms-0.6.9 vendor/bundle/gems/rspec-expectations-2.10.0/spec/rspec/matchers/be_instance_of_spec.rb