search for: unstub

Displaying 7 results from an estimated 7 matches for "unstub".

Did you mean: fnstub
2007 Sep 06
5
Removing/overriding/unstubbing a stub?
We''re using Mocha stubs to stub out a slow-performing network request in a Test::Unit class. But naturally, we don''t want to stub it out in the few tests that actually verify the functionality of that network request. Is there a way to do the stub in "setup", but override it for the few tests that need the original functionality? (I realize that in this case, the
2006 Sep 25
3
Problem stubbing instances referred to by constants
...< Test::Unit::TestCase Arr = [1, 2, 3] def test_a Arr.stubs(:size).returns(6) assert_equal 6, Arr.size end def test_b assert_equal 3, Arr.size #=> Failing test when both tests run consecutively end end #--/code-- I got as far as noticing that Stubba::InstanceMethod#unstub is ''intentionally empty''. This is fine for most object instances but not ones that hang around (like the array above). Sadly, I don''t have (or even know whether there should be) a fix. Chris
2007 Mar 30
7
problem with using any_instance
...nd def test_b ... klass.new.method_name ... end </code> where klass is some class when the tests run, test _a passes, but test_b had an error like this: test_b NoMethodError: undefined method `method_name'' for #<klass:0xb6fb1934> I put a <code> puts ''unstub called'' </code> in unstub of any_instance_method.rb and it got called wen running test_a Any idea what the problem it could be? Thanks, Yi
2011 Feb 16
3
stubbing gets undone?
I''m looking at an example where a stub seems to work sometimes, and sometimes appears to become "unstubbed". I haven''t boiled it down to a minimal example, but it goes something like this: ---- the model: class Premise << ActiveRecord::Base def lookup_stuff_on_the_web $stderr.puts("entering lookup_stuff_on_the_web with #{self}") ... end end ---- the rspec te...
2007 Jan 17
8
Mocha Mock''s hanging on after test run?
Hi guys, I''m running mocha (0.3.2) against Rails core and just found an issue where the mock doesn''t go away after the test is run. For example: def test_reset_bang_doesn_reinstall_named_routes ActionController::Routing::Routes.named_routes.expects(:install).never @session.reset! end def test_zzz puts ActionController::Routing::Routes.named_routes.inspect
2007 Dec 05
9
Does mock_model''s :null_object option work?
...39;'m just trying to get past the untested/un-speced cruft quickly to write the spec for my new code, so I''m looking for expediency over prettiness. I''m specifying before( :each ) do @order_address = mock_model( OrderAddress, :null_object => TRUE ) end but finding that unstubbed/unmocked method calls on @order_address still throw error messages like: Mock ''OrderAddress_1026'' received unexpected message :first_name with (no args) so I''m starting to wonder whether the :null_object option is doing anything at all.... Al ______________...
2007 Jan 30
0
nil object in mocks
...od the view would call on my object, or I have to resort to trickery like stubbing ActionController#render, which is also less than ideal. The solution I''ve some up with is a variant on the :null_object option that can be passed to the mock factory. Null objects return themselves from any unstubbed method call. The option I''ve added changes that return value to nil, which doesn''t play so well with method chaining, but does work nicely in most views. The question for you all is: what should the syntax look like? We''ve considered a couple of options but found them...