Skip to content

rake spec vs rspec #208

Closed
skyeagle opened this Issue Sep 17, 2010 · 4 comments

3 participants

@skyeagle

Rspec 2.0.0.beta22(edge)
Rails 3.0.0(stable brunch)

When i had run specs through rake spec i got much more failed specs if i run them through rspec command. For example:

rake spec:controllers
....
Failure/Error: response.body.should match(/.*"failure":true.*/) expected "#<ActionDispatch::Response:0xd240c40>" to match /.*"failure":true.*/

and other specs were failed.
When

bundle exec rspec ... same controllers in same order ...

I have got no failed specs.

If i try to run exactly same command that rake runs i have got no fallen specs.
What maybe difference between runnning rake and rspec?

@markiz
markiz commented Sep 17, 2010

Random speculation: does "bundle exec rake spec:controllers" produce the same result?

@skyeagle

Yes, the same issue.

@dchelimsky
RSpec member

When you run bundle exec rspec spec, the rspec command loads up files in the spec directory, which, by convention require "spec_helper" which sets the environment to test before loading anything from Rails.

When you run rake, all of the available rake tasks from all of the dependent gems, and all of their dependencies are loaded. It also starts off in development mode and then forks a new process which gets initialized to test mode, but bundler inherits environment information from the parent process.

As you can see, the specs are running in two very different environments in these two cases, and the cause of the failure can come from any number of places. I'm going to close this as I don't believe it's an RSpec issue, but please feel free to keep the conversation going here. Maybe we can narrow it down.

What does your bundle look like? What's the result of bundle show?

@skyeagle

Hmm... All specs passed after i had run bundle install this morning. But no changes have been made in code since friday. It seems like rails or other gems were updated on holidays.
Btw, thank you for exhaustive explanation.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.