Module | RR::DSL |
In: |
lib/rr/dsl.rb
|
METHODS_TO_EXCLUDE_FROM_SPYING | = | [ :methods, :==, :__send__, :__id__, :object_id, :class, :respond_to?, :inspect, :to_s, :respond_to_missing?, :instance_eval, :instance_exec |
Returns a AnyTimesMatcher. This is meant to be passed in as an argument to Double#times.
mock(object).method_name(anything).times(any_times) {return_value}
Sets up an Anything wildcard ArgumentEqualityExpectation that succeeds when passed any argument.
mock(object).method_name(anything) {return_value} object.method_name("an arbitrary value") # passes
Sets up an Boolean wildcard ArgumentEqualityExpectation that succeeds when passed an argument that is a ::Boolean.
mock(object).method_name(boolean) {return_value} object.method_name(false) # passes
Sets up a DuckType wildcard ArgumentEqualityExpectation that succeeds when the passed argument implements the methods.
arg = Object.new def arg.foo; end def arg.bar; end mock(object).method_name(duck_type(:foo, :bar)) {return_value} object.method_name(arg) # passes
Sets up a HashIncluding wildcard ArgumentEqualityExpectation that succeeds when the passed argument contains at least those keys and values of the expectation.
mock(object).method_name(hash_including(:foo => 1)) {return_value} object.method_name({:foo => 1, :bar => 2) # passes
Sets up an IsA wildcard ArgumentEqualityExpectation that succeeds when passed an argument of a certain type.
mock(object).method_name(is_a(String)) {return_value} object.method_name("A String") # passes
Sets up an Numeric wildcard ArgumentEqualityExpectation that succeeds when passed an argument that is ::Numeric.
mock(object).method_name(numeric) {return_value} object.method_name(99) # passes
Sets up a Satisfy wildcard ArgumentEqualityExpectation that succeeds when the passed argument causes the expectation‘s proc to return true.
mock(object).method_name(satisfy {|arg| arg == :foo}) {return_value} object.method_name(:foo) # passes