[rspec-users] weirdness with rake spec!

David Chelimsky dchelimsky at gmail.com
Wed Jun 23 18:11:56 EDT 2010

On Jun 23, 2010, at 3:25 PM, Patrick J. Collins wrote:

>> Why not just use a rails helper? Then you get all the other helpers and environment for free.
> Well, these are usually complex helpers that build a lot of html, and I utilize
> a lot of instance variables to share between methods...  My practice has been
> to put these things in their own class so that I won't have conflicts with
> other instance variables...

I'd recommend slinging values around rather than storing them in instance variables. Passing values around makes each method much easier to test, and you don't have to concern yourself with values persisting across requests, etc, etc.

> I don't understand though why rake spec would fail but script/spec wouldn't...
> Is there something different about the environment when rake spec is called?

There can be. It depends on what else is going on in your app. For one thing, running rake loads all of the .rake files in the lib/tasks directories of your app and all installed plugins.

Could also be a load order thing. The fact that you sometimes get an argument error on pluralize suggests that there is more than one definition of pluralize in your app or one of its dependencies, and they're not getting loaded in the same order with both commands.

Not sure if that helps solve your problem, but hopefully it sheds some light on it.


More information about the rspec-users mailing list