当我运行此RSpec示例时,它会通过,但我收到了弃用警告。如何解决有关新expect语法的RSpec弃用警告?
context "should have valid detail for signup" do
it "should give error for invalid confirm password" do
find("#usernamesignup").set("Any_name")
find("#mobile_number").set("1234567890")
find("#emailsignup").set("[email protected]")
find("#passwordsignup").set("12345678")
find("#passwordsignup_confirm").set("")
find(".signin").click
sleep 2
page.should have_content "Confirm Password Does not Match"
end
end
这里是输出:
废弃警告:
从rspec的期许老
:should
语法使用should
无 明确允许的语法已经过时了。使用新的:expect
语法或明确启用:should
而不是config.expect_with(:rspec) { |c| c.syntax = :should }
。从 /home/rails/rails_nimish/Devise_use/spec/features/users_spec.rb:113:in `块调用(4级)'
如何解决此警告?
更新:解决 我刚刚更换
page.should have_content “确认密码不匹配”
有:由于有消息说你
expect(page).to have_content "Confirm Password Does not Match"
这将是更好的在你的问题的身体进入预警的实际文本。使用Google进行阅读和查找会更容易。 –
做它说什么? –
我不想使用应该,因为它是旧的语法,我正在寻找预期(页面)语法。 – indb