Skip to content

Instantly share code, notes, and snippets.

@jackdempsey
Created October 9, 2008 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackdempsey/15811 to your computer and use it in GitHub Desktop.
Save jackdempsey/15811 to your computer and use it in GitHub Desktop.
irb~ $ irb
>> require 'rubygems'
=> false
>> require 'rr'
=> true
>> extend RR::Adapters::RRMethods
=> main
>> mock(o = Object.new).foo.mock.bar { 'hi' }
=> #<RR::DoubleDefinition:0x22b7cb0 @block_callback_strategy=:returns, @yields_value=nil, @implementation=#<Proc:0x022bbba8@(irb):4>, after_call_valuenil, double#<RR::Double:0x22b7c88 @times_called_expectation=#<RR::Expectations::TimesCalledExpectation:0x22b6f04 @verify_backtrace=["/usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/double.rb:26:in `initialize'", "/usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/double_definition_creator.rb:88:in `new'", "/usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/double_definition_creator.rb:88:in `setup_double'", "/usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/double_definition_creator.rb:59:in `create'", "/usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/double_definition_creator_proxy.rb:14:in `method_missing'", "(irb):4:in `irb_binding'", "/usr/local/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding'", "/usr/local/lib/ruby/1.8/irb/workspace.rb:52"], @matcher=nil, @double=#<RR::Double:0x22b7c88 ...>, times_called0, definition#<RR::DoubleDefinition:0x22b7cb0 ..., @times_called=0, @double_injection=#<RR::DoubleInjection:0x22b8548 @method_name=:bar, @doubles=[#<RR::Double:0x22b7c88 ...>], object#<Object:0x22b940c, @times_matcher=#<RR::TimesCalledMatchers::IntegerMatcher:0x22b6d9c @times=1>, creator_proxy#<RR::DoubleDefinition:0x22b60b8, @argument_expectation=#<RR::Expectations::ArgumentEqualityExpectation:0x22b6db0 @expected_arguments=[]>
>> o.foo.bar
=> "hi"
>> o.foo.bar
RR::Errors::TimesCalledError: foo()
Called 2 times.
Expected 1 times.
from /usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/expectations/times_called_expectation.rb:47:in `verify_input_error'
from /usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/expectations/times_called_expectation.rb:20:in `attempt'
from /usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/double.rb:238:in `call'
from /usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/double_injection.rb:82:in `call_method'
from /usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/double_injection.rb:76:in `__send__'
from /usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/double_injection.rb:76:in `__rr__foo'
from /usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/double_injection.rb:37:in `__send__'
from /usr/local/lib/ruby/gems/1.8/gems/rr-0.5.0/lib/rr/double_injection.rb:37:in `foo'
from (irb):6
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment