For a while now, I''ve had the following in config/environment.rb : config.gem ''haml'' config.gem ''rspec'', :lib => ''spec'' config.gem ''rspec-rails'', :lib => ''spec/rails'' I just tried running the Rails console in production mode, and this warning occured: irb: warn: can''t alias context from irb_context. After some googling, I learned that the gem deps on rspec and rspec- rails are causing that warning. When I remove those two gem deps from environment.rb , the warning disappears. With that said, I''m wondering what the accepted way to setup gem dependencies on rspec and rspec-rails is. Should one not bother? Should the "config.gem" lines go in config/environments/test.rb ? Thanks, Nick
On 07/02/2009, at 12:30 PM, Nick Hoffman wrote:> For a while now, I''ve had the following in config/environment.rb : > > config.gem ''haml'' > config.gem ''rspec'', :lib => ''spec'' > config.gem ''rspec-rails'', :lib => ''spec/rails'' > > I just tried running the Rails console in production mode, and this > warning occured: > > irb: warn: can''t alias context from irb_context. > > After some googling, I learned that the gem deps on rspec and rspec- > rails are causing that warning. When I remove those two gem deps > from environment.rb , the warning disappears. > > With that said, I''m wondering what the accepted way to setup gem > dependencies on rspec and rspec-rails is. Should one not bother? > Should the "config.gem" lines go in config/environments/test.rb ? > > Thanks, > NickI should''ve tried the second solution I proposed before sending that email. If you put the gem dependencies in config/environments/test.rb and then enter the Rails console in test mode (script/console test), the warning occurs. -Nick
On Sat, Feb 7, 2009 at 12:30 PM, Nick Hoffman <nick at deadorange.com> wrote:> For a while now, I''ve had the following in config/environment.rb : > > config.gem ''haml'' > config.gem ''rspec'', :lib => ''spec'' > config.gem ''rspec-rails'', :lib => ''spec/rails'' > > I just tried running the Rails console in production mode, and this warning > occured: > > irb: warn: can''t alias context from irb_context. > > After some googling, I learned that the gem deps on rspec and rspec-rails > are causing that warning. When I remove those two gem deps from > environment.rb , the warning disappears. > > With that said, I''m wondering what the accepted way to setup gem > dependencies on rspec and rspec-rails is. Should one not bother? Should the > "config.gem" lines go in config/environments/test.rb ?Rails config.gem has never seemed to work 100% with libraries that shouldn''t be loaded in all environments. With that said, I point you to the wiki: http://wiki.github.com/dchelimsky/rspec/rails-with-rspec-gems If you try to use the rake tasks to find gem dependencies for your app, it will not list them by default unless you set RAILS_ENV=test. ie: RAILS_ENV=test rake gems IMO, running "rake gems" should tell you the configured gems for *everything*, and it should say what environments a particular gem is required. It kind of defeats the purpose if I have to be so specific when asking the "rake gems" task what gems the application relies on. I''ve haven''t successfully gotten all of the rake tasks for gems to work 100% in the test environment. For the most part the "gems" and "gems:unpack" do function. You can successfully bypass cofnig.gem and the associated rake tasks by using "gem unpack". ie: cd vendor/gems ; gem unpack rspec ; gem unpack rspec-rails Personally, I put rspec and rspec-rails in vendor/plugins, even if it''s just using "gem unpack" to put them there. It makes easier to upgrade to recent changes in rspec/rspec-rails in order to try out bug fixes, or take advantage of new features. Basically you''ve got options. I''d recommend gem unpacking into vendor/gems or vendor/plugins. I don''t see an advantage at this point of using config.gem since it doesn''t work 100% of the time, and it doesn''t work necessarily as it should (of course IMO), -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com
On Sat, Feb 7, 2009 at 9:30 AM, Nick Hoffman <nick at deadorange.com> wrote:> With that said, I''m wondering what the accepted way to setup gem > dependencies on rspec and rspec-rails is. Should one not bother? Should the > "config.gem" lines go in config/environments/test.rb ?I don''t bother to use config.gem with rspec, but if you do then yes it should go in test.rb Pat
David Chelimsky
2009-Feb-07 19:02 UTC
[rspec-users] [RSpec] Setting a gem dep on rspec-rails
On Sat, Feb 7, 2009 at 12:27 PM, Pat Maddox <pergesu at gmail.com> wrote:> On Sat, Feb 7, 2009 at 9:30 AM, Nick Hoffman <nick at deadorange.com> wrote: >> With that said, I''m wondering what the accepted way to setup gem >> dependencies on rspec and rspec-rails is. Should one not bother? Should the >> "config.gem" lines go in config/environments/test.rb ? > > I don''t bother to use config.gem with rspec, but if you do then yes it > should go in test.rbI don''t either, but I''d like to get it working for ppl who want to do it. If anybody w/ config.gem fu wants to help, that''d be awesome.> > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 7 Feb 2009, at 19:02, David Chelimsky wrote:> On Sat, Feb 7, 2009 at 12:27 PM, Pat Maddox <pergesu at gmail.com> wrote: >> On Sat, Feb 7, 2009 at 9:30 AM, Nick Hoffman <nick at deadorange.com> >> wrote: >>> With that said, I''m wondering what the accepted way to setup gem >>> dependencies on rspec and rspec-rails is. Should one not bother? >>> Should the >>> "config.gem" lines go in config/environments/test.rb ? >> >> I don''t bother to use config.gem with rspec, but if you do then yes >> it >> should go in test.rb > > I don''t either, but I''d like to get it working for ppl who want to > do it. > > If anybody w/ config.gem fu wants to help, that''d be awesome.I think this kinda works for us, but I had a couple of issues. One is the problem with rake files, which will depend on RSpec being visible to rake when it loads (which will ignore your vendor/gems folder). I fixed that by putting the rake file in a huge begin / rescue / end block so when the require ''spec'' fails it doesn''t load the rest of the rake tasks. Ugly but functional. The other issue was to do with a line in spec/rails which clobbers the value of RAILS_ENV to be ''test'' whatever it was previously set to. We use an unconventional ''features'' environment for running features (means I can run cukes at the same time as specs) but this was going hay-wire. I think David has put a patch for this into rspec-rails'' head but I don''t know if it''s made it''s way into a gem yet. So yeah, executive summary: What Pat said. Matt Wynne http://blog.mattwynne.net http://www.songkick.com
On 08/02/2009, at 4:39 PM, Matt Wynne wrote:> On 7 Feb 2009, at 19:02, David Chelimsky wrote: > >> On Sat, Feb 7, 2009 at 12:27 PM, Pat Maddox <pergesu at gmail.com> >> wrote: >>> On Sat, Feb 7, 2009 at 9:30 AM, Nick Hoffman <nick at deadorange.com> >>> wrote: >>>> With that said, I''m wondering what the accepted way to setup gem >>>> dependencies on rspec and rspec-rails is. Should one not bother? >>>> Should the >>>> "config.gem" lines go in config/environments/test.rb ? >>> >>> I don''t bother to use config.gem with rspec, but if you do then >>> yes it >>> should go in test.rb >> >> I don''t either, but I''d like to get it working for ppl who want to >> do it. >> >> If anybody w/ config.gem fu wants to help, that''d be awesome. > > I think this kinda works for us, but I had a couple of issues. One > is the problem with rake files, which will depend on RSpec being > visible to rake when it loads (which will ignore your vendor/gems > folder). I fixed that by putting the rake file in a huge begin / > rescue / end block so when the require ''spec'' fails it doesn''t load > the rest of the rake tasks. Ugly but functional. > > The other issue was to do with a line in spec/rails which clobbers > the value of RAILS_ENV to be ''test'' whatever it was previously set > to. We use an unconventional ''features'' environment for running > features (means I can run cukes at the same time as specs) but this > was going hay-wire. I think David has put a patch for this into > rspec-rails'' head but I don''t know if it''s made it''s way into a gem > yet. > > So yeah, executive summary: What Pat said. > > > Matt WynneI''ve decided to just freeze the rspec and rspec-rails gems into vendor/ gems/ . It makes life easy when moving the app between hosts, and means that I don''t have to worry about config.gem shenanigans. Thanks for all of your suggestions, guys. Much appreciated!