Hi, I''m using the latest rspec-rails 1.2.2 with rails 2.3.2, and I''m trying to get it to work with spec_server. This is on Mac/Leopard, with the stock ruby, all gems installed in /Library/Ruby/. I have configured: # config/environments/test.rb config.cache_classes = false # spec/spec.opts --drb The tests run nice and fast, so I know they''re running against the spec_server, but when I make a change to my model which should toggle the result of a test, it doesn''t change until I restart the spec:server. I have tried running it with combinations of: rake spec:server:start script/spec_server script/autospec autospec The specs run, but no reloading makes it useless. Any ideas? Thanks, Andrew Vit
Andrew Vit wrote:> Hi, > > I''m using the latest rspec-rails 1.2.2 with rails 2.3.2, and I''m > trying to get it to work with spec_server. This is on Mac/Leopard, > with the stock ruby, all gems installed in /Library/Ruby/. I have > configured: > > # config/environments/test.rb > config.cache_classes = false > > # spec/spec.opts > --drb > >Do you notice reloading occurring in dev mode (with cache-classes = false) with the same class? Are you explicitly using require anywhere? Scott> The tests run nice and fast, so I know they''re running against the > spec_server, but when I make a change to my model which should toggle > the result of a test, it doesn''t change until I restart the > spec:server. I have tried running it with combinations of: > > rake spec:server:start > script/spec_server > > script/autospec > autospec > > The specs run, but no reloading makes it useless. Any ideas? > > Thanks, > Andrew Vit > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
I just tried it with: $ rake RAILS_ENV=development spec:server:start $ RAILS_ENV=development script/autospec And it looks the same. (If I change the model file, the tests re-run but it obviously doesn''t get reloaded: even if I add a syntax error, it still runs.) Not sure where you mean about the explicit require. All my specs files have require spec_helper at the top, which is how they come out of the box... Thanks for your help, Andrew On Mar 29, 12:12?am, Scott Taylor <sc... at railsnewbie.com> wrote:> Andrew Vit wrote: > > Hi, > > > I''m using the latest rspec-rails 1.2.2 with rails 2.3.2, and I''m > > trying to get it to work with spec_server. This is on Mac/Leopard, > > with the stock ruby, all gems installed in /Library/Ruby/. I have > > configured: > > > # config/environments/test.rb > > config.cache_classes = false > > > # spec/spec.opts > > --drb > > Do you notice reloading occurring in dev mode (with cache-classes > false) with the same class? > > Are you explicitly using require anywhere? > > Scott > > > > > > > The tests run nice and fast, so I know they''re running against the > > spec_server, but when I make a change to my model which should toggle > > the result of a test, it doesn''t change until I restart the > > spec:server. I have tried running it with combinations of: > > > rake spec:server:start > > script/spec_server > > > script/autospec > > autospec > > > The specs run, but no reloading makes it useless. Any ideas? > > > Thanks, > > Andrew Vit > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
Andrew Vit wrote:> I just tried it with: > > $ rake RAILS_ENV=development spec:server:start > $ RAILS_ENV=development script/autospec >Actually I meant poking around your app with a browser in dev mode ;) I''m pretty sure that rails will still try to run the test environment, even with RAILS_ENV set to a different value, anyway.> And it looks the same. (If I change the model file, the tests re-run > but it obviously doesn''t get reloaded: even if I add a syntax error, > it still runs.) > > Not sure where you mean about the explicit require. All my specs files > have require spec_helper at the top, which is how they come out of the > box... >I was thinking of any explicit requires which may occur in app/ and lib/. AFAIK, this is more of a rails loading issue than an rspec one. Scott> Thanks for your help, > Andrew > > > > On Mar 29, 12:12 am, Scott Taylor <sc... at railsnewbie.com> wrote: > >> Andrew Vit wrote: >> >>> Hi, >>> >>> I''m using the latest rspec-rails 1.2.2 with rails 2.3.2, and I''m >>> trying to get it to work with spec_server. This is on Mac/Leopard, >>> with the stock ruby, all gems installed in /Library/Ruby/. I have >>> configured: >>> >>> # config/environments/test.rb >>> config.cache_classes = false >>> >>> # spec/spec.opts >>> --drb >>> >> Do you notice reloading occurring in dev mode (with cache-classes >> false) with the same class? >> >> Are you explicitly using require anywhere? >> >> Scott >> >> >> >> >> >> >>> The tests run nice and fast, so I know they''re running against the >>> spec_server, but when I make a change to my model which should toggle >>> the result of a test, it doesn''t change until I restart the >>> spec:server. I have tried running it with combinations of: >>>>>> rake spec:server:start >>> script/spec_server >>> >>> script/autospec >>> autospec >>> >>> The specs run, but no reloading makes it useless. Any ideas? >>> >>> Thanks, >>> Andrew Vit >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-us... at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Mar 29, 1:40?am, Scott Taylor <sc... at railsnewbie.com> wrote:> Actually I meant poking around your app with a browser in dev mode ;)Ok, I get it, I wasn''t sure what you were driving at! ;-) Yes, everything is reloading fine in the browser under development.> I''m pretty sure that rails will still try to run the test environment, > even with RAILS_ENV set to a different value, anyway.The RAILS_ENV is being set conditionally in my script files, except script/autospec where it isn''t defined. ENV["RAILS_ENV"] ||= ''test''> I was thinking of any explicit requires which may occur in app/ and lib/.Nothing out of the ordinary...> AFAIK, this is more of a rails loading issue than an rspec one.I just tried this on a clean new rails app, and the reloading still doesn''t work when running spec_server and autospec with --drb. It works fine when I''m not using spec_server, but then it reloads all of rails each time. Works fine, except when using spec_server. The rspec site says: [http://rspec.info/rails/runners.html]> Note that there are some classes and modules that, by default, won?t get reloaded > by Rails, which means they won?t be reloaded by spec_server. There are a number > of strategies available for coercing Rails to reload files every time in a given > environment. See the Rails documentation for more information.Does that include my app/models? I wouldn''t have thought so... Another post on this mailing list seemed to suggest those don''t need manual reloading and "just work". $ gem list rails rails (2.3.2) $ gem list rspec rspec (1.2.2) rspec-rails (1.2.2) $ rails test_spec_server && cd test_spec_server $ script/plugin install git://github.com/dchelimsky/rspec-rails.git $ script/generate rspec $ script/generate rspec_model car name:string # edit config/environments/test.rb => config.cache_classes = false # edit spec/spec.opts => --drb $ rake spec:server:start $ script/autospec # 1 example, 0 failures # edit app/models/car.rb => add invalid syntax! # 1 example, 0 failures Can anyone confirm/reproduce? (Or else tell me what I''m doing wrong?) Thanks, Andrew Vit
It appears this is a bug, with an apparently simple fix in spec_server.rb (rails 2.3 compatibility): https://rspec.lighthouseapp.com/projects/5645/tickets/759 However, now that it''s reloading my app, it''s not reloading the setup from my fixture/factory gems and throwing up a bunch of errors on re- run. (I''ve tried it with both factory_girl and machinist now.) These are required in my spec_helper.rb: config.gem ''notahat-machinist'', :lib => ''machinist'', :source => ''http://gems.github.com'' require File.dirname(__FILE__) + ''/blueprints'' or: config.gem ''thoughtbot-factory_girl'', :lib => ''factory_girl'', :source => ''http://gems.github.com'' # automatically loaded from spec/factories/*.rb Not sure where to look for a solution. On Mar 29, 3:15?am, Andrew Vit <and... at avit.ca> wrote:> On Mar 29, 1:40?am, Scott Taylor <sc... at railsnewbie.com> wrote: > > > Actually I meant poking around your app with a browser in dev mode ;) > > Ok, I get it, I wasn''t sure what you were driving at! ;-) Yes, > everything is reloading fine in the browser under development. > > > I''m pretty sure that rails will still try to run the test environment, > > even with RAILS_ENV set to a different value, anyway. > > The RAILS_ENV is being set conditionally in my script files, except > script/autospec where it isn''t defined. > ENV["RAILS_ENV"] ||= ''test'' > > > I was thinking of any explicit requires which may occur in app/ and lib/. > > Nothing out of the ordinary... > > > AFAIK, this is more of a rails loading issue than an rspec one. > > I just tried this on a clean new rails app, and the reloading still > doesn''t work when running spec_server and autospec with --drb. It > works fine when I''m not using spec_server, but then it reloads all of > rails each time. Works fine, except when using spec_server. > > The rspec site says: > [http://rspec.info/rails/runners.html] > > > Note that there are some classes and modules that, by default, won?t get reloaded > > by Rails, which means they won?t be reloaded by spec_server. There are a number > > of strategies available for coercing Rails to reload files every time in a given > > environment. See the Rails documentation for more information. > > Does that include my app/models? I wouldn''t have thought so... Another > post on this mailing list seemed to suggest those don''t need manual > reloading and "just work". > > $ gem list rails > rails (2.3.2) > $ gem list rspec > rspec (1.2.2) > rspec-rails (1.2.2) > $ rails test_spec_server && cd test_spec_server > $ script/plugin install git://github.com/dchelimsky/rspec-rails.git > $ script/generate rspec > $ script/generate rspec_model car name:string > # edit config/environments/test.rb => config.cache_classes = false > # edit spec/spec.opts => --drb > $ rake spec:server:start > $ script/autospec > # 1 example, 0 failures > # edit app/models/car.rb => add invalid syntax! > # 1 example, 0 failures > > Can anyone confirm/reproduce? (Or else tell me what I''m doing wrong?) > > Thanks, > Andrew Vit > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
Thibaud Guillaume-Gentil
2009-May-01 08:14 UTC
[rspec-users] spec_server not reloading model classes
On Mar 30, 1:14?am, Andrew Vit <and... at avit.ca> wrote:> It appears this is a bug, with an apparently simple fix in > spec_server.rb (rails 2.3 compatibility): > > https://rspec.lighthouseapp.com/projects/5645/tickets/759 > > However, now that it''s reloading my app, it''s not reloading the setup > from my fixture/factory gems and throwing up a bunch of errors on re- > run. (I''ve tried it with bothfactory_girland machinist now.) These > are required in my spec_helper.rb: > > config.gem ''notahat-machinist'', :lib => ''machinist'', :source => > ''http://gems.github.com'' > require File.dirname(__FILE__) + ''/blueprints'' > > or: > > config.gem ''thoughtbot-factory_girl'', :lib => ''factory_girl'', :source > => ''http://gems.github.com'' > # automatically loaded from spec/factories/*.rb > > Not sure where to look for a solution.Same problem for me with factory_girl and rspec_rails 1.2.6, work fine the first time but get a bunch of errors the second. Any solution? Thanks
David Chelimsky
2009-May-01 14:04 UTC
[rspec-users] spec_server not reloading model classes
On Sun, Mar 29, 2009 at 6:14 PM, Andrew Vit <andrew at avit.ca> wrote:> It appears this is a bug, with an apparently simple fix in > spec_server.rb (rails 2.3 compatibility): > > https://rspec.lighthouseapp.com/projects/5645/tickets/759 > > However, now that it''s reloading my app, it''s not reloading the setup > from my fixture/factory gems and throwing up a bunch of errors on re- > run. (I''ve tried it with both factory_girl and machinist now.) These > are required in my spec_helper.rb: > > config.gem ''notahat-machinist'', :lib => ''machinist'', :source => > ''http://gems.github.com'' > require File.dirname(__FILE__) + ''/blueprints'' > > or: > > config.gem ''thoughtbot-factory_girl'', :lib => ''factory_girl'', :source > => ''http://gems.github.com'' > # automatically loaded from spec/factories/*.rbIn spec_helper?> > Not sure where to look for a solution. > > > On Mar 29, 3:15?am, Andrew Vit <and... at avit.ca> wrote: >> On Mar 29, 1:40?am, Scott Taylor <sc... at railsnewbie.com> wrote: >> >> > Actually I meant poking around your app with a browser in dev mode ;) >> >> Ok, I get it, I wasn''t sure what you were driving at! ;-) Yes, >> everything is reloading fine in the browser under development. >> >> > I''m pretty sure that rails will still try to run the test environment, >> > even with RAILS_ENV set to a different value, anyway. >> >> The RAILS_ENV is being set conditionally in my script files, except >> script/autospec where it isn''t defined. >> ENV["RAILS_ENV"] ||= ''test'' >> >> > I was thinking of any explicit requires which may occur in app/ and lib/. >> >> Nothing out of the ordinary... >> >> > AFAIK, this is more of a rails loading issue than an rspec one. >> >> I just tried this on a clean new rails app, and the reloading still >> doesn''t work when running spec_server and autospec with --drb. It >> works fine when I''m not using spec_server, but then it reloads all of >> rails each time. Works fine, except when using spec_server. >> >> The rspec site says: >> [http://rspec.info/rails/runners.html] >> >> > Note that there are some classes and modules that, by default, won?t get reloaded >> > by Rails, which means they won?t be reloaded by spec_server. There are a number >> > of strategies available for coercing Rails to reload files every time in a given >> > environment. See the Rails documentation for more information. >> >> Does that include my app/models? I wouldn''t have thought so... Another >> post on this mailing list seemed to suggest those don''t need manual >> reloading and "just work". >> >> $ gem list rails >> rails (2.3.2) >> $ gem list rspec >> rspec (1.2.2) >> rspec-rails (1.2.2) >> $ rails test_spec_server && cd test_spec_server >> $ script/plugin install git://github.com/dchelimsky/rspec-rails.git >> $ script/generate rspec >> $ script/generate rspec_model car name:string >> # edit config/environments/test.rb => config.cache_classes = false >> # edit spec/spec.opts => --drb >> $ rake spec:server:start >> $ script/autospec >> # 1 example, 0 failures >> # edit app/models/car.rb => add invalid syntax! >> # 1 example, 0 failures >> >> Can anyone confirm/reproduce? (Or else tell me what I''m doing wrong?) >> >> Thanks, >> Andrew Vit >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Andrew Vit
2009-May-01 17:16 UTC
[rspec-users] spec_server errors when reloading fixture replacement plugins (was: spec_server not reloading model classes)
On May 1, 2009, at 7:04 AM, David Chelimsky wrote:> On Sun, Mar 29, 2009 at 6:14 PM, Andrew Vit <andrew at avit.ca> wrote: >> It appears this is a bug, with an apparently simple fix in >> spec_server.rb (rails 2.3 compatibility): >> >> https://rspec.lighthouseapp.com/projects/5645/tickets/759 >> >> However, now that it''s reloading my app, it''s not reloading the setup >> from my fixture/factory gems and throwing up a bunch of errors on re- >> run. (I''ve tried it with both factory_girl and machinist now.) These >> are required in my spec_helper.rb: >> >> config.gem ''notahat-machinist'', :lib => ''machinist'', :source => >> ''http://gems.github.com'' >> require File.dirname(__FILE__) + ''/blueprints'' >> >> or: >> >> config.gem ''thoughtbot-factory_girl'', :lib => ''factory_girl'', :source >> => ''http://gems.github.com'' >> # automatically loaded from spec/factories/*.rb > > In spec_helper?Hi David, Sorry, that wasn''t clear the way I wrote it. The config.gem directive was actually in the rails/environments/test.rb file. Then I required the blueprints.rb file in spec_helper (or in factory_girl''s case it automatically loads the factory files from spec/factories). These steps showed that rails model reloading wasn''t working in 1.2.2 with rails 2.3.2:>>> $ gem list rails >>> rails (2.3.2) >>> $ gem list rspec >>> rspec (1.2.2) >>> rspec-rails (1.2.2) >>> $ rails test_spec_server && cd test_spec_server >>> $ script/plugin install git://github.com/dchelimsky/rspec-rails.git >>> $ script/generate rspec >>> $ script/generate rspec_model car name:string >>> # edit config/environments/test.rb => config.cache_classes = false >>> # edit spec/spec.opts => --drb >>> $ rake spec:server:start >>> $ script/autospec >>> # 1 example, 0 failures >>> # edit app/models/car.rb => add invalid syntax! >>> # 1 example, 0 failuresI had given up on spec_server for the time being. The ticket is resolved now, and I just gave these steps another try with a new app using updated versions. Reloading the app classes for each run works fine out of the box now: I can get it to return a success or failure when I change the model on the fly. However, the problem comes when adding Factory Girl: # config/environments/test.rb # add: config.gem "thoughtbot-factory_girl", :lib => ''factory_girl'' # spec/factories/car.rb Factory.define :car do |f| f.name "Jetta" end # spec/models/car_spec.rb it "should create a new instance given valid attributes" do car = Factory :car car.name.should == ''Jetta'' end It runs fine the first time against drb, but on all subsequent runs I get the following error until I restart spec_server. None of the lines in the stacktrace say "rspec" but I was also getting the same error with Machinist too, so it''s not unique to Factory Girl, and I''m guessing something to do with the reloading. TypeError in ''Car should create a new instance given valid attributes'' can''t dup NilClass /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2189:in `dup'' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2189:in `scoped_methods'' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2193:in `current_scoped_methods'' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2176:in `scoped?'' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2440:in `send'' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/ base.rb:2440:in `initialize'' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/proxy/build.rb:5:in `new'' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/proxy/build.rb:5:in `initialize'' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/factory.rb:284:in `new'' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/factory.rb:284:in `run'' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/factory.rb:237:in `create'' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/factory.rb:268:in `send'' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl/factory.rb:268:in `default_strategy'' /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/ factory_girl.rb:20:in `Factory'' ./spec/models/car_spec.rb:11: /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/ dependencies.rb:156:in `require'' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/ dependencies.rb:521:in `new_constants_in'' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/ dependencies.rb:156:in `require'' Andrew Vit
Ben Johnson
2009-May-22 22:55 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Did anyone ever figure out the factory_girl / machinist issues? I am having the same problems and can figure out how to fix it for the life of me. The first run works fine, then afterwards I get a bunch of these errors: No blueprint for class Venue Any ideas? Thanks! -- Posted via http://www.ruby-forum.com/.
Scott Taylor
2009-May-22 23:41 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Ben Johnson wrote:> Did anyone ever figure out the factory_girl / machinist issues? I am > having the same problems and can figure out how to fix it for the life > of me. The first run works fine, then afterwards I get a bunch of these > errors: > > No blueprint for class Venue > > Any ideas? Thanks! >I don''t know about Machinist or Factory Girl. Basically, here''s the deal: If those libraries use require instead of load, you are screwed. Same goes for autoload''ing. If those libraries internally use load, or load_dependency, and you have cache_classes = false in your dev env, you could try manually reloading it. Here''s FixtureReplacement in script/console (@ version 2.1) after reload! is called: http://gist.github.com/116422
Scott Taylor
2009-May-22 23:53 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Ben Johnson wrote:> Did anyone ever figure out the factory_girl / machinist issues? I am > having the same problems and can figure out how to fix it for the life > of me. The first run works fine, then afterwards I get a bunch of these > errors: > > No blueprint for class Venue > > Any ideas? Thanks! >Actually, I decided to make a tiny release. See this commit: http://github.com/smtlaissezfaire/fixturereplacement/commit/6aba70c51f0701820b46dc687e965b43e21eca41 Scott
Ben Mabey
2009-May-24 05:16 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Scott Taylor wrote:> Ben Johnson wrote: >> Did anyone ever figure out the factory_girl / machinist issues? I am >> having the same problems and can figure out how to fix it for the >> life of me. The first run works fine, then afterwards I get a bunch >> of these errors: >> >> No blueprint for class Venue >> >> Any ideas? Thanks! >> > I don''t know about Machinist or Factory Girl. Basically, here''s the > deal: > > If those libraries use require instead of load, you are screwed. Same > goes for autoload''ing.Yep. You might want to check out Spork[1]. It is a drop-in replacement for spec_server that uses Kernel.fork instead of reloading classes to ensure a clean app state. My coworker, Tim Harper, wrote it and it has been working great for us so far. (There is a little setup, so not quite drop-in but it just works with the --drb flag for rspec.) 1. http://github.com/timcharper/spork/tree/master -Ben> > If those libraries internally use load, or load_dependency, and you > have cache_classes = false in your dev env, you could try manually > reloading it. > Here''s FixtureReplacement in script/console (@ version 2.1) after > reload! is called: > > http://gist.github.com/116422 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Scott Taylor
2009-May-24 09:30 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Ben Mabey wrote:> Scott Taylor wrote: >> Ben Johnson wrote: >>> Did anyone ever figure out the factory_girl / machinist issues? I am >>> having the same problems and can figure out how to fix it for the >>> life of me. The first run works fine, then afterwards I get a bunch >>> of these errors: >>> >>> No blueprint for class Venue >>> >>> Any ideas? Thanks! >>> >> I don''t know about Machinist or Factory Girl. Basically, here''s the >> deal: >> >> If those libraries use require instead of load, you are screwed. >> Same goes for autoload''ing. > Yep. You might want to check out Spork[1]. It is a drop-in > replacement for spec_server that uses Kernel.fork instead of reloading > classes to ensure a clean app state. My coworker, Tim Harper, wrote > it and it has been working great for us so far. (There is a little > setup, so not quite drop-in but it just works with the --drb flag for > rspec.) > > 1. http://github.com/timcharper/spork/tree/master > > -BenThat''s absolutely awesome. Have there been any attempts to generalize this, so that mongrel will fork on each request (a la shotgun)? (I''m still stuck on rails 2.0.2, so a non-rack based reloading scheme would be great). Scott> > >> >> If those libraries internally use load, or load_dependency, and you >> have cache_classes = false in your dev env, you could try manually >> reloading it. >> Here''s FixtureReplacement in script/console (@ version 2.1) after >> reload! is called: >> >> http://gist.github.com/116422 >> _______________________________________________ >> 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
Ben Mabey
2009-May-25 05:17 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Scott Taylor wrote:> Ben Mabey wrote: >> Scott Taylor wrote: >>> Ben Johnson wrote: >>>> Did anyone ever figure out the factory_girl / machinist issues? I >>>> am having the same problems and can figure out how to fix it for >>>> the life of me. The first run works fine, then afterwards I get a >>>> bunch of these errors: >>>> >>>> No blueprint for class Venue >>>> >>>> Any ideas? Thanks! >>>> >>> I don''t know about Machinist or Factory Girl. Basically, here''s the >>> deal: >>> >>> If those libraries use require instead of load, you are screwed. >>> Same goes for autoload''ing. >> Yep. You might want to check out Spork[1]. It is a drop-in >> replacement for spec_server that uses Kernel.fork instead of >> reloading classes to ensure a clean app state. My coworker, Tim >> Harper, wrote it and it has been working great for us so far. >> (There is a little setup, so not quite drop-in but it just works with >> the --drb flag for rspec.) >> >> 1. http://github.com/timcharper/spork/tree/master >> >> -Ben > > That''s absolutely awesome. > Have there been any attempts to generalize this, so that mongrel will > fork on each request (a la shotgun)? (I''m still stuck on rails 2.0.2, > so a non-rack based reloading scheme would be great).Well, so Spork was really created with testing in mind. It is more general purpose than spec_server though. You can use it with any Ruby project, not just Rails. You can also potentially use it with any other testing framework that adds support for it (I''ve been meaning to do this for Cucumber). I know that Tim''s original work with Kernel.fork was actually dealing with Mongrel but I''m not sure what the exact details of it are. I''ll try to find out for you though. -Ben
Ben Johnson
2009-May-26 17:32 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Mark Wilden wrote:> On Sun, May 24, 2009 at 10:17 PM, Ben Mabey <ben at benmabey.com> wrote:> Spork seems to have the same problem that I have with spec_server: it > doesn''t reload classes I change. So if I''m doing TDD between a model and > its > spec, it doesn''t help. > > ///arkI have the same problem. I like spork, but I had to restart the spork server anytime I made a change to a model file. The only way I know how to avoid this is to not proload the rails env, which kind of defeats the purpose. -- Posted via http://www.ruby-forum.com/.
Ben Mabey
2009-May-26 18:31 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Scott Taylor wrote:> > On May 26, 2009, at 1:22 PM, Mark Wilden wrote: > >> On Sun, May 24, 2009 at 10:17 PM, Ben Mabey <ben at benmabey.com >> <mailto:ben at benmabey.com>> wrote: >> >> >> Well, so Spork was really created with testing in mind. It is >> more general purpose than spec_server though. You can use it >> with any Ruby project, not just Rails. You can also potentially >> use it with any other testing framework that adds support for it >> (I''ve been meaning to do this for Cucumber). I know that Tim''s >> original work with Kernel.fork was actually dealing with Mongrel >> but I''m not sure what the exact details of it are. I''ll try to >> find out for you though. >> >> >> Spork seems to have the same problem that I have with spec_server: it >> doesn''t reload classes I change. So if I''m doing TDD between a model >> and its spec, it doesn''t help. > > I noticed the same thing. It must be a bug in spork, correct? > > ScottWhat does your spec_helper look like? It should be something like: require ''rubygems'' require ''spork'' Spork.prefork do ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") # Load other stuff that only needs to be setup once and never reloaded (i.e. rspec and configuring it) end Spork.each_run do ActiveRecord::Base.establish_connection # make sure that the db connection is ready. require File.expand_path(RAILS_ROOT + "/spec/fixjour_builders.rb") # You could use FixtureReplacement, FactorGirl, etc... Spec::Runner.configure do |config| config.include Fixjour include SharedSpecHelpers include DatabaseHelpers include AuthenticatedTestHelper end end Keep in mind that the code in Spork.prefork must not require any of your models inadvertently. If your environment file does this or a plugin does then your models will not be reloaded. Look over your spec_helper file and try to see who is requiring your models initially. We have really only tested this on is our apps where Tim and I work... So, there could very well be bugs we need to iron out. -Ben
Scott Taylor
2009-May-26 18:46 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
On May 26, 2009, at 2:31 PM, Ben Mabey wrote:> Scott Taylor wrote: >> >> On May 26, 2009, at 1:22 PM, Mark Wilden wrote: >> >>> On Sun, May 24, 2009 at 10:17 PM, Ben Mabey <ben at benmabey.com <mailto:ben at benmabey.com >>> >> wrote: >>> >>> >>> Well, so Spork was really created with testing in mind. It is >>> more general purpose than spec_server though. You can use it >>> with any Ruby project, not just Rails. You can also potentially >>> use it with any other testing framework that adds support for it >>> (I''ve been meaning to do this for Cucumber). I know that Tim''s >>> original work with Kernel.fork was actually dealing with Mongrel >>> but I''m not sure what the exact details of it are. I''ll try to >>> find out for you though. >>> >>> >>> Spork seems to have the same problem that I have with spec_server: >>> it doesn''t reload classes I change. So if I''m doing TDD between a >>> model and its spec, it doesn''t help. >> >> I noticed the same thing. It must be a bug in spork, correct? >> >> Scott > > What does your spec_helper look like? > > It should be something like: > > require ''rubygems'' > require ''spork'' > > Spork.prefork do > ENV["RAILS_ENV"] = "test" > require File.expand_path(File.dirname(__FILE__) + "/../config/ > environment") > # Load other stuff that only needs to be setup once and never > reloaded (i.e. rspec and configuring it) > end > > Spork.each_run do > ActiveRecord::Base.establish_connection # make sure that the db > connection is ready. > require File.expand_path(RAILS_ROOT + "/spec/fixjour_builders.rb") # > You could use FixtureReplacement, FactorGirl, etc... > Spec::Runner.configure do |config| > config.include Fixjour > include SharedSpecHelpers > include DatabaseHelpers > include AuthenticatedTestHelper > end > end > > > > Keep in mind that the code in Spork.prefork must not require any of > your models inadvertently. If your environment file does this or a > plugin does then your models will not be reloaded. Look over your > spec_helper file and try to see who is requiring your models > initially. We have really only tested this on is our apps where Tim > and I work... So, there could very well be bugs we need to iron out.Sweet! Seems to be working great now. Looks like the README has changed over the weekend - previously, I had been starting the spec server with script/spec_server. Running spork directly seems to work just fine. Thanks a TON! Scott
Ben Mabey
2009-May-26 19:06 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Scott Taylor wrote:> > On May 26, 2009, at 2:31 PM, Ben Mabey wrote: > >> Scott Taylor wrote: >>> >>> On May 26, 2009, at 1:22 PM, Mark Wilden wrote: >>> >>>> On Sun, May 24, 2009 at 10:17 PM, Ben Mabey <ben at benmabey.com >>>> <mailto:ben at benmabey.com>> wrote: >>>> >>>> >>>> Well, so Spork was really created with testing in mind. It is >>>> more general purpose than spec_server though. You can use it >>>> with any Ruby project, not just Rails. You can also potentially >>>> use it with any other testing framework that adds support for it >>>> (I''ve been meaning to do this for Cucumber). I know that Tim''s >>>> original work with Kernel.fork was actually dealing with Mongrel >>>> but I''m not sure what the exact details of it are. I''ll try to >>>> find out for you though. >>>> >>>> >>>> Spork seems to have the same problem that I have with spec_server: >>>> it doesn''t reload classes I change. So if I''m doing TDD between a >>>> model and its spec, it doesn''t help. >>> >>> I noticed the same thing. It must be a bug in spork, correct? >>> >>> Scott >> >> What does your spec_helper look like? >> >> It should be something like: >> >> require ''rubygems'' >> require ''spork'' >> >> Spork.prefork do >> ENV["RAILS_ENV"] = "test" >> require File.expand_path(File.dirname(__FILE__) + >> "/../config/environment") >> # Load other stuff that only needs to be setup once and never >> reloaded (i.e. rspec and configuring it) >> end >> >> Spork.each_run do >> ActiveRecord::Base.establish_connection # make sure that the db >> connection is ready. >> require File.expand_path(RAILS_ROOT + "/spec/fixjour_builders.rb") # >> You could use FixtureReplacement, FactorGirl, etc... >> Spec::Runner.configure do |config| >> config.include Fixjour >> include SharedSpecHelpers >> include DatabaseHelpers >> include AuthenticatedTestHelper >> end >> end >> >> >> >> Keep in mind that the code in Spork.prefork must not require any of >> your models inadvertently. If your environment file does this or a >> plugin does then your models will not be reloaded. Look over your >> spec_helper file and try to see who is requiring your models >> initially. We have really only tested this on is our apps where Tim >> and I work... So, there could very well be bugs we need to iron out. > > Sweet! Seems to be working great now. > > Looks like the README has changed over the weekend - previously, I had > been starting the spec server with script/spec_server. Running spork > directly seems to work just fine. > > Thanks a TON! > > Scott >Ok cool. Seems like the bug may of been poor documentation... please send a pull request if you think it can be improved. :) -Ben
Scott Taylor
2009-May-26 19:10 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
On May 26, 2009, at 3:06 PM, Ben Mabey wrote:> Scott Taylor wrote: >> >> On May 26, 2009, at 2:31 PM, Ben Mabey wrote: >> >>> Scott Taylor wrote: >>>> >>>> On May 26, 2009, at 1:22 PM, Mark Wilden wrote: >>>> >>>>> On Sun, May 24, 2009 at 10:17 PM, Ben Mabey <ben at benmabey.com <mailto:ben at benmabey.com >>>>> >> wrote: >>>>> >>>>> >>>>> Well, so Spork was really created with testing in mind. It is >>>>> more general purpose than spec_server though. You can use it >>>>> with any Ruby project, not just Rails. You can also potentially >>>>> use it with any other testing framework that adds support for it >>>>> (I''ve been meaning to do this for Cucumber). I know that Tim''s >>>>> original work with Kernel.fork was actually dealing with Mongrel >>>>> but I''m not sure what the exact details of it are. I''ll try to >>>>> find out for you though. >>>>> >>>>> >>>>> Spork seems to have the same problem that I have with >>>>> spec_server: it doesn''t reload classes I change. So if I''m doing >>>>> TDD between a model and its spec, it doesn''t help. >>>> >>>> I noticed the same thing. It must be a bug in spork, correct? >>>> >>>> Scott >>> >>> What does your spec_helper look like? >>> >>> It should be something like: >>> >>> require ''rubygems'' >>> require ''spork'' >>> >>> Spork.prefork do >>> ENV["RAILS_ENV"] = "test" >>> require File.expand_path(File.dirname(__FILE__) + "/../config/ >>> environment") >>> # Load other stuff that only needs to be setup once and never >>> reloaded (i.e. rspec and configuring it) >>> end >>> >>> Spork.each_run do >>> ActiveRecord::Base.establish_connection # make sure that the db >>> connection is ready. >>> require File.expand_path(RAILS_ROOT + "/spec/fixjour_builders.rb") >>> # You could use FixtureReplacement, FactorGirl, etc... >>> Spec::Runner.configure do |config| >>> config.include Fixjour >>> include SharedSpecHelpers >>> include DatabaseHelpers >>> include AuthenticatedTestHelper >>> end >>> end >>> >>> >>> >>> Keep in mind that the code in Spork.prefork must not require any >>> of your models inadvertently. If your environment file does this >>> or a plugin does then your models will not be reloaded. Look over >>> your spec_helper file and try to see who is requiring your models >>> initially. We have really only tested this on is our apps where >>> Tim and I work... So, there could very well be bugs we need to >>> iron out. >> >> Sweet! Seems to be working great now. >> >> Looks like the README has changed over the weekend - previously, I >> had been starting the spec server with script/spec_server. Running >> spork directly seems to work just fine. >> >> Thanks a TON! >> >> Scott >> > > > Ok cool. Seems like the bug may of been poor documentation... > please send a pull request if you think it can be improved. :)BTW: https://rspec.lighthouseapp.com/projects/5645-rspec/tickets Scott
Tim Harper
2009-Jun-02 05:58 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Ben J., Have you given up on this? You''re right - that defeats the purpose of Spork. You need to make sure that any code that loads code in your project does not make it in to your Spork.prefork block. If you are specifically loading the models in your environment, that''s your problem. Here''s some possible options to resolve what you''re experiencing: 1) Add spork blocks to your environment.rb to put portions that are loading code you develop on inside of a Spork.each_run block, and the rest of it in a Spork.prefork block. 2) modify your environment.rb file to only load libraries like gems and plug-ins, and set up autoload to load the rest of your classes as you need them. Alternatively, is this is a matter of pre-caching, you could choose not to load those classes preemptively in the test environment. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090601/6b19cac7/attachment.html>
Zach Powell
2009-Jun-11 02:50 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Ben Johnson wrote:> Did anyone ever figure out the factory_girl / machinist issues? I am > having the same problems and can figure out how to fix it for the life > of me. The first run works fine, then afterwards I get a bunch of these > errors: > > No blueprint for class Venue > > Any ideas? Thanks!I found that using load File.expand_path(File.dirname(__FILE__) + "/blueprints.rb") in the spec_helper.rb did the trick. -- Posted via http://www.ruby-forum.com/.
Lenart Rudel
2009-Oct-28 21:54 UTC
[rspec-users] spec_server errors when reloading fixture replacement pl
Some plugins (like Thinking Sphinx) preload all the files in the app/ folder. You can see if this is the case by logging spork''s output to a file and see what requested the app/* files to load. spork -d > spork.log More details can be found here: http://upstream-berlin.com/2009/07/27/kickstart-rspec-with-spork Hope it helps someone! It took me an hour to solve this :) Zach Powell wrote:> Ben Johnson wrote: >> Did anyone ever figure out the factory_girl / machinist issues? I am >> having the same problems and can figure out how to fix it for the life >> of me. The first run works fine, then afterwards I get a bunch of these >> errors: >> >> No blueprint for class Venue >> >> Any ideas? Thanks! > > > I found that using > > load File.expand_path(File.dirname(__FILE__) + "/blueprints.rb") > > in the spec_helper.rb > > did the trick.-- Posted via http://www.ruby-forum.com/.