Class/Module Index [+]

Quicksearch

RR::Adapters::RRMethods

Public Class Methods

register_strategy_class(strategy_class, method_name) click to toggle source
# File lib/rr/adapters/rr_methods.rb, line 5
def register_strategy_class(strategy_class, method_name)
  class_eval((          def #{method_name}(subject=DoubleDefinitions::DoubleDefinitionCreate::NO_SUBJECT, method_name=nil, &definition_eval_block)            double_definition_create = DoubleDefinitions::DoubleDefinitionCreate.new            double_definition_create.#{method_name}(subject, method_name, &definition_eval_block)          end), __FILE__, __LINE__ + 1)

  class_eval((          def #{method_name}!(method_name=nil, &definition_eval_block)            double_definition_create = DoubleDefinitions::DoubleDefinitionCreate.new            double_definition_create.#{method_name}!(method_name, &definition_eval_block)          end), __FILE__, __LINE__ + 1)
end

Public Instance Methods

any_times() click to toggle source

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}
# File lib/rr/adapters/rr_methods.rb, line 37
def any_times
  TimesCalledMatchers::AnyTimesMatcher.new
end
anything() click to toggle source

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
# File lib/rr/adapters/rr_methods.rb, line 45
def anything
  RR::WildcardMatchers::Anything.new
end
boolean() click to toggle source

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
# File lib/rr/adapters/rr_methods.rb, line 69
def boolean
  RR::WildcardMatchers::Boolean.new
end
duck_type(*args) click to toggle source

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
# File lib/rr/adapters/rr_methods.rb, line 80
def duck_type(*args)
  RR::WildcardMatchers::DuckType.new(*args)
end
hash_including(expected_hash) click to toggle source

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
# File lib/rr/adapters/rr_methods.rb, line 89
def hash_including(expected_hash)
  RR::WildcardMatchers::HashIncluding.new(expected_hash)
end
is_a(klass) click to toggle source

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
# File lib/rr/adapters/rr_methods.rb, line 53
def is_a(klass)
  RR::WildcardMatchers::IsA.new(klass)
end
numeric() click to toggle source

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
# File lib/rr/adapters/rr_methods.rb, line 61
def numeric
  RR::WildcardMatchers::Numeric.new
end
received(subject) click to toggle source
# File lib/rr/adapters/rr_methods.rb, line 111
def received(subject)
  RR::SpyVerificationProxy.new(subject)
end
reset() click to toggle source

Resets the registered Doubles and ordered Doubles

# File lib/rr/adapters/rr_methods.rb, line 29
def reset
  RR::Space.instance.reset
end
satisfy(expectation_proc=nil, &block) click to toggle source

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
# File lib/rr/adapters/rr_methods.rb, line 98
def satisfy(expectation_proc=nil, &block)
  expectation_proc ||= block
  RR::WildcardMatchers::Satisfy.new(expectation_proc)
end
spy(subject) click to toggle source
# File lib/rr/adapters/rr_methods.rb, line 103
def spy(subject)
  methods_to_stub = subject.public_methods.map {|method_name| method_name.to_sym} -
    [:methods, :==, :__send__, :__id__, :object_id]
  methods_to_stub.each do |method|
    stub.proxy(subject, method)
  end
end
verify() click to toggle source

Verifies all the DoubleInjection objects have met their TimesCalledExpectations.

# File lib/rr/adapters/rr_methods.rb, line 24
def verify
  RR::Space.instance.verify_doubles
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.