[rspec-users] stub in config.before
dchelimsky at gmail.com
Sun Aug 14 23:17:24 EDT 2011
On Aug 14, 2011, at 10:15 PM, Justin Ko wrote:
> On Sun, Aug 14, 2011 at 3:48 PM, John Hinnegan <john.hinnegan at gmail.com> wrote:
> I was trying to stub something "globally", across all tests today, and had some trouble.
> I tried
> RSpec.configure do |config|
> config.before(:all) do
> seems that stub is not available here yet. (I was stubbing a class method, and the class was loaded correctly).
> Is there somewhere else I should be putting this? At what point is the stub code loaded?
> (PS, the code I'm using in there works just fine in "proper" before blocks inside describe blocks)
> rspec-users mailing list
> rspec-users at rubyforge.org
> That *should* work. The before's in config are run before any before's in your specs. And as long as you're not using any other mocking framework, `.stub` should work as well. We'll need some more info to help you debug.
The problem is not that it's a global config, but it's in before(:all). Put it in a before(:each) and it will work.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users