I am a bit of a rails and rspec noob. I am trying to use rspec in conjunction with CruiseControlrb. When I run a cruise build having spec errors, the build does not indicate a failure. I have tried to track down why this is the case, and my best guess is that the spec task is kicking off the spec via a ruby() method in rake, and that ruby method does not propagate my spec failure back to rake. Any help in setting this up would be much appreciated. Also, if there is a better alternative to cruisecontrolrb that integrates nicely with rspec, please let me know. Thanks
Hi Alex, I''m having a similar problem with CC.rb at the moment - from what I can see, CC.rb is trying to run my spec''s using the production database, rather than the test one: 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: ... Naturally this causes all of the specs to fail. :-/ Running the same ''rake spec'' on the command line in my rails app works as expected. I don''t have a solution just yet but have also asked if others were having this problem on the cc.rb users mailing list - hopefully we''ll have a solution to it soon. If this isn''t the problem you''re having - would be good to know so we can sort that out too. At least you''re not the only one :) Cheers, Marcus On 17/04/2007, at 12:23 PM, Alex Edwards wrote:> I am a bit of a rails and rspec noob. > > I am trying to use rspec in conjunction with CruiseControlrb. > > When I run a cruise build having spec errors, the build does not > indicate a failure. I have tried to track down why this is the case, > and my best guess is that the spec task is kicking off the spec via a > ruby() method in rake, and that ruby method does not propagate my spec > failure back to rake. > > Any help in setting this up would be much appreciated. > Also, if there is a better alternative to cruisecontrolrb that > integrates nicely with rspec, please let me know. > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
I had that problem too. I ended up just changing my database.yml in my projects/work directory so that production pointed towards the correct database. As my database.yml file is not in source control, this works ok as a workaround. But the problem I am facing is different to that. When I run the spec:app task form cc, spec failures do not result in a build failure. As I said, I think this is because the spec task uses the ruby() method to invoke the specs, and that method is not propagating the spec failure out to the build. I am hoping there might be an option I can pass to the spec that would tell it to reraise any errors, or maybe just a different rake task I can use to invoke my specs? Marcus Crafter wrote:> Hi Alex, > > I''m having a similar problem with CC.rb at the moment - from what I > can see, CC.rb is trying to run my spec''s using the production > database, rather than the test one: > > 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: > ... > > Naturally this causes all of the specs to fail. :-/ > > Running the same ''rake spec'' on the command line in my rails app > works as expected. > > I don''t have a solution just yet but have also asked if others were > having this problem on the cc.rb users mailing list - hopefully we''ll > have a solution to it soon. > > If this isn''t the problem you''re having - would be good to know so we > can sort that out too. At least you''re not the only one :) > > Cheers, > > Marcus > > On 17/04/2007, at 12:23 PM, Alex Edwards wrote: > > >> I am a bit of a rails and rspec noob. >> >> I am trying to use rspec in conjunction with CruiseControlrb. >> >> When I run a cruise build having spec errors, the build does not >> indicate a failure. I have tried to track down why this is the case, >> and my best guess is that the spec task is kicking off the spec via a >> ruby() method in rake, and that ruby method does not propagate my spec >> failure back to rake. >> >> Any help in setting this up would be much appreciated. >> Also, if there is a better alternative to cruisecontrolrb that >> integrates nicely with rspec, please let me know. >> Thanks >> _______________________________________________ >> 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070417/6ea6d559/attachment-0001.html
Hi Alex, Alex Edwards wrote:> I am trying to use rspec in conjunction with CruiseControlrb. >How are you running the specs? I''m using cruise.task in lib/tasks and it works perfectly. Here it is: (Note that it''s a bit complicated because we run firewatir specs too that need some preparations) task ''cruise'' do puts "This is cruise rake task running within the #{RAILS_ENV} environment" Rake::Task[''db:migrate''].invoke Rake::Task[''db:test:clone_structure''] puts "Executing model specs.." Rake::Task[''spec:models''].invoke puts "Executing controller specs.." Rake::Task[''spec:controllers''].invoke puts "Loading fixtures to the database.." # load fixtures Rake::Task[''spec:db:fixtures:load''].invoke # restart server puts "Restarting server/FCGI.." puts `ruby #{File.dirname(__FILE__)+''/../../script/process/reaper -a kill''}` begin start_firefox puts "Running spec:watir.." Rake::Task[''spec:watir''].invoke rescue raise "Watir spec failed!" ensure stop_firefox end end Greetings, Esad
I think I tracked it down. It seems like the: t.spec_opts = [''--options'', "\"#{RAILS_ROOT}/spec/spec.opts\""] was causing my spec.opts to be read, and the use of --drb in my spec.opts resulted in spec failures not causing build failures. Not sure why?? I fixed it by writing my own rake task that did not set any spec opts desc "run specs" Spec::Rake::SpecTask.new(''my_specs'') do |t| # t.spec_opts = [''--options'', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList[''spec/**/*_spec.rb''] end Now my build fails when it is supposed to. I guess it is not so important if I don''t use --drb on my build server, as performance there is not really an issue. Any further thoughts? Esad Hajdarevic wrote:> Hi Alex, > > Alex Edwards wrote: > >> I am trying to use rspec in conjunction with CruiseControlrb. >> >> > How are you running the specs? I''m using cruise.task in lib/tasks and it > works perfectly. > Here it is: > > (Note that it''s a bit complicated because we run firewatir specs too > that need some preparations) > > task ''cruise'' do > puts "This is cruise rake task running within the #{RAILS_ENV} > environment" > > Rake::Task[''db:migrate''].invoke > Rake::Task[''db:test:clone_structure''] > > puts "Executing model specs.." > Rake::Task[''spec:models''].invoke > > puts "Executing controller specs.." > Rake::Task[''spec:controllers''].invoke > > puts "Loading fixtures to the database.." > # load fixtures > Rake::Task[''spec:db:fixtures:load''].invoke > > # restart server > puts "Restarting server/FCGI.." > puts `ruby #{File.dirname(__FILE__)+''/../../script/process/reaper -a > kill''}` > > begin > start_firefox > puts "Running spec:watir.." > Rake::Task[''spec:watir''].invoke > rescue > raise "Watir spec failed!" > ensure > stop_firefox > end > end > > Greetings, > > Esad > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070417/28c4f646/attachment-0001.html
Marcus, I have now got my specs working in CI, and have also found that you can make cruise run under the ''test'' environment by: cruise start -e test Hope this helps you get around your problem. Marcus Crafter wrote:> Hi Alex, > > I''m having a similar problem with CC.rb at the moment - from what I > can see, CC.rb is trying to run my spec''s using the production > database, rather than the test one: > > 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: > ... > > Naturally this causes all of the specs to fail. :-/ > > Running the same ''rake spec'' on the command line in my rails app > works as expected. > > I don''t have a solution just yet but have also asked if others were > having this problem on the cc.rb users mailing list - hopefully we''ll > have a solution to it soon. > > If this isn''t the problem you''re having - would be good to know so we > can sort that out too. At least you''re not the only one :) > > Cheers, > > Marcus > > On 17/04/2007, at 12:23 PM, Alex Edwards wrote: > > >> I am a bit of a rails and rspec noob. >> >> I am trying to use rspec in conjunction with CruiseControlrb. >> >> When I run a cruise build having spec errors, the build does not >> indicate a failure. I have tried to track down why this is the case, >> and my best guess is that the spec task is kicking off the spec via a >> ruby() method in rake, and that ruby method does not propagate my spec >> failure back to rake. >> >> Any help in setting this up would be much appreciated. >> Also, if there is a better alternative to cruisecontrolrb that >> integrates nicely with rspec, please let me know. >> Thanks >> _______________________________________________ >> 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070418/f62a2798/attachment.html
Hi Alex, Thanks for that - I ended up fixing the RAILS_ENV to ''test'' in the project''s Rakefile directly which also got it working, for some reason my lib/tasks/cruise.task wasn''t being picked up but at least it''s all working now. Thanks again for your help mate. Much appreciated :) Cheers, Marcus On 18/04/2007, at 2:32 PM, Alex Edwards wrote:> Marcus, > I have now got my specs working in CI, and have also found that you > can make cruise run under the ''test'' environment by: > cruise start -e test > > Hope this helps you get around your problem. > > Marcus Crafter wrote: >> Hi Alex, I''m having a similar problem with CC.rb at the moment - >> from what I can see, CC.rb is trying to run my spec''s using the >> production database, rather than the test one: 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: ... Naturally this >> causes all of the specs to fail. :-/ Running the same ''rake spec'' >> on the command line in my rails app works as expected. I don''t >> have a solution just yet but have also asked if others were having >> this problem on the cc.rb users mailing list - hopefully we''ll >> have a solution to it soon. If this isn''t the problem you''re >> having - would be good to know so we can sort that out too. At >> least you''re not the only one :) Cheers, Marcus On 17/04/2007, at >> 12:23 PM, Alex Edwards wrote: >>> I am a bit of a rails and rspec noob. I am trying to use rspec in >>> conjunction with CruiseControlrb. When I run a cruise build >>> having spec errors, the build does not indicate a failure. I have >>> tried to track down why this is the case, and my best guess is >>> that the spec task is kicking off the spec via a ruby() method in >>> rake, and that ruby method does not propagate my spec failure >>> back to rake. Any help in setting this up would be much >>> appreciated. Also, if there is a better alternative to >>> cruisecontrolrb that integrates nicely with rspec, please let me >>> know. Thanks _______________________________________________ >>> 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
I am using rspec with Cerberus. I don''t remember if this was the result of the test/production environment with Cerberus or not, but I always set the RAILS_ENV at the top of my spec_helper: ENV["RAILS_ENV"] = "test" Brandon On Apr 16, 2007, at 10:23 PM, Alex Edwards wrote:> I am a bit of a rails and rspec noob. > > I am trying to use rspec in conjunction with CruiseControlrb. > > When I run a cruise build having spec errors, the build does not > indicate a failure. I have tried to track down why this is the case, > and my best guess is that the spec task is kicking off the spec via a > ruby() method in rake, and that ruby method does not propagate my spec > failure back to rake. > > Any help in setting this up would be much appreciated. > Also, if there is a better alternative to cruisecontrolrb that > integrates nicely with rspec, please let me know. > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users