Ruby on Rails Tutorial by Michael Hartl Chapter 7.1.3 - Failing Test -
i've spent couple hours trying figure out tiny little piece of puzzle before moving on in tutorial doesn't blow on later. because of that, know issues tests failing these dime dozen, apologize. in "7.1.3 testing user show page (with factories)" section of tutorial (link provided below), cannot signup page tests pass. seems it's trivial, can't find wrong in of seemingly endless files there issue (the controller, routes, test itself, user model, , on). no 1 online seems have had issue either, figure it's got random setting or on rails project.
anyway, here believe relevant code:
the error running user_pages_spec test in sublime:
failures: 1) user pages signup page failure/error: { should have_content('sign up') } expected #has_content?("sign up") return true, got false # ./spec/requests/user_pages_spec.rb:18:in `block (3 levels) in <top (required)>' 2) user pages signup page failure/error: { should have_title(full_title('sign up')) } expected #has_title?("ruby on rails tutorial sample app | sign up") return true, got false # ./spec/requests/user_pages_spec.rb:19:in `block (3 levels) in <top (required)>' finished in 0.16194 seconds 4 examples, 2 failures failed examples: rspec ./spec/requests/user_pages_spec.rb:18 # user pages signup page rspec ./spec/requests/user_pages_spec.rb:19 # user pages signup page randomized seed 46255 [finished in 2.7s exit code 1]
spec/requests/user_pages_spec.rb
require 'spec_helper' describe "user pages" subject { page } describe "profile page" let(:user) { factorygirl.create(:user) } before { visit user_path(user) } { should have_content(user.name) } { should have_title(user.name) } end describe "signup page" before { visit signup_path } { should have_content('sign up') } { should have_title(full_title('sign up')) } end end
app/views/users/new.html.erb
<% provide(:title, 'sign up') %> <h1>sign up</h1> <p>find me in app/views/users/new.html.erb</p>
app/controller/users_controller.rb
class userscontroller < applicationcontroller def show @user = user.find(params[:id]) end def new end end
config/routes.rb
sampleapp::application.routes.draw resources :users root to: 'static_pages#home' match '/signup', to: 'users#new', via: 'get' match '/help', to: 'static_pages#help', via: 'get' match '/about', to: 'static_pages#about', via: 'get' match '/contact', to: 'static_pages#contact', via: 'get' end
let me know if can think of other code may need see. included new.html.erb because i think signup test looking on page, must wrong on that. if let me know i'm doing wrong causing failure, eternally grateful.
if convince me whole test driven development concept isn't complete pain in rear, brownie points on top of that. i've found tutorial pretty enjoyable, time testing section lose motivation continue, when doesn't work. know it's better code in long run, getting started i'm beginning think should ignore @ risk of quitting.
http://ruby.railstutorial.org/book/ruby-on-rails-tutorial?version=4.0#code-name_title_and_heading
did try replace 'sign up' 'sign up' in spec/requests/user_pages_spec.rb ?
Comments
Post a Comment