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

  • SEARCH
  • Home
  • 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 6682315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:41:30+00:00 2026-05-26T04:41:30+00:00

I am trying to get my test suite working and am having some issues.

  • 0

I am trying to get my test suite working and am having some issues.

#home_controller_spec.rb
require 'spec_helper'

describe HomeController do
  describe "GET 'index'" do
    it "should be successful" do
      get 'index'
      response.should be_success
    end
    it "should have the right h2" do
      get 'index'
      response.should have_selector('h2', :content => 'Home')
    end
  end
end

The first test works and passes just fine. Any time I try to run

response.should have_selector('[anything]')

it gives this error:

2) HomeController GET 'index' should have the right h2
   Failure/Error: response.should have_selector('h2','Home')
   expected css "Home" to return something
 # ./spec/controllers/home_controller_spec.rb:12:in `block (3 levels) in <top (required)>'

I’m using Rails 3.1 and RSpec 2.6 and have already uninstalled and reinstalled Rspec. The same result happens in all of my controller tests.

Any ideas how to fix this error?

Thanks in advance!

Edit:
Uninstalled all gems. Reinstalled all gems. Re-setup RSpec, Capybara and Guard. Seems to be working now. Thanks for the help. Not sure what was wrong.

  • 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-05-26T04:41:31+00:00Added an answer on May 26, 2026 at 4:41 am

    By default RSpec doesn’t render templates in controller specs. You can either:

    1) Move the test into a view spec

    2) Add render_views to the describe block in the controller spec, which will then render the template.

    Option 1 is preferred IMO. You could also use a request spec to test for content. If you are writing request specs, view specs are usually superfluous.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to get some checkbox with a specific name document.getElementsByName(test); Unfortunatley i cant
I've trying to get some vertical text on a little test webpage after reading
I have a test suite and I am trying to get it to work
Using TeamCity, I'm trying to get a (TestAutomationFX) test that requires an STA thread
I am trying to get a ASP.NET Unit Test running and I keep getting
I'm trying to get Thinking Sphinx to work in test mode in Rails. Basically
Alright, I'm trying to get arguments to work properly with a small test application.
When trying to start my JUnit-Test out of Eclipse, I get a ClassNotFoundException. When
I'm trying to see if there's a way to get a consistent unit test
I am trying to get the whole setup working with Autotest/Growl/Shoulda on my Mac

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.