Permalink
Browse files

stub the instance method, there is no class method

  • Loading branch information...
jeremy committed Apr 11, 2008
1 parent 13e7849 commit 9a7ab8b05b748932d25d3e05a3d09600afa99f7b
Showing with 1 addition and 1 deletion.
  1. +1 −1 actionpack/test/controller/dispatcher_test.rb
@@ -41,7 +41,7 @@ def test_failsafe_response
CGI.expects(:new).raises('some multipart parsing failure')
ActionController::Routing::Routes.stubs(:reload)
- Dispatcher.stubs(:log_failsafe_exception)
+ Dispatcher.any_instance.stubs(:log_failsafe_exception)

This comment has been minimized.

Show comment Hide comment
@mislav

mislav Apr 12, 2008

Member

Thought I knew all of Mocha :-/

@mislav

mislav Apr 12, 2008

Member

Thought I knew all of Mocha :-/

assert_nothing_raised { dispatch }

6 comments on commit 9a7ab8b

@tomafro

This comment has been minimized.

Show comment Hide comment
@tomafro

tomafro Apr 12, 2008

Contributor

If you mean #any_instance, you were better off not knowing. It’s a nasty code smell.

Contributor

tomafro replied Apr 12, 2008

If you mean #any_instance, you were better off not knowing. It’s a nasty code smell.

@joevandyk

This comment has been minimized.

Show comment Hide comment
@joevandyk

joevandyk Apr 12, 2008

Contributor

You’re a nasty code smell.

Contributor

joevandyk replied Apr 12, 2008

You’re a nasty code smell.

@josh

This comment has been minimized.

Show comment Hide comment
@josh

josh Apr 15, 2008

Member

git-bisect says was not a good idea. What handy a little tool.

9a7ab8b05b748932d25d3e05a3d09600afa99f7b is first bad commit
commit 9a7ab8b05b748932d25d3e05a3d09600afa99f7b
Author: Jeremy Kemper jeremy@bitsweat.net
Date: Fri Apr 11 16:44:42 2008 -0700

Investigating.

Member

josh replied Apr 15, 2008

git-bisect says was not a good idea. What handy a little tool.

9a7ab8b05b748932d25d3e05a3d09600afa99f7b is first bad commit
commit 9a7ab8b05b748932d25d3e05a3d09600afa99f7b
Author: Jeremy Kemper jeremy@bitsweat.net
Date: Fri Apr 11 16:44:42 2008 -0700

Investigating.

@lazyatom

This comment has been minimized.

Show comment Hide comment
@lazyatom

lazyatom Apr 15, 2008

Contributor
  1. any_instance is useful where you can’t turn the instance (of Dispatcher in this case) into a collaborator (i.e. something that’s passed to a method).

Another way of getting around using #any_instance is stubbing whatever creates the Dispatcher instance (and probably extracting the creation of the Dispatcher into a method while you do that) to return a known instance (or a stub object).

However, often that’s more work than one might hope…

Contributor

lazyatom replied Apr 15, 2008

  1. any_instance is useful where you can’t turn the instance (of Dispatcher in this case) into a collaborator (i.e. something that’s passed to a method).

Another way of getting around using #any_instance is stubbing whatever creates the Dispatcher instance (and probably extracting the creation of the Dispatcher into a method while you do that) to return a known instance (or a stub object).

However, often that’s more work than one might hope…

@lazyatom

This comment has been minimized.

Show comment Hide comment
@lazyatom

lazyatom Apr 15, 2008

Contributor

(apologies for the weird formatting there, i didn’t realise it was going to use Markdown…)

Contributor

lazyatom replied Apr 15, 2008

(apologies for the weird formatting there, i didn’t realise it was going to use Markdown…)

@robbyrussell

This comment has been minimized.

Show comment Hide comment
@robbyrussell

robbyrussell Apr 15, 2008

Contributor

@lazyatom:

NO WORRIES!

Contributor

robbyrussell replied Apr 15, 2008

@lazyatom:

NO WORRIES!

Please sign in to comment.