File: argument_expectation_spec.rb

package info (click to toggle)
ruby-rspec-mocks 2.14.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 868 kB
  • ctags: 725
  • sloc: ruby: 8,227; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 1,130 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'spec_helper'

module RSpec
  module Mocks
    describe ArgumentListMatcher do
      let(:argument_expectation) { RSpec::Mocks::ArgumentListMatcher.new }
      let(:obj) { double("matcher") }

      it "considers an object that responds to #matches? and #failure_message_for_should to be a matcher" do
        obj.stub(:matches?)
        obj.stub(:failure_message_for_should)
        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
        obj.stub(:matches?)
        obj.stub(:failure_message)
        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
        obj.stub(:matches?)
        expect(argument_expectation.send(:is_matcher?, obj)).to be_false
      end

      it "does not consider a null object to be a matcher" do
        obj.as_null_object
        expect(argument_expectation.send(:is_matcher?, obj)).to be_false
      end
    end
  end
end