Displaying 7 results from an estimated 7 matches for "unstubbed".
Did you mean:
stubbed
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
Hi James,
An instance retains its mocha between tests if that instance is
pointed to by a constant. The simplest failing test is something like
(add as a new file in mocha/test)..
#--code--
require File.join(File.dirname(__FILE__), "test_helper")
require ''stubba''
class WemStubbaTest < Test::Unit::TestCase
Arr = [1, 2, 3]
def test_a
2007 Mar 30
7
problem with using any_instance
Hey all,
I have a question with using mocha in my tests.
In the same test file, I have two tests,
<code>
def test_a
klass.any_instance.stubs(:method_name).returns("something")
klass.new.method_name
...
end
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:
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 test...
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 la...