현재 Michael Hartl 's Rails의 책을 읽고 있으며 테스트를 시작하는 3 장입니다. 문제는 첫 번째 테스트가 작동하지 않는다는 것입니다. 검색 및 여러 스레드에서 stackoverflow, Capybara 추가 정보뿐만 아니라, 그의 코드에서 몇 가지 변경 한 있지만 여전히 작동하도록 방문 기능을 얻을 수 없습니다. 관련 파일은 아래에 포함되어 있습니다.Capybara NoMethodError
사양/spec_helper.rb
require 'capybara'
require 'capybara/rspec'
Rspec.configure do |config|
config.include Capybara::DSL
end
Capybara.configure do |config|
config.app = "Sample App"
end
기능/static_pages_spec.rb
require 'spec_helper'
feature "Static pages" do
feature "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
expect(page).to have_content('Sample App')
end
end
end
그리고 루프 저를 던지고 관련 오류 메시지 :
Failure/Error: visit '/static_pages/home'
NoMethodError:
undefined method `call' for "Sample App":String
#./spec/features/static_pages_spec.rb:9:in `block (3 levels) in <top (required)>'
보기 내가 config30을 제거하려고 시도했습니다 spec_helper.rb,하지만 그저 다른 오류가 발생합니다. 추론이 무엇인지
Failure/Error: visit '/static_pages/home'
ArgumentError:
rack-test requires a rack applicaiton, but none was given
#./spec/features/static_pages_spec.rb:9:in `block (3 levels) in <top (required)>'
왜 spec_helper에'config.app = "Sample App"이 있습니까? 그리고''Sample App "대신에'SampleApp'이되어서는 안 될까요? – mus
config.app를 포함하지 않으면 테스트를 실행하지 못하게하는 다른 오류가 발생합니다. – lafferjm
''Sample App "을'SampleApp'로 바꾸려고 했습니까? – mus