是否可以对以下html结构进行测试?
<p class="all-jobs"><%= link_to "<< Back to all jobs", jobs_path %></p>
我试过这样做:
it { should have_selector('p.all-jobs', link: "<< Back to all jobs")}
错误是:
1) JobPages visit a job page
Failure/Error: it { should have_selector('p.all-jobs', link: "<< Back to all jobs")}
expected css "p.all-jobs" to return something
# ./spec/requests/job_pages_spec.rb:78:in `block (3 levels) in <top (required)>'
答案 0 :(得分:0)
好的,我得到了以下内容:
describe "should have a link to index page" do
it { should have_selector('a', title: "<< Back to all jobs", href: jobs_path) }
end