2012-12-26 42 views
1

我有以下規格Rspec的不匹配標題

describe "user enters 150 into time" do 
before do 
    fill_in "workout[total_time]", with: "150" 
    click_button "Update Workout" 
end 
    it "should be on profile page" do 
    save_and_open_page 
    page.should have_selector("h1", text: "Profile") 
    page.should have_selector("title", text: "Profile") 
    end 
end 

它有以下消息失敗:

Capybara::ExpectationNotMet: expected to find css "title" with text "Profile" but there were no matches. Also found "", which matched the selector but not all filters. 

的源代碼(從save_and_open_page)包含此head部分:

<head> 
<meta content="width=device-width, initial-scale=1.0" name="viewport"> 
<title>Profile 
</title> 
<meta content="Composer Delete" name="description"> 
<link href="/assets/application.css" media="all" rel="stylesheet" type="text/css"> 
<script src="/assets/application.js" type="text/javascript"></script> 
</head> 

以下是觀點:

- content_for :title do 
    Profile 
%h1 Profile 
%table.table.table-striped 
    %thead 
    %tr 
     %th Name 
    %tbody 
    - current_user.workouts.each do |workout| 
    %tr 
     %td= link_to workout.name, workout 
     %td= link_to "Edit", edit_profile_workout_url(workout) 
     %td= link_to "Remove", profile_workout_url(workout), method: :delete, confirm: "Are you sure?" 
= link_to "Create New Workout", new_profile_workout_url 

而且content_forlayouts/application.html.haml

%title= content_for?(:title) ? yield(:title) : "Composer Delete" 

頁面的標題被顯示爲 「個人資料」。

任何想法爲什麼這個規範失敗?

的Rails 3.2.3

的Ruby 1.9.3

回答