Skip to content

Instantly share code, notes, and snippets.

@ymendel
Created March 2, 2011 07:19
Show Gist options
  • Save ymendel/850590 to your computer and use it in GitHub Desktop.
Save ymendel/850590 to your computer and use it in GitHub Desktop.
stubbing ``
>> class Blah
>> def bang
>> `ls`
>> end
>> end
=> nil
>> Blah.new.bang
=> "Applications\nDatabases\nDesktop\nDocuments\nDropbox\nLibrary\nMovies\nMusic\nPictures\nPublic\nSites\nbin\ndev\ndownloads\nmbox\nnotes.txt\nproblems.pl\nscripts\nstuff\ntmp\n"
>> x = Blah.new
=> #<Blah:0x1036500>
>> x.stubs(:`).returns('crap')
=> #<Mocha::Expectation:0x1033e7c @ordering_constraints=[], @parameters_matcher=#<Mocha::ParametersMatcher:0x1033e18 @matching_block=nil, @expected_parameters=[#<Mocha::ParameterMatchers::AnyParameters:0x1033ddc>]>, @return_values=#<Mocha::ReturnValues:0x1033c74 @values=[#<Mocha::SingleReturnValue:0x1033c9c @value="crap">]>, @yield_parameters=#<Mocha::YieldParameters:0x1033d64 @parameter_groups=[]>, @invocation_count=0, @method_matcher=#<Mocha::MethodMatcher:0x1033e40 @expected_method_name=:`>, @backtrace=["/Library/Ruby/Gems/1.8/gems/mocha-0.9.10/lib/mocha/argument_iterator.rb:15:in `call'", "/Library/Ruby/Gems/1.8/gems/mocha-0.9.10/lib/mocha/argument_iterator.rb:15:in `each'", "/Library/Ruby/Gems/1.8/gems/mocha-0.9.10/lib/mocha/object.rb:94:in `stubs'", "(irb):15:in `irb_binding'", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding'", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/workspace.rb:52"], @cardinality=#<Mocha::Cardinality:0x1033cec @required=0, @maximum=Infinity>, @side_effects=[], @mock=#<Blah:0x1036500>>
>> Blah.new.bang
=> "Applications\nDatabases\nDesktop\nDocuments\nDropbox\nLibrary\nMovies\nMusic\nPictures\nPublic\nSites\nbin\ndev\ndownloads\nmbox\nnotes.txt\nproblems.pl\nscripts\nstuff\ntmp\n"
>> x.bang
=> "crap"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment