Guard を使用してスペックを実行すると、奇妙な問題が発生します。
Capybara の「機能」/「シナリオ」構文を使用する機能仕様を実行しています。私もSpringを使っています。
コンソールまたはrspec spec
Guardシェルで実行すると、すべて正常に動作します。しかし、監視された仕様が Guard によって自動的に実行されると、次のエラーが発生します。spring rspec
rspec
/spec/features/navigation_spec.rb:1:in
<top (required)>': undefined method
feature' for main:Object (NoMethodError)
この特定のコンテキストでのみカピバラの構文を取り上げないのはなぜですか?
関連するコードは次のとおりです。
ガードファイル
guard :rspec, :spring => true do
watch(%r{^spec/.+_spec\.rb$})
end
仕様/機能/navigation_spec.rb
feature "navigation" do
context "When on the home page" do
before { visit "/" }
scenario "I should see the navigation header" do
expect(page).to have_selector("div.navigation")
end
end
end
spec/spec_helper.rb
require 'capybara/rspec'