Sha256: 07ace505f7a764ef73df5a4ff1118fa467ac1481874246999efcec0cccbc7f51
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
module NotAMock module Matchers class CallMatcher def initialize(parent = nil) @parent = parent end def matches?(object) @object = object @matched = parent_matches? && matches_without_parents? end def matched?; @matched end attr_reader :calls def failure_message if parent_matched? parent_failure_message + failure_message_without_parents else parent_failure_message end end def negative_failure_message failure_message end def with(*args) ArgsMatcher.new(args, self) end def without_args ArgsMatcher.new([], self) end def and_returned(result) ResultMatcher.new(result, self) end def exactly(n) TimesMatcher.new(n, self) end def once; exactly(1) end def twice; exactly(2) end protected def parent_matches? @parent.nil? || @parent.matches?(@object) end def parent_matched? @parent.nil? || @parent.matched? end def parent_failure_message @parent ? @parent.failure_message : @object.inspect 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/call_matcher.rb |
not_a_mock-1.0.0 | lib/not_a_mock/matchers/call_matcher.rb |