Hi, I am new to rspec and started implementing it on my project yesterday. I have followed the instructions and installed rspec gem and rspec plugin into my project. I created couple of sample stories and tried running the specs using spec command which worked fine, but when I started using rake spec command it is loading development environment instead of test environment. I tried to putting some STDOUT's in spec_helper.rb but it seems that this file is never interpreted. Am I missing something? Please help, Thanks in advance. -SatishG
on 2008-08-19 20:05
on 2008-08-19 20:23
On Aug 19, 2008, at 1:05 PM, Satish Gunnu <lists@ruby-forum.com> wrote: > Hi, > > I am new to rspec and started implementing it on my project > yesterday. > I have followed the instructions What instructions? > and installed rspec gem and rspec > plugin into my project. I created couple of sample stories and tried > running the specs using spec command which worked fine, but when I > started using rake spec command it is loading development environment > instead of test environment. I tried to putting some STDOUT's in > spec_helper.rb but it seems that this file is never interpreted. Are you including it from your spec files?
on 2008-08-19 22:08
Hi David, Most of my knowledge came from peepcode rspec screencast and the following link. http://rspec.rubyforge.org/documentation/rails/install.html Here are the steps I have done to get going. 1) Installed rspec gem 2) Installed rspec plugin in my project 3) created a test_spec.rb file which have sample stories 4) ruby script/generate rspec 5) rake spec I have one initializer file for oracle_driver in initializers directory which is set to not load in test environment. when I run rake spec command this initializer is invoked and I see that the environment is set to development but not test. To answer your second questions, I am not including it from my spec files. BTW I am using rpsec 1.1.4 and rails 2.1.0. Sorry for not being elaborate in my prev post. Thanks, SatishG. David Chelimsky wrote: > On Aug 19, 2008, at 1:05 PM, Satish Gunnu <lists@ruby-forum.com> wrote: > >> Hi, >> >> I am new to rspec and started implementing it on my project >> yesterday. >> I have followed the instructions > > What instructions? > >> and installed rspec gem and rspec >> plugin into my project. I created couple of sample stories and tried >> running the specs using spec command which worked fine, but when I >> started using rake spec command it is loading development environment >> instead of test environment. I tried to putting some STDOUT's in >> spec_helper.rb but it seems that this file is never interpreted. > > Are you including it from your spec files?
on 2008-08-19 22:11
On Aug 19, 2008, at 2:05 PM, Satish Gunnu wrote: > missing something? Please help, Thanks in advance. > > -SatishG > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users iirc, it looks at the development environment to prepare the db schema, but still runs the specs in test. Is that what you're seeing?
on 2008-08-19 22:32
Yes I think that is what's happening in my case. is this how it is supposed to work? or can we have rspec ignore the step to look at development environment. thanks so much for all your help. > iirc, it looks at the development environment to prepare the db > schema, but still runs the specs in test. Is that what you're seeing?
on 2008-08-19 23:09
On Aug 19, 2008, at 4:32 PM, Satish Gunnu wrote: > Yes I think that is what's happening in my case. is this how it is > supposed to work? or can we have rspec ignore the step to look at > development environment. thanks so much for all your help. you'll notice that vendor/plugins/rspec-rails/rspec.rake contains the line spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop which you could change or comment out
on 2008-08-19 23:12
On Tue, Aug 19, 2008 at 2:08 PM, Jonathan Linowes <jonathan@parkerhill.com>wrote: > > you'll notice that vendor/plugins/rspec-rails/rspec.rake contains the line > > spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) > ? "db:test:prepare" : :noop > > which you could change or comment out You'd have to remember to run your migrations against the test db as well as the dev db. ///ark
on 2008-08-19 23:14
On Tue, Aug 19, 2008 at 3:08 PM, Satish Gunnu <lists@ruby-forum.com> wrote: > 3) created a test_spec.rb file which have sample stories > 4) ruby script/generate rspec > 5) rake spec > > I have one initializer file for oracle_driver in initializers > directory which is set to not load in test environment. when I run rake > spec command this initializer is invoked and I see that the environment > is set to development but not test. > > To answer your second questions, I am not including it from my spec > files. I'd recommend doing so if you want the spec_helper.rb file to be loaded. It will set the environment for you correctly.
on 2008-08-19 23:14
> > http://rspec.rubyforge.org/documentation/rails/install.html > I sure wish someone would take that page down - it's caused me more than my share of grief. ///ark
on 2008-08-19 23:21
Awesome. Thanks guys. Appreciate your help. Mark Wilden wrote: > On Tue, Aug 19, 2008 at 2:08 PM, Jonathan Linowes > <jonathan@parkerhill.com>wrote: > >> >> you'll notice that vendor/plugins/rspec-rails/rspec.rake contains the line >> >> spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) >> ? "db:test:prepare" : :noop >> >> which you could change or comment out > > > You'd have to remember to run your migrations against the test db as > well as > the dev db. > > ///ark
on 2008-08-19 23:38
On Aug 19, 2008, at 5:08 PM, Jonathan Linowes wrote: > spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', > 'database.yml')) ? "db:test:prepare" : :noop > > which you could change or comment out note, I ran into this wanting to run through my specs on my production server, which doesnt have a development environment but does have a production one. So instead I run (via a cap deploy:spec task i wrote) rake spec RAILS_ENV=production that way the db:test:prepare uses the production db rather than the development one
on 2009-05-14 04:59
I know this thread is long dead, but I'm finding that I have the same problem. 'rake spec:modles' loads the development environment and clobbers my development database. I have to run set RAILS_ENV=test in order for the tests to run correctly. Commenting out that rake task line does not solve the problem. WHat's going on? Do I really have to remember to always set the environment to test? Shouldn't that be the default?
on 2009-05-14 05:17
On Wed, May 13, 2009 at 9:59 PM, Matthew Isleb <lists@ruby-forum.com> wrote: > I know this thread is long dead, but I'm finding that I have the same > problem. 'rake spec:modles' loads the development environment and > clobbers my development database. I have to run set RAILS_ENV=test in > order for the tests to run correctly. > > Commenting out that rake task line does not solve the problem. What rake task line in what file?
on 2009-05-14 07:34
On Tue, Aug 19, 2008 at 2:35 PM, Jonathan Linowes <jonathan@parkerhill.com>wrote: > > rake spec RAILS_ENV=production > > that way the db:test:prepare uses the production db rather than the > development one I know this thread is long dead but ... you must be joking. ///ark
on 2010-11-12 20:57
Mark Wilden wrote in post #816031: > On Tue, Aug 19, 2008 at 2:35 PM, Jonathan Linowes > <jonathan@parkerhill.com>wrote: > >> >> rake spec RAILS_ENV=production >> >> that way the db:test:prepare uses the production db rather than the >> development one > > > I know this thread is long dead but ... you must be joking. > > ///ark I went though same experience today with my recently setup ruby 1.9, rails 3.0, and rspec 2. "$ rake spec" loaded development environment, hitting development db and pumping logs at log/development.log. This caused lot of confusion in my testing (As I run spec within RubyMine at the same time). I found that there is "RAILS_ENV=development" in my bash environment. Once I remove that, everything works as expected. rspec loads test environment, test db, and logging at log/test.log. One thing I noticed is when I have RAILS_ENV=development, even if I tried "$ rake spec RAILS_ENV=test", it actually hit development environment. I thought argument override shell env setting. Am I wrong or is it rspec issue?
on 2011-03-21 19:04
This thread has been dead for awhile, but I'm having the same issue. I don't have a bash variable set. I'm also having this issue with Cucumber. It always runs in development mode. If I put "p Rails.env" in spec_helper.rb:8 (after spec_helper already declares ENV["RAILS_ENV"] ||= "test") and run "rake spec" it outputs "development" every time. If I run "spec spec/*/**" it outputs "test" like it should. My setup: Rails 2.3.9 Rake 0.8.7 Bundler 1.0.10 Rspec-rails 1.3.3 Rspec 1.3.1
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.