This project is archived and is in readonly mode.

#4982 ✓invalid
mark

rake environment for test tasks

Reported by mark | June 26th, 2010 @ 12:53 PM

This could be a rspec issue, I am not sure, but when having rails3/rspec2 combo, 'rake spec' uses 'development' environment by default.
'db:test:prepare' task (used as a parent for 'spec') is the one responsible for that as far as I can understand.

Comments and changes to this ticket

  • Ryan Bigg

    Ryan Bigg June 26th, 2010 @ 02:06 PM

    • State changed from “new” to “needs-more-info”
    • Importance changed from “” to “Low”

    I tried duplicating this by calling Rails.env in a before in a spec, but it outputs "test". Please add steps to reproduce.

  • mark

    mark June 26th, 2010 @ 02:09 PM

    http://github.com/markiz/rspec_testzor freshly generated app (steps: updated Gemfile to include rspec, bundle install, rails generate rspec:install, rails generate model testz (wouldn't work without a migration), rake db:migrate, created test/unit/testz_test.rb and spec/models/testz_spec.rb)

  • David Trasbo

    David Trasbo June 26th, 2010 @ 02:09 PM

    Just tested it with a Rails 3.0.0.beta4 app I have lying around that uses RSpec 2. Putting a simple raise Rails.env in one of the spec files shows that test is being used.

    It's a completely standard setup with all test-related gems in the :test group in the Gemfile - including rspec-rails, mocha, factory_girl, shoulda, and so on.

    Mark, if you're still having this issue, I'm having a feeling you should report it to the people behind RSpec instead.

    This can be closed.

  • mark

    mark June 26th, 2010 @ 02:16 PM

    You could set Rails.env in your spec_helper explicitly which would resolve the issue, but it is the default combination of rake tasks that creates the subject problem.

    The thing should be reproducable since I supplied a test-repo in a comment above.

  • David Trasbo

    David Trasbo June 26th, 2010 @ 02:20 PM

    Mark,

    I've worked out what's wrong. You're using rspec-rails version 2.0.0.beta13. The app I tested used beta12. As soon as I changed the 12 to a 13, did bundle install the specs were run in development environment.

    This clearly shows that this is not a Rails issue. I suggest you simply downgrade, and wait till it's fixed. And also, of course, report the issue here: https://rspec.lighthouseapp.com/projects/5645-rspec/tickets

  • Rohit Arondekar

    Rohit Arondekar June 26th, 2010 @ 02:23 PM

    • State changed from “needs-more-info” to “invalid”

    Great work David! :)

    Mark, closing ticket for now. Please report the issue at the RSpec issue tracker and see what happens there.

  • mark
  • bingbing

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages