Sha256: 380654814244469d9f826b0f22665f676a3235ccb7b010788ac91f22861ce21b

Contents?: true

Size: 1.53 KB

Versions: 11

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

module RSpec
  module Mocks
    describe ArgumentListMatcher do

      it "considers an object that responds to #matches? and #failure_message_for_should to be a matcher" do
        argument_expectation = RSpec::Mocks::ArgumentListMatcher.new
        obj = double("matcher")
        obj.stub(:respond_to?).with(:matches?).and_return(true)
        obj.stub(:respond_to?).with(:failure_message_for_should).and_return(true)
        expect(argument_expectation.send(:is_matcher?, obj)).to be_true
      end

      it "considers an object that responds to #matches? and #failure_message to be a matcher for backward compatibility" do
        argument_expectation = RSpec::Mocks::ArgumentListMatcher.new
        obj = double("matcher")
        obj.stub(:respond_to?).with(:matches?).and_return(true)
        obj.stub(:respond_to?).with(:failure_message_for_should).and_return(false)
        obj.stub(:respond_to?).with(:failure_message).and_return(true)
        expect(argument_expectation.send(:is_matcher?, obj)).to be_true
      end

      it "does NOT consider an object that only responds to #matches? to be a matcher" do
        argument_expectation = RSpec::Mocks::ArgumentListMatcher.new
        obj = double("matcher")
        obj.stub(:respond_to?).with(:matches?).and_return(true)
        obj.stub(:respond_to?).with(:failure_message_for_should).and_return(false)
        obj.stub(:respond_to?).with(:failure_message).and_return(false)
        expect(argument_expectation.send(:is_matcher?, obj)).to be_false
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 6 rubygems

Version Path
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-mocks-2.13.0/spec/rspec/mocks/argument_expectation_spec.rb
sshp-0.0.2 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/spec/rspec/mocks/argument_expectation_spec.rb
sshp-0.0.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/spec/rspec/mocks/argument_expectation_spec.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/spec/rspec/mocks/argument_expectation_spec.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/spec/rspec/mocks/argument_expectation_spec.rb
rspec-mocks-2.13.1 spec/rspec/mocks/argument_expectation_spec.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/rspec-mocks-2.13.0/spec/rspec/mocks/argument_expectation_spec.rb
rspec-mocks-2.13.0 spec/rspec/mocks/argument_expectation_spec.rb
remq-0.0.4 vendor/bundle/gems/rspec-mocks-2.12.2/spec/rspec/mocks/argument_expectation_spec.rb
remq-0.0.3 vendor/bundle/gems/rspec-mocks-2.12.2/spec/rspec/mocks/argument_expectation_spec.rb
rspec-mocks-2.12.2 spec/rspec/mocks/argument_expectation_spec.rb