public
Last active

rspec undefined method get

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
 
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'

Yes, the problem was that I was not defining the it block, e.g.

require 'spec_helper'

describe ArticlesController, :type => :controller do
describe "GET index" do
it "does something"
get :index
response.should be_successful
end
end
end

Diogo Almeida | Gnomeslab
..............................................
e-mail: diogo.almeida@gnomeslab.com
skype: diogo.borges.almeida
twitter: dbalmeida
linkedin: http://pt.linkedin.com/in/dbalmeida
..............................................
Visit our website at http://gnomeslab.com

On Aug 25, 2011, at 4:26 PM, agirorn wrote:

I have the same problem with nested controllers.
Did you ever get this to work?

Reply to this email directly or view it on GitHub:
https://gist.github.com/858192

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

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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.