Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8049317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:45:27+00:00 2026-06-05T06:45:27+00:00

I am trying to test a Rails app using Michael Hartl’s tutorial, but I

  • 0

I am trying to test a Rails app using Michael Hartl’s tutorial, but I am getting following error after typing bundle exec rspec spec/requests/static_pages_spec.rb (I am in the sample app directory)

static_pages_spec.rb:9: syntax error, unexpected ‘,’, expecting ‘)’ (SyntaxError)
…age.should have_selector (‘h1’, :text => ‘Sample App’)

… ^

/Users/subalcharla/subal_rails/sample_app/spec/requests/static_pages_spec.rb:9: syntax error, unexpected ‘)’, expecting keyword_end
…r (‘h1’, :text => ‘Sample App’)

/Users/subalcharla/subal_rails/sample_app/spec/requests/static_pages_spec.rb:14: syntax error, unexpected ‘,’, expecting ‘)’
page.should have_selector (‘title’,

                                                       ^

/Users/subalcharla/subal_rails/sample_app/spec/requests/static_pages_spec.rb:15: syntax error, unexpected ‘)’, expecting keyword_end
…ls Tutorial Sample App | Home”)

/Users/subalcharla/subal_rails/sample_app/spec/requests/static_pages_spec.rb:49: syntax error, unexpected ‘)’, expecting keyword_end

from /Users/subalcharla/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'

from /Users/subalcharla/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `map'

from /Users/subalcharla/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `load_spec_files’

from /Users/subalcharla/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/rspec-core-2.10.1/lib/rspec/core/command_line.rb:22:in `run’

from /Users/subalcharla/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:69:in `run’

from /Users/subalcharla/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:10:in `block in autorun’

My static_pages_spec.rb file is

require ‘spec_helper’

describe “Static pages” do

describe "Home page" do

    it "should have the content 'Sample App'" do  
                    visit '/static_pages/home'
                    page.should have_selector ('h1', :text => 'Sample App') 
    end 

    it "should have the right title" do
                    visit '/static_pages/home'
                    page.should have_selector ('title', 
                  :text => "Ruby on Rails Tutorial Sample App | Home")   
    end

end


describe "Help page" do

    it "should have the content 'Help'" do
      visit '/static_pages/help'
      page.should have_selector('h1', :text => 'Help')
    end

    it "should have the right title" do
      visit '/static_pages/help' 
      page.should have_selector ('title',
        :text => "Ruby on Rails Tutorial Sample App | Help")

    end

end


describe "About page" do

  it "should have the content 'About Us'" do
        visit '/static_pages/about'
        page.should have_selector ('h1', :text => 'About Us')

      end 

  it "should have the right title" do
        visit '/static_pages/about'
        page.should have_selector ('title',
        :text => "Ruby on Rails Tutorial Sample App | About Us")
      end


end

end

I have checked my test file with the tutorial screencast and it looks identical. What could be causing the RED failing test to work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:45:28+00:00Added an answer on June 5, 2026 at 6:45 am

    Don’t leave spaces between a function and its opening parens, i.e.

    page.should have_selector ('h1', :text => 'Sample App')
    

    should be

    page.should have_selector('h1', :text => 'Sample App') 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run a single unit test in my Rails app, I'm using
Trying to test deploy a simple Rails 3.1 app in production mode, using the
I'm trying to test my Rails App with test fixtures using Watir. The watir
I'm running through Michael Hartl's Rails Tutorial . I'm trying to verify the title
I'm new to rails and cucumber and I'm trying to test the following scenario
just trying to test for equality in this piece of code, but getting a
Im trying to test my successfully creates a new user after login (using authlogic).
Trying to do something very basic and test my Rails app on my phone.
I am trying to run my tests in my first Rails app using the
I'm trying to start a Rails app from Maven exec plugin. I'm using ./script/rails

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.