주변을 수색했는데이 문제는 흔한 것 같지만 아무 것도 작동하지 않았습니다. 여기 간다!사용자 모델을 테스트하는 동안 'visit * _path'가 작동하지 않습니다.
첫째, 저는 Hartl RoR 튜토리얼을 진행하고 있습니다. section 9 (비디오 905) 끝으로 가고 있으며 실패한 사용자 로그인을 테스트하려고합니다. 그것은이 변경되지만,
1) User login failure should not log the user in
Failure/Error: visit login_path
NameError:
undefined local variable or method `login_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_5::Nested_1:0x00000102c79248>
# ./spec/models/user_spec.rb:176:in `block (4 levels) in <top (required)>'
내가있어 오류가 여전히 visit '/login'
로 visit login_path
를 작성하고, 시도 : 여기 user_spec.rb
의 코드입니다 :
describe "failure" do
it "should not log the user in" do
visit login_path
puts response.body
fill_in 'session_email', with: ""
fill_in 'session_password', with: ""
click_button
response.should have_selector('div.login_error', content: "Invalid")
response.should render_template('sessions/new')
end
end
은 여기에 자동 측정 오류의
Failure/Error: visit '/login'
NoMethodError:
undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_5::Nested_1:0x00000102c2d140>
내가 '어비스'가 webrat (그리고 rspec이 아닌)에서 온다는 것을 읽을 때, 이것이 아마도 아마존 문제라고 생각합니다. 또한 puts response.body
이 자동 테스트 실패시 나타나지 않으므로 첫 번째 줄을 지나치지 않고 있음을 알 수 있습니다. 더 혼란 스럽다는 것은 내 앱의 다른 부분에서, 사실상 동일하고 괜찮은 다른 테스트 코드를 가지고 있다는 것이다.
layout_links_spec.rb
:
before(:each) do
@user = Factory(:user)
visit login_path
# puts response.body
fill_in 'session_email', with: @user.email
fill_in 'session_password', with: @user.password
click_button
end
어떤 아이디어가?
user_spec.rb에 include 문이 누락 되었습니까? layout_links_spec.rb에 포함 된 내용을 user_spec.rb와 비교하십시오. – manoj
모두'require 'spec_helper''을 가지고 있습니다. – dax
뭔가 문제가 있다고 생각합니다. 'User' 모델을 테스트하는 [Rails Tutorial ** user_spec.rb **] (https://github.com/railstutorial/sample_app_2nd_ed/blob/master/spec/models/user_spec.rb)를보십시오. '* _path' 테스트는 없습니다. Capybara는'** requests'는'** requests/user_pages_spec.rb ** '(https://github.com/railstutorial/sample_app_2nd_ed/blob/master/spec/requests/user_pages_spec.rb)에'방문 '을 테스트합니다. . –