Marcus Crafter
2007-Apr-17 02:21 UTC
[Cruisecontrolrb-users] CC.rb, rails and rspec tests using production database?
Hi All, Hope all is going well. Just installed CC.rb in my development environment here and it looks great. Top stuff. I was able to get my Rails project registered and building properly which was awesome. I''m using RSpec for my tests rather than Test::Unit, so I modified the project.rake_task to be ''spec'' rather than commented out, however it seems that CC.rb now tries to run my spec''s over the production database rather than the test database. Running a ''rake spec'' from the command line with the same project works fine as expected, however unfortunately through CC.rb it fails. Anyone got any thoughts where things might be wrong with the configuration of what database to use? or any pointers where to take a look? Thanks for any thoughts, ideas. Cheers, Marcus
Jeff Xiong
2007-Apr-17 02:43 UTC
[Cruisecontrolrb-users] CC.rb, rails and rspec tests using production database?
Have you tried to create a /lib/tasks/cruise.rake file, then invoke ''spec'' task in it? desc ''Continuous build target'' task :cruise do Rake::Task["speck"].invoke end CC.rb prefers ''cruise'' rake task. On 4/17/07, Marcus Crafter <marcus at marcuscrafter.com> wrote:> Hi All, > > Hope all is going well. > > Just installed CC.rb in my development environment here and it looks > great. Top stuff. > > I was able to get my Rails project registered and building properly > which was awesome. > > I''m using RSpec for my tests rather than Test::Unit, so I modified > the project.rake_task to be ''spec'' rather than commented out, however > it seems that CC.rb now tries to run my spec''s over the production > database rather than the test database. > > Running a ''rake spec'' from the command line with the same project > works fine as expected, however unfortunately through CC.rb it fails. > > Anyone got any thoughts where things might be wrong with the > configuration of what database to use? or any pointers where to take > a look? > > Thanks for any thoughts, ideas. > > Cheers, > > Marcus > _______________________________________________ > Cruisecontrolrb-users mailing list > Cruisecontrolrb-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users >-- Jeff Xiong Software Journeyman - http://gigix.thoughtworkers.org Open Source Contributor - http://cruisecontrolrb.thoughtworks.com/ Technical Evangelist - http://www.infoq.com/cn/
Marcus Crafter
2007-Apr-17 02:54 UTC
[Cruisecontrolrb-users] CC.rb, rails and rspec tests using production database?
Hi Jeff, Thanks for your response - just gave that a go, but unfortunately the same error occurs - it seems that it''s able to run the spec''s, just that they all fail due to the wrong database: 1) ActiveRecord::StatementInvalid in ''A new Activation object should be invalid without a name'' Mysql::Error: Table ''cms_production.activations'' doesn''t exist: SHOW FIELDS FROM activations ./spec/models/activation_spec.rb:7: ...... I''ve checked my project all over, and there''s no setting of the RAILS_ENV to production anywhere, and a rake spec on the command line works fine with the right database. Still digging in to it.. Cheers, Marcus On 17/04/2007, at 12:43 PM, Jeff Xiong wrote:> Have you tried to create a /lib/tasks/cruise.rake file, then invoke > ''spec'' task in it? > > desc ''Continuous build target'' > task :cruise do > Rake::Task["speck"].invoke > end > > CC.rb prefers ''cruise'' rake task. > > On 4/17/07, Marcus Crafter <marcus at marcuscrafter.com> wrote: >> Hi All, >> >> Hope all is going well. >> >> Just installed CC.rb in my development environment here and it looks >> great. Top stuff. >> >> I was able to get my Rails project registered and building properly >> which was awesome. >> >> I''m using RSpec for my tests rather than Test::Unit, so I modified >> the project.rake_task to be ''spec'' rather than commented out, however >> it seems that CC.rb now tries to run my spec''s over the production >> database rather than the test database. >> >> Running a ''rake spec'' from the command line with the same project >> works fine as expected, however unfortunately through CC.rb it fails. >> >> Anyone got any thoughts where things might be wrong with the >> configuration of what database to use? or any pointers where to take >> a look? >> >> Thanks for any thoughts, ideas. >> >> Cheers, >> >> Marcus >> _______________________________________________ >> Cruisecontrolrb-users mailing list >> Cruisecontrolrb-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users >> > > > -- > Jeff Xiong > Software Journeyman - http://gigix.thoughtworkers.org > Open Source Contributor - http://cruisecontrolrb.thoughtworks.com/ > Technical Evangelist - http://www.infoq.com/cn/ > _______________________________________________ > Cruisecontrolrb-users mailing list > Cruisecontrolrb-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users
Alexey Verkhovsky
2007-Apr-17 03:00 UTC
[Cruisecontrolrb-users] CC.rb, rails and rspec tests using production database?
Marcus, CC.rb version 1.1 doesn''t change RAILS_ENV, either (earlier versions did). If you want to try and force it to be ''test'' before ''spec'' task is invoked, try this: desc ''Continuous build target'' task :cruise do ENV[''RAILS_ENV''] = ''test'' Rake::Task[''spec''].invoke end If that doesn''t help, please send me your Rakefile (or whatever needed to reproduce the issue) off-list, and I''ll look into it. Best regards, Alex Marcus Crafter <marcus at marcuscrafter.com> Sent by: cruisecontrolrb-users-bounces at rubyforge.org 04/16/2007 08:54 PM To cruisecontrolrb-users at rubyforge.org cc Subject Re: [Cruisecontrolrb-users] CC.rb, rails and rspec tests using production database? Hi Jeff, Thanks for your response - just gave that a go, but unfortunately the same error occurs - it seems that it''s able to run the spec''s, just that they all fail due to the wrong database: 1) ActiveRecord::StatementInvalid in ''A new Activation object should be invalid without a name'' Mysql::Error: Table ''cms_production.activations'' doesn''t exist: SHOW FIELDS FROM activations ./spec/models/activation_spec.rb:7: ...... I''ve checked my project all over, and there''s no setting of the RAILS_ENV to production anywhere, and a rake spec on the command line works fine with the right database. Still digging in to it.. Cheers, Marcus On 17/04/2007, at 12:43 PM, Jeff Xiong wrote:> Have you tried to create a /lib/tasks/cruise.rake file, then invoke > ''spec'' task in it? > > desc ''Continuous build target'' > task :cruise do > Rake::Task["speck"].invoke > end > > CC.rb prefers ''cruise'' rake task. > > On 4/17/07, Marcus Crafter <marcus at marcuscrafter.com> wrote: >> Hi All, >> >> Hope all is going well. >> >> Just installed CC.rb in my development environment here and it looks >> great. Top stuff. >> >> I was able to get my Rails project registered and building properly >> which was awesome. >> >> I''m using RSpec for my tests rather than Test::Unit, so I modified >> the project.rake_task to be ''spec'' rather than commented out, however >> it seems that CC.rb now tries to run my spec''s over the production >> database rather than the test database. >> >> Running a ''rake spec'' from the command line with the same project >> works fine as expected, however unfortunately through CC.rb it fails. >> >> Anyone got any thoughts where things might be wrong with the >> configuration of what database to use? or any pointers where to take >> a look? >> >> Thanks for any thoughts, ideas. >> >> Cheers, >> >> Marcus >> _______________________________________________ >> Cruisecontrolrb-users mailing list >> Cruisecontrolrb-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users >> > > > -- > Jeff Xiong > Software Journeyman - http://gigix.thoughtworkers.org > Open Source Contributor - http://cruisecontrolrb.thoughtworks.com/ > Technical Evangelist - http://www.infoq.com/cn/ > _______________________________________________ > Cruisecontrolrb-users mailing list > Cruisecontrolrb-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users_______________________________________________ Cruisecontrolrb-users mailing list Cruisecontrolrb-users at rubyforge.org http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/cruisecontrolrb-users/attachments/20070416/ef83f6d1/attachment.html
Marcus Crafter
2007-Apr-17 11:56 UTC
[Cruisecontrolrb-users] CC.rb, rails and rspec tests using production database?
Hi Alex, Thanks for your help - unfortunately setting the environment directly didn''t fix it either - I''ll follow through and send you a simple environment that reproduces the problem offline now. Cheers, Marcus On 17/04/2007, at 1:00 PM, Alexey Verkhovsky wrote:> > Marcus, > > CC.rb version 1.1 doesn''t change RAILS_ENV, either (earlier > versions did). > > If you want to try and force it to be ''test'' before ''spec'' task is > invoked, try this: > > desc ''Continuous build target'' > task :cruise do > ENV[''RAILS_ENV''] = ''test'' > Rake::Task[''spec''].invoke > end > > If that doesn''t help, please send me your Rakefile (or whatever > needed to reproduce the issue) off-list, and I''ll look into it. > > Best regards, > Alex > > > > > Marcus Crafter <marcus at marcuscrafter.com> > Sent by: cruisecontrolrb-users-bounces at rubyforge.org > 04/16/2007 08:54 PM > > To > cruisecontrolrb-users at rubyforge.org > cc > Subject > Re: [Cruisecontrolrb-users] CC.rb, rails and rspec tests > using production database? > > > > > > Hi Jeff, > > Thanks for your response - just gave that a go, but unfortunately the > same error occurs - it seems that it''s able to run the spec''s, just > that they all fail due to the wrong database: > > 1) ActiveRecord::StatementInvalid in ''A new Activation object should > be invalid without a name'' Mysql::Error: Table > ''cms_production.activations'' doesn''t exist: SHOW FIELDS FROM > activations ./spec/models/activation_spec.rb:7: > ...... > > I''ve checked my project all over, and there''s no setting of the > RAILS_ENV to production anywhere, and a rake spec on the command line > works fine with the right database. > > Still digging in to it.. > > Cheers, > > Marcus > > > On 17/04/2007, at 12:43 PM, Jeff Xiong wrote: > > > Have you tried to create a /lib/tasks/cruise.rake file, then invoke > > ''spec'' task in it? > > > > desc ''Continuous build target'' > > task :cruise do > > Rake::Task["speck"].invoke > > end > > > > CC.rb prefers ''cruise'' rake task. > > > > On 4/17/07, Marcus Crafter <marcus at marcuscrafter.com> wrote: > >> Hi All, > >> > >> Hope all is going well. > >> > >> Just installed CC.rb in my development environment here and it > looks > >> great. Top stuff. > >> > >> I was able to get my Rails project registered and building properly > >> which was awesome. > >> > >> I''m using RSpec for my tests rather than Test::Unit, so I modified > >> the project.rake_task to be ''spec'' rather than commented out, > however > >> it seems that CC.rb now tries to run my spec''s over the production > >> database rather than the test database. > >> > >> Running a ''rake spec'' from the command line with the same project > >> works fine as expected, however unfortunately through CC.rb it > fails. > >> > >> Anyone got any thoughts where things might be wrong with the > >> configuration of what database to use? or any pointers where to > take > >> a look? > >> > >> Thanks for any thoughts, ideas. > >> > >> Cheers, > >> > >> Marcus > >> _______________________________________________ > >> Cruisecontrolrb-users mailing list > >> Cruisecontrolrb-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users > >> > > > > > > -- > > Jeff Xiong > > Software Journeyman - http://gigix.thoughtworkers.org > > Open Source Contributor - http://cruisecontrolrb.thoughtworks.com/ > > Technical Evangelist - http://www.infoq.com/cn/ > > _______________________________________________ > > Cruisecontrolrb-users mailing list > > Cruisecontrolrb-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users > > _______________________________________________ > Cruisecontrolrb-users mailing list > Cruisecontrolrb-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > > _______________________________________________ > Cruisecontrolrb-users mailing list > Cruisecontrolrb-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users
Jim Hughes
2007-Apr-17 13:23 UTC
[Cruisecontrolrb-users] CC.rb, rails and rspec tests using production database?
db:test:clone really wants to use the test environment. (If you look at your test.log, you might notice that even when your specs are trying to run against production or development, your test db is being cloned correctly.) Since I am testing in a non-standard environment, cruise_build, I use db:migrate, which uses the current RAILS_ENV. J. On Apr 17, 2007, at 8:04 AM, Marcus Crafter wrote:> Hi Jim, > > Awesome, thanks for that mate, I''ll take a closer look at that in > the morning when I can try it out. Looks like I might have to do > something similar to get it to work on my test database. > > BTW, something else I''m just wondering, since you''re setting your > RAILS_ENV explicitly, do you prefer to use db:migrate to load up > your non-development databases such as test, rather than the > db:test:clone task? > > From what I can tell, db:test:clone doesn''t include data from your > development database, it just loads up the schema - in my case I > have static data in a few tables that I had in migrations after the > create_table declarations - they don''t show up at all in any non- > migrated database using clone, etc. > > Seems like db:test:clone isn''t the right thing to use to create > your test database? Or have I lost the plot somewhere along the > track? :) > > Thanks again for your help. > > Cheers, > > Marcus > > On 17/04/2007, at 10:32 PM, Jim Hughes wrote: > >> Here''s a snippet from my rakefile: >> >> task :build_env do >> ENV[''RAILS_ENV''] = ''cruise_build'' >> RAILS_ENV = ''cruise_build'' >> end >> >> task :cruise => [:build_env,''db:migrate'',:spec_cruise] >> >> I found setting RAILS_ENV to be necessary. (I use a different env >> from test because the db is different on my ci server.) >> >> Jim >> >> >> On Apr 17, 2007, at 6:56 AM, Marcus Crafter wrote: >> >>> Hi Alex, >>> >>> Thanks for your help - unfortunately setting the environment >>> directly >>> didn''t fix it either - I''ll follow through and send you a simple >>> environment that reproduces the problem offline now. >>> >>> Cheers, >>> >>> Marcus >>> >>> >>> On 17/04/2007, at 1:00 PM, Alexey Verkhovsky wrote: >>> >>>> >>>> Marcus, >>>> >>>> CC.rb version 1.1 doesn''t change RAILS_ENV, either (earlier >>>> versions did). >>>> >>>> If you want to try and force it to be ''test'' before ''spec'' task is >>>> invoked, try this: >>>> >>>> desc ''Continuous build target'' >>>> task :cruise do >>>> ENV[''RAILS_ENV''] = ''test'' >>>> Rake::Task[''spec''].invoke >>>> end >>>> >>>> If that doesn''t help, please send me your Rakefile (or whatever >>>> needed to reproduce the issue) off-list, and I''ll look into it. >>>> >>>> Best regards, >>>> Alex >>>> >>>> >>>> >>>> >>>> Marcus Crafter <marcus at marcuscrafter.com> >>>> Sent by: cruisecontrolrb-users-bounces at rubyforge.org >>>> 04/16/2007 08:54 PM >>>> >>>> To >>>> cruisecontrolrb-users at rubyforge.org >>>> cc >>>> Subject >>>> Re: [Cruisecontrolrb-users] CC.rb, rails and rspec tests >>>> using production database? >>>> >>>> >>>> >>>> >>>> >>>> Hi Jeff, >>>> >>>> Thanks for your response - just gave that a go, but >>>> unfortunately the >>>> same error occurs - it seems that it''s able to run the spec''s, just >>>> that they all fail due to the wrong database: >>>> >>>> 1) ActiveRecord::StatementInvalid in ''A new Activation object >>>> should >>>> be invalid without a name'' Mysql::Error: Table >>>> ''cms_production.activations'' doesn''t exist: SHOW FIELDS FROM >>>> activations ./spec/models/activation_spec.rb:7: >>>> ...... >>>> >>>> I''ve checked my project all over, and there''s no setting of the >>>> RAILS_ENV to production anywhere, and a rake spec on the command >>>> line >>>> works fine with the right database. >>>> >>>> Still digging in to it.. >>>> >>>> Cheers, >>>> >>>> Marcus >>>> >>>> >>>> On 17/04/2007, at 12:43 PM, Jeff Xiong wrote: >>>> >>>>> Have you tried to create a /lib/tasks/cruise.rake file, then >>>>> invoke >>>>> ''spec'' task in it? >>>>> >>>>> desc ''Continuous build target'' >>>>> task :cruise do >>>>> Rake::Task["speck"].invoke >>>>> end >>>>> >>>>> CC.rb prefers ''cruise'' rake task. >>>>> >>>>> On 4/17/07, Marcus Crafter <marcus at marcuscrafter.com> wrote: >>>>>> Hi All, >>>>>> >>>>>> Hope all is going well. >>>>>> >>>>>> Just installed CC.rb in my development environment here and it >>>> looks >>>>>> great. Top stuff. >>>>>> >>>>>> I was able to get my Rails project registered and building >>>>>> properly >>>>>> which was awesome. >>>>>> >>>>>> I''m using RSpec for my tests rather than Test::Unit, so I >>>>>> modified >>>>>> the project.rake_task to be ''spec'' rather than commented out, >>>> however >>>>>> it seems that CC.rb now tries to run my spec''s over the >>>>>> production >>>>>> database rather than the test database. >>>>>> >>>>>> Running a ''rake spec'' from the command line with the same project >>>>>> works fine as expected, however unfortunately through CC.rb it >>>> fails. >>>>>> >>>>>> Anyone got any thoughts where things might be wrong with the >>>>>> configuration of what database to use? or any pointers where to >>>> take >>>>>> a look? >>>>>> >>>>>> Thanks for any thoughts, ideas. >>>>>> >>>>>> Cheers, >>>>>> >>>>>> Marcus >>>>>> _______________________________________________ >>>>>> Cruisecontrolrb-users mailing list >>>>>> Cruisecontrolrb-users at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users >>>>>> >>>>> >>>>> >>>>> -- >>>>> Jeff Xiong >>>>> Software Journeyman - http://gigix.thoughtworkers.org >>>>> Open Source Contributor - http://cruisecontrolrb.thoughtworks.com/ >>>>> Technical Evangelist - http://www.infoq.com/cn/ >>>>> _______________________________________________ >>>>> Cruisecontrolrb-users mailing list >>>>> Cruisecontrolrb-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users >>>> >>>> _______________________________________________ >>>> Cruisecontrolrb-users mailing list >>>> Cruisecontrolrb-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users >>>> >>>> ___________________________________________________________________ >>>> ___ >>>> This email has been scanned by the MessageLabs Email Security >>>> System. >>>> For more information please visit http://www.messagelabs.com/email >>>> ___________________________________________________________________ >>>> ___ >>>> >>>> _______________________________________________ >>>> Cruisecontrolrb-users mailing list >>>> Cruisecontrolrb-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users >>> >>> _______________________________________________ >>> Cruisecontrolrb-users mailing list >>> Cruisecontrolrb-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users >> >