【发布时间】:2021-08-05 10:03:53
【问题描述】:
最近我的测试开始失败,出现以下异常。
NoMethodError:
undefined method `and' for #<Capybara::RSpecMatchers::Matchers::HaveText:0x00007f97687dbe30>
Did you mean? end
我的测试看起来像
it "starts german but allows to be changed to english" do
within(".e-header") do
# german locale
expect(page).to have_content("Mein Anliegen").and not_have_content("My issue")
end
end
compound expectations 的 Rspec 3.10 文档仍然支持它。我不知道为什么我的测试突然开始失败了。
【问题讨论】:
-
多重预期已经有点臭了——如果你要这样做,我至少会明确,不要使用复合预期。
-
没错,我也不赞成。但如果你有遗留代码。它停止工作你需要让它正常工作。这就是我问这个问题的原因。
标签: ruby-on-rails rspec capybara