[rspec-users] undefined method 'get'

David Chelimsky dchelimsky at gmail.com
Sun Mar 13 10:00:23 EDT 2011


On Mar 7, 2011, at 1:30 AM, DBA wrote:

> Hello guys,
> 
> I was just starting a rails 3.0.5 application with rspec-rails 2.5.0
> and ruby 1.9.2-p180 and when I went to describe my controller I ran
> into this undefined method 'get' error.
> 
> Here's the spec that is causing the problem (which lives in the folder
> spec/controllers)
> 
> require 'spec_helper'
> 
> describe ArticlesController, :type => :controller do
>  describe "GET index" do
>    get :index
>    response.should be_successful
>  end
> end

The `get` method is available in examples (the block passed to `it` or `specify`), but here it's being called in a group (the block passed to `describe` or context`). Try this instead:

describe ArticlesController, :type => :controller do
  describe "GET index" do
    it "returns a 200" do
      get :index
      response.should be_successful
    end
  end
end

HTH,
David


More information about the rspec-users mailing list