Andrew Dangerfield
2011-Jan-22 23:30 UTC
[rspec-users] uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError)
I am a new to ruby and rails and am trying to refactor some code with rspec and have run into a problem that has stumped me for a few days and I have searched google and ruby/rails forums to no avail so I really hope somebody can help me out with this problem which I think may be caused by a rails config problem. Anyway, I used ''rails new myapp'' to make a new rails project and then I copied the files (just a few files each containing a class) I want to refactor into "myapp/app" and after running the command ''rspec collector_helper_spec.rb'' I get the following error: ************************************************************************** C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/tag_helper.rb:10: uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError) from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'' from C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/javascript_helper.rb:1 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'' from C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/url_helper.rb:1 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'' from C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/asset_tag_helper.rb:3 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'' from ./helper.rb:3 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'' from C:/Users/bob/app/collector_helper_spec.rb:8 from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load'' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files'' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map'' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files'' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run'' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process'' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run'' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun'' from C:/Ruby187/bin/rspec:19 ************************************************************************** Can anyone explain to me why ERB cannot be found? From the information I found about ERB it is part of ActiveSupport and I ran the command "gem install activesupport" and afterwards I see activesupport installed when I issue the command "gem list". If anyone can point me in the right direction either by explaining what I am doing wrong or telling me about some documentation to read or something that would be great. -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2011-Jan-23 13:17 UTC
[rspec-users] uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError)
On Jan 22, 2011, at 5:30 PM, Andrew Dangerfield wrote:> I am a new to ruby and rails and am trying to refactor some code with > rspec and have run into a problem that has stumped me for a few days and > I have searched google and ruby/rails forums to no avail so I really > hope somebody can help me out with this problem which I think may be > caused by a rails config problem. Anyway, I used ''rails new myapp'' to > make a new rails project and then I copied the files (just a few files > each containing a class) I want to refactor into "myapp/app" and after > running the command ''rspec collector_helper_spec.rb'' I get the following > error: > > ************************************************************************** > C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/tag_helper.rb:10: > uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError) > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require'' > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `require'' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/javascript_helper.rb:1 > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require'' > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `require'' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/url_helper.rb:1 > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require'' > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `require'' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/asset_tag_helper.rb:3 > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in > `gem_original_require'' > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in > `require'' > from ./helper.rb:3 > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require'' > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `require'' > from C:/Users/bob/app/collector_helper_spec.rb:8 > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load'' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load_spec_files'' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `map'' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load_spec_files'' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in > `run'' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in > `run_in_process'' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in > `run'' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in > `autorun'' > from C:/Ruby187/bin/rspec:19 > ************************************************************************** > > Can anyone explain to me why ERB cannot be found? From the information > I found about ERB it is part of ActiveSupport and I ran the command "gem > install activesupport" and afterwards I see activesupport installed when > I issue the command "gem list". If anyone can point me in the right > direction either by explaining what I am doing wrong or telling me about > some documentation to read or something that would be great.I see a couple of problems in the backtrace, and it''s hard to know whether resolving them will fix this issue or not. But let''s give it a shot: 1. Make sure you have this in your Gemfile: gem ''rspec-rails'', :group => [:development, :test] 2. Install the bundle bundle install After you do this, ''gem list rspec'' should include rspec, rspec-core, rspec-expectations, rspec-mocks, and rspec-rails. 3. Install rspec rails generate rspec:install 4. Move app/collector_helper_spec.rb to spec/helpers/collector_helper_spec.rb and make sure the following appears at the top: require "spec_helper" Now try running ''rake spec'' and if you still run into the any problems, please post (preferably on http://gist.github.com/ or http://pastie.org/) the backtrace and code in spec/helpers/collector_helper_spec.rb, app/helpers/collector_helper.rb. HTH, David