Zeus と RSpec の多くのユーザーに起こりそうな状況に直面しています。
私が次の仕様を持っているとしましょう:
# spec/views/messages/show.html.erb
require 'spec_helper'
describe "messages/show.html.erb" do
it "displays the text attribute of the message" do
render
rendered.should contain("Hello world!")
end
end
そして、それがテストする次のビュー テンプレート。
# app/views/messages/show.html.erb
Hello world!
私の pwd は rails アプリのルートです。実行するrspec
と、次の応答が返されます。
user@host $ rspec
.
Finished in 0.06264 seconds
1 example, 0 failures
Randomized with seed 9609
すべてが良さそうです。zeus rspec spec
ただし、 (zeus rspec
まったく機能しない) でテストを実行すると、次の出力が得られます。
user@host $ zeus rspec spec
.
Finished in 0.07292 seconds
1 example, 0 failures
Randomized with seed 0
F
Failures:
1) messages/show.html.erb displays the text attribute of the message
Failure/Error: render
NameError:
undefined local variable or method `render' for <RSpec::Core::ExampleGroup::Nested_2:0x936a0fc>
# ./spec/views/show.html.erb_spec.rb:5:in `block (2 levels) in <top (required)>'
# -e:1:in `<main>'
Finished in 0.00041 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/views/show.html.erb_spec.rb:4 # messages/show.html.erb displays the text attribute of the message
SO でこれに似た質問をいくつか見ました。たとえば、次のようなものです。
zeus rspec は必要なファイルのインクルードに失敗しますが、rspec だけでは問題ありません
Zeus + FactoryGirl::Syntax::メソッド。未定義のメソッド「作成」
共通のスレッドは、解決策が、spec_helper.rb から次の行が存在する場合はコメント アウト/削除することを提案することです。
require 'rspec/autorun'
require 'rspec/autotest'
私の問題は、これらの行が spec_helper.rb ファイルやアプリケーションの他の場所に表示されないことです。
掘り下げた後、問題のある行が実際にrspec
はRSpec gemの実行可能スクリプトにあることがわかりました。
現在、RSpec バージョン 2.13.1 を使用しており、ファイルの内容は次のとおりです。
#!/usr/bin/env ruby
begin
require 'rspec/autorun'
rescue LoadError
$stderr.puts <<-EOS
#{'*'*50}
Could not find 'rspec/autorun'
This may happen if you're using rubygems as your package manager, but it is not
being required through some mechanism before executing the rspec command.
You may need to do one of the following in your shell:
# for bash/zsh
export RUBYOPT=rubygems
# for csh, etc.
set RUBYOPT=rubygems
For background, please see http://gist.github.com/54177.
#{'*'*50}
EOS
exit(1)
end
RSpec のドキュメントから、テストを実行するための便利な方法であることがわかります。奇妙なことに、begin/rescue zeus のセクションをコメント アウトすると、同じ動作 (エラーをスローする) が引き続き行われますが、rspec は従来の方法 (コマンドrequire 'rspec/autorun'
を実行するだけ) では機能しなくなります。rspec
このドキュメント ( https://www.relishapp.com/rspec/rspec-core/docs/command-line ) に従って、もう少し冗長な方法で実行できます。
いずれにせよ、これは、zeus が exec スクリプト以外のファイルに依存しているrspec
か、問題が spec_helper.rb の require ステートメント (rspec 2.13.1 では追加されていない) だけに明確に関連していないかのいずれかであることを示唆しています。設定に)。
誰かがこの状況に遭遇したり、この同じ道をたどりましたか??
どのライブラリがどのライブラリに問題を引き起こしているのかまったくわからないため、rspec-rails / rspec-core または zeus リポジトリのいずれかで問題を提起することをためらっています。
どんな助けでも大歓迎です。