水豚have_text通行证时应该失败

问题描述 投票:0回答:1

我有RSpec的和水豚不应该通过写一个测试,但它是:

it 'should have the given text' do
  visit root_path
  expect(page).to have_text("This is not here")
end

然后我在测试查找问题包括如下:

puts page.text

它返回更大量的文字比网页上,并列入那就是:

Extracted source (around line #12):
10 11 12 13
})
visit root_path
expect(page).to have_text("This is not here")

它看起来像什么我把我的测试将拿出当它调用has_text?。为什么它包含所有这段文字,是不是在网页上?

ruby-on-rails testing rspec capybara
1个回答
0
投票

这是因为你在你的应用程序/代码有错误,宝石渲染错误,和周围的代码,在测试模式下启用了返回的页面。要禁用所有这些类型的宝石(better_errors等)时,在测试模式(所以它更接近生产模式)。你可以将它们移动到你的Gemfile发展才集团这样做。您还可以在test.log看到被抛出什么样的错误。

© www.soinside.com 2019 - 2024. All rights reserved.