如何在 Rails 的集成测试中访问 View helper?
How to access View helper in integration test in Rails?
我的 Rails 视图
中有以下代码
<li><span class="list-group-item-bullet"><%= icon('eye') %></span>
生成以下 HTML:
<li><span class="list-group-item-bullet"><i class="fa fa-eye"></i></span>
我想在我的集成测试中验证这个东西,我正在使用以下生成错误的代码
assert_select 'li' do
assert_select 'span.list-group-item-bullet', 'i.fa fa-eye'
end
如何在我的集成测试中验证它?
以下似乎可行:
assert_select 'li' do
assert_select 'span.list-group-item-bullet' do
assert_select 'i.fa.fa-eye'
end
end
或者更简洁地说,
assert_select 'li span.list-group-item-bullet i.fa.fa-eye'
Taglia 是正确的,您需要 'i.fa.fa-eye' b/c 'i.fa fa-eye' 寻找带有 class fa 和后代 fa-eye 标签的 i 标签。
我的 Rails 视图
中有以下代码 <li><span class="list-group-item-bullet"><%= icon('eye') %></span>
生成以下 HTML:
<li><span class="list-group-item-bullet"><i class="fa fa-eye"></i></span>
我想在我的集成测试中验证这个东西,我正在使用以下生成错误的代码
assert_select 'li' do
assert_select 'span.list-group-item-bullet', 'i.fa fa-eye'
end
如何在我的集成测试中验证它?
以下似乎可行:
assert_select 'li' do
assert_select 'span.list-group-item-bullet' do
assert_select 'i.fa.fa-eye'
end
end
或者更简洁地说,
assert_select 'li span.list-group-item-bullet i.fa.fa-eye'
Taglia 是正确的,您需要 'i.fa.fa-eye' b/c 'i.fa fa-eye' 寻找带有 class fa 和后代 fa-eye 标签的 i 标签。