I am working on my first Rails BDD project with extensive tests since starting out with Rails a few years ago. Running RSpec or Cucumber is really slow. I''m using Rails 3 and RSpec 2. To run one model spec with only 5 tests takes almost 1 minute! When it finishes it says it took only 0.9 seconds to run the actual test. So obviously it is loading the environment that takes so long. I just restarted my machine as I read somewhere that can make a difference, but no joy for me. Its very frustrating and time consuming - I am usually running tests then going off to do something else while I wait for that to finish, its really spoiling my work flow..! I read somewhere that even 15 seconds is a long time... 1 minute is ridiculous! Also that Java test suites can run hundreds of examples in less than 2 seconds. I wish !! I have looked into Spork, but this is not Rails 3 compatible yet. Is there anything I can do to make this better? Thanks in advance.. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ok - please excuse me - it seems that the info on the Spork readme is out of date... the Rails 3 branch has been merged. just installed and ran a test... wow... 1 minute had become 1 second!! :) On Jan 20, 1:06 pm, adam <adam.elemen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am working on my first Rails BDD project with extensive tests since > starting out with Rails a few years ago. > > Running RSpec or Cucumber is really slow. I''m using Rails 3 and RSpec > 2. > To run one model spec with only 5 tests takes almost 1 minute! When it > finishes it says it took only 0.9 seconds to run the actual test. So > obviously it is loading the environment that takes so long. I just > restarted my machine as I read somewhere that can make a difference, > but no joy for me. > > Its very frustrating and time consuming - I am usually running tests > then going off to do something else while I wait for that to finish, > its really spoiling my work flow..! I read somewhere that even 15 > seconds is a long time... 1 minute is ridiculous! Also that Java test > suites can run hundreds of examples in less than 2 seconds. I wish !! > > I have looked into Spork, but this is not Rails 3 compatible yet. > Is there anything I can do to make this better? > > Thanks in advance..-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
adam wrote in post #976260:> Ok - please excuse me - it seems that the info on the Spork readme is > out of date... the Rails 3 branch has been merged. just installed and > ran a test... wow... 1 minute had become 1 second!!If you haven''t already done so, you might also take a look at the following gems. This is what I have been using in my BDD workflow and really speeds the process up for me. autotest-standalone autotest-rails-pure autotest-fsevent autotest-growl I run this in a second terminal window and watch the Red-Green growl notifications as I work through the Red-Green-Refactor cycle. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
1) If your running ''rake spec'', then don''t, unless you need to do ''rake db:test:prepare'' also. The ''rake spec'' command combines the database rake with ''rspec spec'', that''s why it takes a few seconds before the tests are run. Use ''rspec spec'' instead. 2) Use Spork and Autotest. Follow http://railstutorial.org/chapters/static-pages#sec:testing_tools to get Autotest setup. Note that you don''t need the Spork hack with the newest version of Spork. 3) When using Autotest, consider removing ''bundle exec'' from the RSpec command. In future versions of RSpec, you''ll be able to do this with a configuration setting, or you can get the current RSpec master which has committed the option already (see commit here https://github.com/rspec/rspec-core/commit/1ff93b0969a0f1a6c8d4cf39ed9b7466c7eb10c8). If you want to freedom patch to get rid of ''bundle exec'' see this post: http://www.arailsdemo.com/posts/36. (There''s some other information in the Post #35...) I haven''t seen how these tips affect Cucumber yet, so you''ll have to experiment on your own for now. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Arailsdemo A. wrote in post #976437:> 1) If your running ''rake spec'', then don''t, unless you need to do ''rake > db:test:prepare'' also.But don''t you always need to do that? Isn''t that the task that clears out the test DB? Or is that not an issue since you''re (hopefully) running your specs transactionally? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> But don''t you always need to do that? Isn''t that the task that clears > out the test DB? Or is that not an issue since you''re (hopefully) > running your specs transactionally?As far as I can tell, the difference between ''rake spec'' and ''rspec spec'' is ''db:test:prepare''. When all tests pass with ''rake spec'', they''re also passing with ''rspec spec'', only faster. If you check the test database after running ''rspec spec'', it should be empty. So that''s why I think ''rake spec'' isn''t necessary, unless the database schema has changed. I do have config.use_transactional_fixtures = true in my spec_helper file. If the setting is set to false, then the database could have residual data in it after running the tests. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks guys, got autotest running now with the hack, working like a charm - now I remember that sometimes I do actually enjoy coding! :) Now to get it working properly with Cucumber and Factory Girl ("uninitialized constant Factory") ... On Jan 21, 7:12 pm, "Arailsdemo A." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > But don''t you always need to do that? Isn''t that the task that clears > > out the test DB? Or is that not an issue since you''re (hopefully) > > running your specs transactionally? > > As far as I can tell, the difference between ''rake spec'' and ''rspec > spec'' is ''db:test:prepare''. When all tests pass with ''rake spec'', > they''re also passing with ''rspec spec'', only faster. If you check the > test database after running ''rspec spec'', it should be empty. So that''s > why I think ''rake spec'' isn''t necessary, unless the database schema has > changed. > > I do have > > config.use_transactional_fixtures = true > > in my spec_helper file. If the setting is set to false, then the > database could have residual data in it after running the tests. > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
adam wrote in post #976772:> Now to get it working properly with Cucumber and Factory Girl > ("uninitialized constant Factory") ...That could be a confusion between version 1.3 and 2. Compare this: https://github.com/thoughtbot/factory_girl#readme https://github.com/thoughtbot/factory_girl/tree/1.3.x#readme You could be looking at the 1.3 documentation (telling you to use the Factory class), but installed version 2.0 (that has the FactoryGirl class). HTH, Peter -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thank you, but I still get the same error - "uninitialized constant FactoryGirl (NameError)" I have also posted on the FactoryGirl list: https://groups.google.com/group/factory_girl/browse_thread/thread/8decccc21a97486?hl=en (see bottom of the thread) Regards Adam On Jan 22, 4:05 pm, Peter Vandenabeele <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> adam wrote in post #976772: > > > Now to get it working properly with Cucumber and Factory Girl > > ("uninitialized constant Factory") ... > > That could be a confusion between version 1.3 and 2. > > Compare this: > > https://github.com/thoughtbot/factory_girl#readmehttps://github.com/thoughtbot/factory_girl/tree/1.3.x#readme > > You could be looking at the 1.3 documentation (telling you to > use the Factory class), but installed version 2.0 > (that has the FactoryGirl class). > > HTH, > > Peter > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Strangely - I am not getting this error when running seperate features, only when running just "cucucmber --drb" On Jan 23, 6:39 am, adam <adam.elemen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thank you, but I still get the same error - "uninitialized constant > FactoryGirl (NameError)" > > I have also posted on the FactoryGirl list:https://groups.google.com/group/factory_girl/browse_thread/thread/8de... > (see bottom of the thread) > > Regards > Adam > > On Jan 22, 4:05 pm, Peter Vandenabeele <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > > > adam wrote in post #976772: > > > > Now to get it working properly with Cucumber and Factory Girl > > > ("uninitialized constant Factory") ... > > > That could be a confusion between version 1.3 and 2. > > > Compare this: > > >https://github.com/thoughtbot/factory_girl#readmehttps://github.com/t... > > > You could be looking at the 1.3 documentation (telling you to > > use the Factory class), but installed version 2.0 > > (that has the FactoryGirl class). > > > HTH, > > > Peter > > > -- > > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try adding this to your spec_helper.rb Spork.each_run do require ''factory_girl_rails'' end adam wrote in post #976883:> Strangely - I am not getting this error when running seperate > features, only when running just "cucucmber --drb"-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thank you - however that code it already in place.. On Jan 23, 5:29 pm, "Arailsdemo A." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Try adding this to your spec_helper.rb > > Spork.each_run do > require ''factory_girl_rails'' > end > > adam wrote in post #976883: > > > Strangely - I am not getting this error when running seperate > > features, only when running just "cucucmber --drb" > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.