Tabrez
Tabrez

Reputation: 3466

RSpec issue: have_selector syntax error

I am using Rspec 2.6.1 on Rails 3.1.

I am trying out a simple test from rails tutorial. Here is what I have in a spec/controllers/pages_controller_spec.rb :

  describe "GET 'home'" do
    it "returns http success" do
      get 'home'
      response.should be_success  #test1
      response.should have_selector ("title", :content => "Home") #test2
    end
  end

Everything works if I have only the first #test1 in the file. This means the setup is fine. But the moment I add #test2 I get bunch of errors and rspec is no longer able to run the tests. The root error seems to be a syntax error and shows up as follows:

syntax error, unexpected ')', expecting keyword_end

I looked around and that seems to be the correct syntax. Any Idea what the issue is?

Upvotes: 0

Views: 609

Answers (1)

lucapette
lucapette

Reputation: 20724

Try to change

 response.should have_selector ("title", :content => "Home")

to

 response.should have_selector("title", :content => "Home")

I can't say (because I can't reproduce it right now) this will solve your problem but, for sure, it's not a good idea to have a space there.

Upvotes: 1

Related Questions