1

私は次のスペックを持っています

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_forからlayouts/application.html.hamlです:

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

ページのタイトルは「プロフィール」として表示されています。

この仕様が失敗している理由はありますか?

Rails 3.2.3

Ruby 1.9.3

4

1 に答える 1

2

これはCapybara2.0のバグ(または機能:)です。以前のバージョンを使用してみてください(1.1.2は私にとっては問題なく動作します)。

https://github.com/jnicklas/capybara/issues/844

has_titleでリクエストをプルしますか?マッチャー:

https://github.com/jnicklas/capybara/issues/844

于 2012-12-26T16:17:38.410 に答える