sporkrb / spork

A DRb server for testing frameworks (RSpec / Cucumber currently) that forks before each run to ensure a clean testing state.
spork.rubyforge.org
MIT License
1.4k stars 202 forks source link

undefined method `inject' for Gem::Specification:Class (NoMethodError) #182

Open belgoros opened 12 years ago

belgoros commented 12 years ago

I followed the instructions on https://github.com/sporkrb/spork/wiki/WindowsSupport where the link to Windows directions is broken: https://github.com/timcharper/spork/wiki/.

After running

C:\Documents and Settings\path to my ror app\>spork cucumber --bootstrap

I got the above exception:

undefined method `inject' for Gem::Specification:Class (NoMethodError)
C:/Ruby192/lib/ruby/gems/1.9.1/gems/spork-1.0.0rc2-x86-mingw32/lib/spork/gem_helpers.rb:5:in `latest_specs'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/spork-1.0.0rc2-x86-mingw32/lib/spork/gem_helpers.rb:16:in `find_files_using_latest_spec'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/spork-1.0.0rc2-x86-mingw32/lib/spork.rb:101:in `detect_and_require'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/spork-1.0.0rc2-x86-mingw32/lib/spork/test_framework.rb:167:in `<top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/spork-1.0.0rc2-x86-mingw32/lib/spork/runner.rb:49:in `find_test_framework'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/spork-1.0.0rc2-x86-mingw32/lib/spork/runner.rb:57:in `run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/spork-1.0.0rc2-x86-mingw32/lib/spork/runner.rb:10:in `run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/spork-1.0.0rc2-x86-mingw32/bin/spork:10:in `<top (required)>'
C:/Ruby192/bin/spork:19:in `load'
C:/Ruby192/bin/spork:19:in `<main>'

In the Gem file:

group :test do
  gem "factory_girl_rails", ">= 1.6.0"
  gem "cucumber-rails", ">= 1.2.1"
  gem "database_cleaner", ">= 0.7.1"
  gem "launchy", ">= 2.0.5"
  gem "capybara"  
  gem "spork-rails"
end

It happened on Windows XP SP3, Ruby 1.9.2, Spork (1.0.0rc2 x86-mingw32). Any idea ?

d3chapma commented 12 years ago

I get this same problem. Have you managed to work around this yet?

belgoros commented 12 years ago

It seems that spork is not supported by Windows for the moment, that's whay I abandonned it for development on Windows box. The rest is being done on Ubuntu.

d3chapma commented 12 years ago

Hmm...I am getting this on Mac OS 10.6. Anyone have an idea of why this would be on a mac?

d3chapma commented 12 years ago

For me I am running: spork rspec --bootstrap

and I get ``undefined methodinject' for Gem::Specification:Class (NoMethodError) /Users/dc/.rvm/gems/ruby-1.9.2-p180@launch3/gems/spork-1.0.0rc2/lib/spork/gem_helpers.rb:5:in latest_specs' /Users/dc/.rvm/gems/ruby-1.9.2-p180@launch3/gems/spork-1.0.0rc2/lib/spork/gem_helpers.rb:16:infind_files_using_latest_spec' /Users/dc/.rvm/gems/ruby-1.9.2-p180@launch3/gems/spork-1.0.0rc2/lib/spork.rb:101:in detect_and_require' /Users/dc/.rvm/gems/ruby-1.9.2-p180@launch3/gems/spork-1.0.0rc2/lib/spork/test_framework.rb:167:in<top (required)>' /Users/dc/.rvm/gems/ruby-1.9.2-p180@launch3/gems/spork-1.0.0rc2/lib/spork/runner.rb:49:in find_test_framework' /Users/dc/.rvm/gems/ruby-1.9.2-p180@launch3/gems/spork-1.0.0rc2/lib/spork/runner.rb:57:inrun' /Users/dc/.rvm/gems/ruby-1.9.2-p180@launch3/gems/spork-1.0.0rc2/lib/spork/runner.rb:10:in run' /Users/dc/.rvm/gems/ruby-1.9.2-p180@launch3/gems/spork-1.0.0rc2/bin/spork:10:in<top (required)>' /Users/dc/.rvm/gems/ruby-1.9.2-p180@launch3/bin/spork:19:in load' /Users/dc/.rvm/gems/ruby-1.9.2-p180@launch3/bin/spork:19:in

'

d3chapma commented 12 years ago

actually, turns out all I needed was to run bundle exec spork rspec --bootstrap instead

belgoros commented 12 years ago

Oh, yes, I didn't think about that. I recently marked it too that for some things I had to prefix with 'bundle exec' to make them run. Thanks for pointing it out.

moll commented 12 years ago

I'm getting the same error with a Rails project here on OS X. Running without bundle exec always fails. With Guard 0.9.0rc9 it ran fine.

belgoros commented 12 years ago

it is necessary in general to prefix commands such as rake or rspec with bundle exec so that the programs run in the exact gem environment specified by the Gemfile. (For technical reasons, the only exception to this is the rails command itself.). You can eliminate the use of 'bundle exec as described By Michael Hartle here: http://ruby.railstutorial.org/chapters/static-pages#sec:eliminating_bundle_exec