20042


Rails3.2からRails4.0最新バージョンに上げたところsporkを起動できなくなりました。  
以下のようなエラーが出ます。

[code]

    [hoge@CS-c014 apll]$ sudo bundle exec spork
    Using RSpec, Rails
    Preloading Rails environment
    Loading Spork.prefork block...
    cannot load such file -- spec_helper (LoadError)
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:229:in `require'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:229:in `block in require'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:214:in `load_dependency'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:229:in `require'
    /poge/hoge/workspace/version/app/hogeapp/spec/support/lib/cached_object_loader_examples.rb:18:in `<top (required)>'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:229:in `require'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:229:in `block in require'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:214:in `load_dependency'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:229:in `require'
    /poge/hoge/workspace/version/app/hogeapp/spec/spec_helper.rb:31:in `block (2 levels) in <top (required)>'
    /poge/hoge/workspace/version/app/hogeapp/spec/spec_helper.rb:31:in `each'
    /poge/hoge/workspace/version/app/hogeapp/spec/spec_helper.rb:31:in `block in <top (required)>'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/spork-1.0.0rc4/lib/spork.rb:24:in `prefork'
    /poge/hoge/workspace/version/app/hogeapp/spec/spec_helper.rb:18:in `<top (required)>'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:223:in `load'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:223:in `block in load'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:214:in `load_dependency'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:223:in `load'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/spork-1.0.0rc4/lib/spork/test_framework.rb:138:in `block (2 levels) in preload'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/spork-rails-4.0.0/lib/spork/app_framework/rails.rb:8:in `preload'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/spork-1.0.0rc4/lib/spork/test_framework.rb:134:in `block in preload'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/spork-1.0.0rc4/lib/spork.rb:62:in `exec_prefork'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/spork-1.0.0rc4/lib/spork/test_framework.rb:120:in `preload'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/spork-1.0.0rc4/lib/spork/run_strategy/forking.rb:25:in `preload'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/spork-1.0.0rc4/lib/spork/runner.rb:75:in `run'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/spork-1.0.0rc4/lib/spork/runner.rb:10:in `run'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/gems/spork-1.0.0rc4/bin/spork:10:in `<top (required)>'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/bin/spork:23:in `load'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0/bin/spork:23:in `<main>'
    No DRb server is running. Running in local process instead ...
    No examples found.
    
    
    Finished in 0.00058 seconds (files took 5.32 seconds to load)
    0 examples, 0 failures
    
[/code]

[こちら](http://qiita.com/yujinakayama/items/a1d31b2caa35642e8e69)を参考にrspecのバージョンも上げていこうと思いrspecのバージョンは2.99にしてます。  
他sporkのバージョンは以下の通りです。  
spork (1.0.0rc4)  
spork-rails (4.0.0)

読み込んでいるspec/spec_helper.rbコードは以下のようになっています。

[code]

     31   Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
     32
     33   RSpec.configure do |config|
     34     # ## Mock Framework
     35     #
     36     # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
     37     #
     38     # config.mock_with :mocha
     39     # config.mock_with :flexmock
     40     # config.mock_with :rr
     41
     42     # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
     43     config.fixture_path = "#{::Rails.root}/spec/fixtures"
     44
     45     # If you're not using ActiveRecord, or you'd prefer not to run each of your
     46     # examples within a transaction, remove the following line or assign false
     47     # instead of true.
     48     config.use_transactional_fixtures = true
    
[/code]

spec/support/**/*.rbのとこにrequre
spec_helperが入ってたのでそれを除くとsporkは起動するようになりました。でもテストを流すと以下エラーになりました。

[code]

    Exception encountered: #<NameError: uninitialized constant RSpec::Core::CommandLine>
    backtrace:
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0rails/gems/spork-1.0.0rc4/lib/spork/test_framework/rspec.rb:11:in `run_tests'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0rails/gems/spork-1.0.0rc4/lib/spork/run_strategy/forking.rb:13:in `block in run'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0rails/gems/spork-1.0.0rc4/lib/spork/forker.rb:21:in `block in initialize'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0rails/gems/spork-1.0.0rc4/lib/spork/forker.rb:18:in `fork'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0rails/gems/spork-1.0.0rc4/lib/spork/forker.rb:18:in `initialize'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0rails/gems/spork-1.0.0rc4/lib/spork/run_strategy/forking.rb:9:in `new'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0rails/gems/spork-1.0.0rc4/lib/spork/run_strategy/forking.rb:9:in `run'
    /poge/hoge/.rbenv/versions/2.2.3/gemsets/4.0rails/gems/spork-1.0.0rc4/lib/spork/server.rb:49:in `run'
    /poge/hoge/.rbenv/versions/2.2.3/lib/ruby/2.2.0/drb/drb.rb:1624:in `perform_without_block'
    /poge/hoge/.rbenv/versions/2.2.3/lib/ruby/2.2.0/drb/drb.rb:1584:in `perform'
    /poge/hoge/.rbenv/versions/2.2.3/lib/ruby/2.2.0/drb/drb.rb:1657:in `block (2 levels) in main_loop'
    /poge/hoge/.rbenv/versions/2.2.3/lib/ruby/2.2.0/drb/drb.rb:1653:in `loop'
    /poge/hoge/.rbenv/versions/2.2.3/lib/ruby/2.2.0/drb/drb.rb:1653:in `block in main_loop'
    
[/code]

調べてみると、[書いてある通りgemを編集](http://qiita.com/etmnk/items/e1aa63b2f7f5615ac834)したら動作するようになりました。やっぱりgemを直接直すのも何なんでsporkではないものを使うべきでしょうか？


CC BY-SA 3.0
2015-11-17T10:22:04.650
18948
2015-12-15T22:04:24.503
2015-12-15T05:17:43.230
10851
10851
question
ruby-on-rails ruby rubygems rspec
Rails4でsporkを起動できない


> やっぱりgemを直接直すのも何なんでsporkではないものを使うべきでしょうか？

Rails 4.1からSpringがデフォルトでインストールされているようになっているので、SporkからSpringに切り替えるのをオススメします。  
僕も現在Sporkは使っていません。

Rails 4.0でもSpringは使用可能です。

Rails + Spring + Guard + RSpecを組み合わせる方法はネットにいろいろと載っていますし、僕が翻訳した「[Everyday
Rails - RSpecによるRailsテスト入門](https://leanpub.com/everydayrailsrspec-
jp)」でも解説しています。


CC BY-SA 3.0
2015-12-15T22:04:24.503
20042
2015-12-15T22:04:24.503
85
18948
answer