ruby on rails - Simple Rspec test failing from Michael Hartl RoR Tuotiral -


i total neophyte , learning ruby on rails tutorial michael hartl. on chapter 3 , rspec test page failing (while exact same test not failing home , pages).

the error getting when running $ bundle exec rspec spec/requests/static_pages_spec.rb is:

failures:  1) static pages page should have content 'about us'←[31mfailure/error:←[0m ←[31mvisit 'static_pages/about'←[0m←[31muri::invalidurierror←[0m:←[31mthe scheme http not accept registry part: www.example.com:80static_pages (or bad hostname?)←[0m←[36m     # ./spec/requests/static_pages_spec.rb:24:in `block (3 levels) in <top (required)>'←[0m finished in 0.0776 seconds←[31m3 examples, 1 failure←[0m  failed examples:  ←[31mrspec ./spec/requests/static_pages_spec.rb:23←[0m ←[36m# static pages page should have content 'about us'←[0m 

when accessing http://localhost:3000/static_pages/about page loads , can see "about us" in big h1 letters.

spec/requests/static_pages_spec.rb:

require 'spec_helper'  describe "static pages"    describe "home page"      "should have content 'sample app'"       visit '/static_pages/home'       expect(page).to have_content('sample app')     end   end    describe "help page"      "should have content 'help'"       visit '/static_pages/help'       expect(page).to have_content('help')     end   end    describe "about page"      "should have content 'about us'"       visit 'static_pages/about'       expect(page).to have_content('about us')     end   end end 

config/routes.rb:

sampleapp::application.routes.draw   "static_pages/home"   "static_pages/help"   "static_pages/about" end 

app/controllers/static_pages_controller.rb:

class staticpagescontroller < applicationcontroller   def home   end    def   end    def   end end 

app/views/about.html.erb:

<h1>about us</h1> <p>   <a href="http://railstutorial.org/">ruby on rails tutorial</a>   project make book , screencasts teach web development   <a href="http://rubyonrails.org/">ruby on rails</a>.   sample application tutorial. </p> 

i notice you're missing initial / in failing test:

visit 'static_pages/about' 

vs

visit '/static_pages/help' 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -