私はMichael HartlのRuby on Railsチュートリアルを勉強しています。私は理解できない失敗テストを続けています。"Ruby on Railsチュートリアルサンプルアプリケーション|サインアップ"のテキストがある
Failure/Error: it { should have_selector('title', text: full_title('Sign Up')) }
expected css "title" with text "Ruby on Rails Tutorial Sample App | Sign Up" to return something
# ./spec/requests/user_pages_spec.rb:11:in `block (3 levels) in <top (required)>'
ここに私のテストファイルされる:
require 'spec_helper'
describe "User pages" do
subject { page }
describe "signup page" do
before { visit signup_path }
it { should have_selector('h1', text: 'Sign up') }
it { should have_selector('title', text: full_title('Sign Up')) }
end
end
ここでは私のnew.html.erbファイルです
ユーザーページは、ページにサインアップ:ここ
は、私が取得しています失敗です:
<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>
<p>Find me in app/views/users/new.html.erb</p>
アプリケーションation_helper.rb:
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title)
base_title = 'Ruby on Rails Tutorial Sample App'
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
end
application.html.erb:
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<%= yield %>
<%= render 'layouts/footer' %>
</div>
</body>
</html>
は私が私が間違っているのかわからないです。より多くの情報を提供する必要があるかどうかを教えてください。
ありがとうございました。
またはその逆ですが、thats ur problem :) – TheIrishGuy
私はapplication_helper.rbを追加しました。それはあなたが話していたことですか?また、Railsチュートリアルのスクリーンキャストでは、Hartlは<%= %> –
ではない<% %>を使用しています。なぜあなたのテストが失敗したのか、それは誤字に気付きました。 Rspecは "サインアップ"を期待しています...あなたの提供方法であなたの渡し "サインアップ" – TheIrishGuy