expected css "title" with text "Ruby on Rails Tutorial Sample App | Sign Up" to return something

capybara, railstutorial.org, rspec, ruby, ruby-on-rails

Solution

Your test is expecting "Sign up", you're passing "Sign Up". Note the difference in capitalization on the word "up".

Problem

I am working through the Ruby on Rails Tutorial by Michael Hartl and I keep getting a failing test that I cannot figure out. Here is the failure I am getting: User pages signup page: ``` 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)>' ``` Here is my test file: ``` 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 ``` Here is my new.html.erb file: ``` <% provide(:title, 'Sign up') %> <h1>Sign up</h1> <p>Find me in app/views/users/new.html.erb</p> ``` application_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> ``` I am not sure what I am doing wrong. Let me know if I should provide more information. Thanks.

Original source