0

是否可以对以下 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)>'
4

1 回答 1

0

好的,我让它与以下内容一起工作:

describe "should have a link to index page" do
  it { should have_selector('a', title: "<< Back to all jobs", href: jobs_path) }
end
于 2012-11-29T05:09:48.100 回答