预期(页)。为了have_title
Rspec的Ruby on Rails的教程
什么是该页面时,它说了页未定义的局部变量/方法?
下面是我看到的错误。
E:\Users\dheeraj\Desktop\rails_projects\sample_app>rspec spec/ ←[31mF←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
失败:
1) StaticPagesController GET 'home' should have the right title ←[31mFailure/Error:←[0m ←[31mexpect(page).to have_title("Home")←[0m ←[31mNameError←[0m: ←[31m**undefined local variable or method
page' for #<RSpec::Core::Example Group::Nested_1::Nested_1:0x2e70778>←[0m** ←[36m # ./spec/controllers/static_pages_controller_spec.rb:13:in
block (3 l evels) in '←[0mFinished in 0.21701 seconds ←[31m4 examples, 1 failure←[0m
Failed examples:
←[31mrspec ./spec/controllers/static_pages_controller_spec.rb:11←[0m ←[36m# Stat icPagesController GET 'home' should have the right title←[0m
Randomized with seed 63847
请帮助我了解和解决这个问题。
那确实是---------请建议的方法是什么我应该使用为了测试这个地方期望(页),我使用Rails 4?它“应该有正确的标题” end – kamal
你可以在你的请求规格中使用这个例子。您要确保显示正确的标题,这意味着您要测试视图的行为。您的控制器规范中的示例可以被删除,您不应该在那里使用页面。 –