Sha256: 55a57955fc32b99a06a8d36d19761baba3ac91b223066afe26f315d232e83d39

Contents?: true

Size: 626 Bytes

Versions: 2

Compression:

Stored size: 626 Bytes

Contents

require 'not_a_mock/matchers/call_matcher'

module NotAMock
  module Matchers
    # Matcher for
    #   and_returned(...)
    class ResultMatcher < CallMatcher
  
      def initialize(result, parent = nil)
        super parent
        @result = result
      end
  
      def matches_without_parents?
        @calls = @parent.calls.select {|entry| entry[:result] == @result }
        !@calls.empty?
      end
  
      def failure_message_without_parents
        if matched?
          ", and returned #{@result.inspect}"
        else
          ", but didn't return #{@result.inspect}"
        end
      end
  
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
not_a_mock-1.0.1 lib/not_a_mock/matchers/result_matcher.rb
not_a_mock-1.0.0 lib/not_a_mock/matchers/result_matcher.rb