Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
rspec undefined method get
require 'spec_helper'
describe ArticlesController, :type => :controller do
describe "GET index" do
get :index
response.should be_successful
end
end
# Rails 3.0.5 & Ruby 1.9.2-p180 & rspec-rails 2.5.0
#
# bundle exec rspec spec/controllers/articles_controller_spec.rb
#
# /spec/controllers/articles_controller_spec.rb:5:in `block (2 levels) in <top (required)>': undefined method `get' for #<Class:0x00000105aab738> (NoMethodError)
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:132:in `module_eval'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:132:in `subclass'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:119:in `describe'
# from /controllers/articles_controller_spec.rb:4:in `block in <top (required)>'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:132:in `module_eval'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:132:in `subclass'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:119:in `describe'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/extensions/object.rb:6:in `describe'
# from /spec/controllers/articles_controller_spec.rb:3:in `<top (required)>'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `block in load_spec_files'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `map'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load_spec_files'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:18:in `run'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:55:in `run_in_process'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:46:in `run'
# from /Users/DBA/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:10:in `block in autorun'
@DBA

This comment has been minimized.

Show comment Hide comment
@DBA

DBA Aug 26, 2011

Owner

DBA commented Aug 26, 2011

@alexvbush

This comment has been minimized.

Show comment Hide comment
@alexvbush

alexvbush May 10, 2012

Man, such a small and simple thing and I managed to miss it too :D
Thanks!

Man, such a small and simple thing and I managed to miss it too :D
Thanks!

@njakobsen

This comment has been minimized.

Show comment Hide comment
@njakobsen

njakobsen Mar 4, 2013

Me too.

Me too.

@filippovG

This comment has been minimized.

Show comment Hide comment
@filippovG

filippovG Apr 7, 2013

the "..., :type => :controller do" was a solution for me!

the "..., :type => :controller do" was a solution for me!

@pboling

This comment has been minimized.

Show comment Hide comment
@pboling

pboling Jun 4, 2014

I just had to add :type => :controller after upgrading from rspec-rails 3.0.0.rc1 to 3.0.1 in a Rails 4.1.1 app on Ruby 2.1.2 because get was undefined. Whaat? The file is spec/controllers/home_controller_spec.rb. Adding the explicit :type fixed it.

pboling commented Jun 4, 2014

I just had to add :type => :controller after upgrading from rspec-rails 3.0.0.rc1 to 3.0.1 in a Rails 4.1.1 app on Ruby 2.1.2 because get was undefined. Whaat? The file is spec/controllers/home_controller_spec.rb. Adding the explicit :type fixed it.

@microweb10

This comment has been minimized.

Show comment Hide comment
@microweb10

microweb10 Jun 7, 2014

@pboling that's kink of annoying. There must be a way to not have to add :type => :controller

@pboling that's kink of annoying. There must be a way to not have to add :type => :controller

@matthewrossanderson

This comment has been minimized.

Show comment Hide comment
@matthewrossanderson

matthewrossanderson Jun 30, 2014

Gooood call on the it block

Gooood call on the it block

@wcpaez

This comment has been minimized.

Show comment Hide comment
@wcpaez

wcpaez Nov 6, 2014

OMG, one more here.

wcpaez commented Nov 6, 2014

OMG, one more here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment