相关疑难解决方法(0)

如何使用Capybara 2.0测试页面标题?

试图测试该页面包含<title>My Title</title>:

# spec/features/reports_spec.rb
require 'spec_helper'

feature "Archive Management" do
  subject { page }

  describe "Index Page" do
    before(:all) { 10.times { FactoryGirl.create(:randomreport) } }
    after(:all) { Report.delete_all }

    describe "when no search terms present" do
      before { visit reports_path }

      it { should have_selector('title', text: 'My Title') } # <= Fails w/Capybara 2.0
      it { should have_selector('title') }                   # <= passes
      it { should have_text('My Title') }                    # <= passes
      it { should have_selector('h2', text: "Welcome") } …
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails capybara

19
推荐指数
1
解决办法
2万
查看次数

标签 统计

capybara ×1

rspec ×1

ruby-on-rails ×1