【发布时间】:2016-02-13 11:57:46
【问题描述】:
当我运行这个 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("mymail@yopmail.com")
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-expectations 的旧
:should语法的should没有 显式启用语法已被弃用。使用新的:expect语法或使用config.expect_with(:rspec) { |c| c.syntax = :should }显式启用: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 会更容易阅读和查找。
-
我不想使用 should,因为它是旧语法,我正在寻找一种 expect(page) 语法。
标签: ruby-on-rails rspec capybara rspec-rails rspec3