簡體   English   中英

spork 0.9.2和rspec 3.0.0 =未初始化的常量RSpec :: Core :: CommandLine(NameError)

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

我使用spork 0.9.2和rspec 3.0.0。 當試圖運行測試rspec --drb我有一個例外

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork/test_framework/rspec.rb:11:in run_tests: uninitialized constant RSpec::Core::CommandLine (NameError)

但是當將rspec版本改回2.6時 - 一切都還可以。 有沒有人遇到同樣的問題? 可以解決嗎?

原因是在Rspec3中刪除了RSpec :: Core :: CommandLine

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

將RSpec :: Core :: CommandLine(從未正式聲明為公共)合並到RSpec :: Core :: Runner中。 (邁倫馬斯頓)

但是spork取決於這個代碼。

spork的github上已經存在一個問題,可以在后面的spork的fork中找到解決方案:

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

一般來說 - 更換

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

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

在soprks源代碼中

喜歡@ lx00st說:

原因是在Rspec3中刪除了RSpec :: Core :: CommandLine

spork gem尚未在rubygems.org中更新。 但是,修復程序已合並到spith的github主分支上。 你可以通過告訴bundler你想從github(master)而不是rubygems.org獲取spork來獲取它。 這樣做:

這已在spork的主分支上修復。 簡單方案:

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

如果您正在使用spork-rails,只需要通過github spork,然后再在gemfile中使用spork-rails。 有關這方面的更多信息,請參閱我的評論:

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

編輯:添加branch: 'master'

這里也是一樣的。 只需從.spec文件中刪除“--drb”行,然后刪除cli: '--drb'guard :rspec...行上的cli: '--drb'參數。 這不會關閉spork。 它只是關閉“分布式紅寶石”(--drb)Rspec選項。 因為后衛知道你正在通過Spork運行Rspec,所以不需要它。

我開始使用Spring而不是Spork,這解決了它。

它似乎是新的Rails方式: http//edgeguides.rubyonrails.org/4_1_release_notes.html#spring-application-preloader

我有同樣的問題。 無法深入研究rspec3源代碼,從我的.rspec文件中刪除--drb行為我解決了問題。 一些Guardfile示例也使用了--drb,這會給我帶來問題。 一旦刪除所有測試工作正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM