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 6338663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:29:26+00:00 2026-05-24T19:29:26+00:00

I have some troubles with testing in Rails 3. I’m currently upgrading a Rails2

  • 0

I have some troubles with testing in Rails 3. I’m currently upgrading a Rails2 app to Rails3. I’m using shoulda for testing. In my functional tests, I’m testing with shoulda, that a GET should respond with success

context "GET to :blame" do
  should "mark a song as blamed" do
    get :blame, :id => @song.id
    assert_equal Blame.count, 1
    get :blame, :id => @song.id
    assert_equal Blame.count, 2
  end
  should respond_with :success
end

In the next to last line I’m getting the following error while executing the functional tests with rake test:functionals:

  1) Error:
test: a visitor GET to :blame should respond with 200. (SongsControllerTest):
NoMethodError: undefined method `response_code' for nil:NilClass
    /Users/23tux/.rvm/gems/ruby-1.9.2-p136@rails3/gems/activesupport-3.0.3/lib/active_support/whiny_nil.rb:48:in `method_missing'
    /Users/23tux/.rvm/gems/ruby-1.9.2-p136@rails3/gems/shoulda-2.11.3/lib/shoulda/action_controller/matchers/respond_with_matcher.rb:57:in `response_code'
    /Users/23tux/.rvm/gems/ruby-1.9.2-p136@rails3/gems/shoulda-2.11.3/lib/shoulda/action_controller/matchers/respond_with_matcher.rb:48:in `correct_status_code?'
    /Users/23tux/.rvm/gems/ruby-1.9.2-p136@rails3/gems/shoulda-2.11.3/lib/shoulda/action_controller/matchers/respond_with_matcher.rb:30:in `matches?'
    /Users/23tux/.rvm/gems/ruby-1.9.2-p136@rails3/gems/shoulda-2.11.3/lib/shoulda/assertions.rb:53:in `assert_accepts'
    /Users/23tux/.rvm/gems/ruby-1.9.2-p136@rails3/gems/shoulda-2.11.3/lib/shoulda/context.rb:324:in `block in should'
    /Users/23tux/.rvm/gems/ruby-1.9.2-p136@rails3/gems/shoulda-2.11.3/lib/shoulda/context.rb:382:in `call'
    /Users/23tux/.rvm/gems/ruby-1.9.2-p136@rails3/gems/shoulda-2.11.3/lib/shoulda/context.rb:382:in `block in create_test_from_should_hash'

I’m using Ruby 1.9.2, Rails 3.0.3 and Shoulda 2.11.3.
Hope, someone can help me.

thx,
tux

  • 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-24T19:29:29+00:00Added an answer on May 24, 2026 at 7:29 pm

    The two should blocks are run separately and no request would be made for respond_with hence the error. You would need to make the request in a setup block such as:

    context "GET to :blame" do
      setup do
        get :blame, :id => @song.id
      end
      should "mark a song as blamed" do
        assert_equal Blame.count, 1
      end
      should respond_with :success
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.NET MVC site using Membership Provider. I have trouble testing some
I'm having a bit of trouble doing some unit-testing using moq. If I have
I have some troubles with memory leaks in JavaScript. I'm using the Leak Memory
I have some troubles with positioning my label/password field. With this code they both
I have some troubles while writing logs from log4net to the file. I seem
I have some troubles with receiving data on server side. Here goes the code:
Right now I have some troubles. I'm finding a way to solve one problem.
I'm trying to start my java game but I have some troubles with the
I have just installed Delphi 2010 and got some troubles with idHTTP component. If
I am currently trying to test some code I have in a web application

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.