spork 0.9.2 and rspec 3.0.0 = uninitialized constant RSpec::Core::CommandLine (NameError)

南楼画角 提交于 2019-11-30 04:44:49

The reason is that RSpec::Core::CommandLine was removed in Rspec3

https://github.com/rspec/rspec-core/blob/master/Changelog.md

Merge RSpec::Core::CommandLine (never formally declared public) into RSpec::Core::Runner. (Myron Marston)

But spork depends on this code.

There is already an issue on spork's github and a solution can be found in a following spork's fork:

https://github.com/codecarson/spork/commit/38c79dcedb246daacbadb9f18d09f50cc837de51#diff-937afaa19ccfee172d722a05112a7c6fL6

In general - replace

::RSpec::Core::CommandLine.new(argv).run(stderr, stdout)

with

::RSpec::Core::Runner.run(argv,stderr, stdout)

in the soprks source code

Like @lx00st said:

The reason is that RSpec::Core::CommandLine was removed in Rspec3

The spork gem hasn't been updated in rubygems.org. However, the fix has been merged into spork's master branch on github. You can grab it by telling bundler that you'd like to get spork from github (master) instead of rubygems.org. So do this:

This has been fixed on spork's master branch. Simple solution:

gem 'spork', github: 'sporkrb/spork', branch: 'master'

If you're using spork-rails, just require spork via github before requiring spork-rails in your gemfile. For more info on this, see my comment here:

https://github.com/sporkrb/spork-rails/issues/26

Edit: added branch: 'master'

efiguerc

Same thing here. Just remove the "--drb" line from .spec file and remove the cli: '--drb' parameter on the guard :rspec... line within the Guardfile. This does not turn off spork. It just turn off the "distributed ruby" (--drb) Rspec option. As guard knows you are running Rspec through Spork, it is not needed.

I started using Spring instead of Spork and that solved it.

It seems to be the new Rails way: http://edgeguides.rubyonrails.org/4_1_release_notes.html#spring-application-preloader

I had this same problem. Sans digging into the rspec3 source code, removing the --drb line from my .rspec file fixed the problem for me. Some Guardfile examples also have use of the --drb which causes issues for me. Once removed all tests work fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!