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 -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2008-Aug-19 18:19 UTC
[rspec-users] rake spec loads development environment
On Aug 19, 2008, at 1:05 PM, Satish Gunnu <lists at ruby-forum.com> wrote:> Hi, > > I am new to rspec and started implementing it on my project > yesterday. > I have followed the instructionsWhat 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?> Am I > missing something? Please help, Thanks in advance. > > -SatishG > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
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 at 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?-- Posted via http://www.ruby-forum.com/.
Jonathan Linowes
2008-Aug-19 20:10 UTC
[rspec-users] rake spec loads development environment
On Aug 19, 2008, at 2:05 PM, Satish Gunnu wrote:> 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 > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-usersiirc, it looks at the development environment to prepare the db schema, but still runs the specs in test. Is that what you''re seeing?
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?-- Posted via http://www.ruby-forum.com/.
Jonathan Linowes
2008-Aug-19 21:08 UTC
[rspec-users] rake spec loads development environment
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> > >> 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? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
> > 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080819/2f9e273b/attachment.html>
On Tue, Aug 19, 2008 at 2:08 PM, Jonathan Linowes <jonathan at 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 outYou''d have to remember to run your migrations against the test db as well as the dev db. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080819/b949eb24/attachment.html>
David Chelimsky
2008-Aug-19 21:14 UTC
[rspec-users] rake spec loads development environment
On Tue, Aug 19, 2008 at 3:08 PM, Satish Gunnu <lists at ruby-forum.com> wrote:> 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.I''d recommend doing so if you want the spec_helper.rb file to be loaded. It will set the environment for you correctly.> > 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 at 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? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Awesome. Thanks guys. Appreciate your help. Mark Wilden wrote:> On Tue, Aug 19, 2008 at 2:08 PM, Jonathan Linowes > <jonathan at 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-- Posted via http://www.ruby-forum.com/.
Jonathan Linowes
2008-Aug-19 21:35 UTC
[rspec-users] rake spec loads development environment
On Aug 19, 2008, at 5:08 PM, Jonathan Linowes wrote:> > 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 outnote, 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> >> >> >>> 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? >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
David Chelimsky
2008-Aug-19 21:37 UTC
[rspec-users] rake spec loads development environment
Done On Tue, Aug 19, 2008 at 4:09 PM, Mark Wilden <mark at mwilden.com> wrote:>> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
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? -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2009-May-14 03:15 UTC
[rspec-users] rake spec loads development environment
On Wed, May 13, 2009 at 9:59 PM, Matthew Isleb <lists at 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?> WHat''s > going on? Do I really have to remember to always set the environment to > test? Shouldn''t that be the default? > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Mark Wilden wrote in post #816031:> On Tue, Aug 19, 2008 at 2:35 PM, Jonathan Linowes > <jonathan at 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. > > ///arkI 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? -- Posted via http://www.ruby-forum.com/.
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 -- Posted via http://www.ruby-forum.com/.