Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

rake environment for test tasks

#4982

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.

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

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Ryan Bigg
    Ryan Bigg
    • 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.

    June 26th, 2010 @ 02:06 PM

  2. mark
    mark

    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)

    June 26th, 2010 @ 02:09 PM

  3. David Trasbo
    David Trasbo

    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.

    June 26th, 2010 @ 02:09 PM

  4. mark
    mark

    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.

    June 26th, 2010 @ 02:16 PM

  5. David Trasbo
    David Trasbo

    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

    June 26th, 2010 @ 02:20 PM

  6. Rohit Arondekar
    Rohit Arondekar
    • 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.

    June 26th, 2010 @ 02:23 PM

  7. mark
  8. bingbing