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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:18:53+00:00 2026-05-23T11:18:53+00:00

I am trying to test my Rails 3.0.9 controller with Rspec 2.6.4 and Webrat

  • 0

I am trying to test my Rails 3.0.9 controller with Rspec 2.6.4 and Webrat 0.7.3. My controller looks like this:

#metrics_controller.rb
class MetricsController < ApplicationController
  def show
    @metric = Metric.all(:msrun_id => params[:id]).first
  end

  def index
    @metrics = Metric.all
  end
end

And my controller spec looks like this:

#metrics_controller_spec.rb
require 'spec_helper'

describe MetricsController do
  describe "GET #index" do
    it "should be successful" do
      get :index
      response.should be_success
    end
  end

  describe "GET show" do
    it 'contains an overview of a metric' do
      get :show, :id => 1
      response.should have_selector('title', :content => "Metric Overview")
    end
  end
end

This looks very similar to other examples I have seen in documentation, but when I run bundle exec rspec spec/controllers/metrics_controller_spec.rb I am getting some strange errors:

1) MetricsController GET #index should be successful
Failure/Error: response.should be_success
     TypeError:
       wrong argument type RSpec::Matchers::BePredicate (expected Proc)
     # ./spec/controllers/metrics_controller_spec.rb:8

  2) MetricsController GET show contains an overview of a metric
     Failure/Error: response.should have_selector('title')
     TypeError:
       wrong argument type Webrat::Matchers::HaveSelector (expected Proc)
     # ./spec/controllers/metrics_controller_spec.rb:16

It looks like something weird is going on with the response.should method. If I change the first example to something more verbose that doesn’t call should on response like this:

response.success?.should == true

then the example works fine, but why would should be expecting a Proc? Any ideas about how I can fix this?

  • 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-23T11:18:53+00:00Added an answer on May 23, 2026 at 11:18 am

    This is not an especially helpful answer, but I will put it in here in case someone else gets stuck on the same thing. I inherited the project from someone else, and they set it up to use both railties and rails. Changing the Gemfile to look like this:

    source 'http://rubygems.org'
    
    RAILS_VERSION = '~> 3.0.7'
    DM_VERSION    = '~> 1.1.0'
    gem 'railties', RAILS_VERSION, :require => 'rails'
    gem 'activesupport', RAILS_VERSION
    gem 'actionpack', RAILS_VERSION
    gem 'actionmailer', RAILS_VERSION
    gem 'dm-rails',          DM_VERSION
    gem 'rspec-rails'
    #other gems below
    

    Instead of something like this:

    source 'http://rubygems.org'
    gem 'rails'    
    gem 'dm-rails',          '~> 1.1.0'
    gem 'rspec-rails'
    #other gems below
    

    along with changing the config/application.rb to require the railties instead of rails seemed to fix it. The key seemed to be using railties instead of all of rails along with dm-rails.

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

Sidebar

Related Questions

I'm trying to do this: How do I test a controller with rspec-rails? My
I'm new to rails and I'm trying to test a controller with rspec. My
I'm trying to test my app controller with RSpec on Ruby on Rails. I'm
I keep getting this error when trying to run a Rspec test as part
I'm trying to test a controller and I got this error. I understand the
I'm trying to test an existing rails project with rspec. And I want to
I'm trying to test my Rails 3.2.3 application by RSpec. It's installed (I already
Good day! I'm trying to implement ajax in my rails test app. my controller
I am trying to test a controller with RSpec but am having a problem
I'm newbie on ruby on rails and I'm trying to test my controller with

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.