【发布时间】:2021-07-27 16:15:41
【问题描述】:
在我的索引页面上,我有这个 div:
<div class="banner">
<h1 class="glow-header">Galaxy Far, Far Away? Quick Trip to Mars?<br>
Pianeta has you covered.</h1>
<div>
在我的测试文件中这是有效的:
RSpec.describe 'home features' do
it 'displays the name of the app and links to the index-all planets page' do
visit root_path
expect(page).to have_content('Space is full of surprises.')
click_link('Go Beyond')
expect(current_path).to eq('/planets')
expect(page).to have_content('Galaxy Far, Far Away?')
end
end
但我希望它与包含的 h1 一起使用。 我这样做了:
expect(page).to have_content('<h1 class="glow-header">Galaxy Far, Far Away? Quick Trip to Mars?<br>
Pianeta has you covered.</h1>')
end
但是测试失败了。我做错了什么?
【问题讨论】:
标签: ruby-on-rails rspec capybara system-testing