[rspec-users] [rspec-rails] rspec-rails forcing test environment?

David Chelimsky dchelimsky at gmail.com
Fri Jul 31 08:36:39 EDT 2009


On Fri, Jul 31, 2009 at 3:57 AM, Balint Erdi<balint.erdi at gmail.com> wrote:
> Hi,
>
> I realized that requiring rspec-rails somehow sets RAILS_ENV to
> 'test'. My experimental environment.rb file is the following:
>
> puts "XXX RAILS_ENV: #{RAILS_ENV}"
>
> Rails::Initializer.run do |config|
>  (...)
>  config.gem "rspec", :version => ">= 1.2.8", :lib => 'spec'
>  config.gem "rspec-rails", :version => ">= 1.2.7.1", :lib => 'spec/

Use lib => false to keep rails from automatically loading rspec and/or
rspec-rails

This should also be in config/environments/test.rb

HTH,
David

> rails' # (1)
>  (...)
> end
>
> puts "XXX RAILS_ENV: #{RAILS_ENV}"
>
> When I run the server (./script/server), I see:
>
> XXX RAILS_ENV: development
> XXX RAILS_ENV: test
>
> If I comment out the rspec-rails inclusion line (1), then the
> RAILS_ENV remains 'development' after the config block. That's causing
> me a problem because "in the real app" I set up a CouchDB database
> depending on RAILS_ENV after the block.
>
> One possible workaround is to put the rspec and rspec-rails lines into
> the environment file for the test env. (test.rb), but that seems to
> defeat the goal of having all dependencies in one place so that it is
> clear and gem-related rake tasks can be conveniently run. (I am using
> rails 2.3.2, rspec 1.2.8, rspec-rails 1.2.7.1)
>
> Do you know of a better workaround or a real solution for the problem?
>
> Thank you,
> Balint
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list