5

I am at chapter 3 of Michael Hartl's tutorial and I am stuck at the testing part. Initially it had the problem of an uninitialised constant Rails (NameError) but after adding

require 'rspec/rails'
require 'active_support'
require 'active_support/deprecation'
require 'activerecord-nulldb-adapter'

to the spec_helper.rb file, there is this new problem with uninitalised constant ActiveSupport::Autoload (NameError).

Attached is the error:

C:\Users\HuiHui\MyProject\sampleapp>bundle exec rspec spec/requests/static_pages
_spec.rb
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1.1/lib/action
_view/template.rb:8:in `<class:Template>': uninitialized constant ActiveSupport:
:Autoload (NameError)
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/template.rb:7:in `<module:ActionView>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/template.rb:5:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/template/resolver.rb:4:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/template/resolver.rb:4:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/testing/resolvers.rb:1:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionview-4.1
.1/lib/action_view/testing/resolvers.rb:1:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-rails-3.
0.1/lib/rspec/rails/view_rendering.rb:1:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-rails-3.
0.1/lib/rspec/rails/view_rendering.rb:1:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-rails-3.
0.1/lib/rspec/rails.rb:4:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-rails-3.
0.1/lib/rspec/rails.rb:4:in `<top (required)>'
        from C:/Users/HuiHui/MyProject/sampleapp/spec/spec_helper.rb:17:in `requ
ire'
        from C:/Users/HuiHui/MyProject/sampleapp/spec/spec_helper.rb:17:in `<top
 (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration.rb:1018:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration.rb:1018:in `block in requires='
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration.rb:1018:in `each'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration.rb:1018:in `requires='
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration_options.rb:101:in `block in process_options_into
'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration_options.rb:100:in `each'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration_options.rb:100:in `process_options_into'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/configuration_options.rb:22:in `configure'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/runner.rb:96:in `setup'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/runner.rb:85:in `run'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/runner.rb:70:in `run'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/lib/rspec/core/runner.rb:38:in `invoke'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0
.1/exe/rspec:4:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bin/rspec:23:in `lo
ad'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bin/rspec:23:in `<m
ain>'

Can anyone help me?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Hanzawa Naoki
  • 505
  • 1
  • 8
  • 19

1 Answers1

1

Try changing the order from

require 'rspec/rails'
require 'active_support'
require 'active_support/deprecation'
require 'activerecord-nulldb-adapter'

To

require 'active_support'
require 'active_support/core_ext'
require 'active_support/deprecation'
require 'rspec/rails'
require 'activerecord-nulldb-adapter'
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
shankardevy
  • 4,290
  • 5
  • 32
  • 49
  • Hi thank you for your comment, I've tried it and it now gives me another error, uninitialised constant ActionView::Template::Handlers::ERB::ENCODING_FLAG (NameError). Do you have any idea as to what is this? – Hanzawa Naoki Jun 19 '14 at 13:48
  • solution here http://stackoverflow.com/questions/4429068/getting-an-unitialized-constant-error-with-rspec-have-no-idea-whats-causing-it says to require 'rails/all'. Try your luck with that. – shankardevy Jun 19 '14 at 16:32
  • @huicheese did you ever figure this out? I am having the same error. – Thalatta Jul 21 '14 at 22:16
  • 1
    @Thalatta Hi i eventually just placed require 'spec_helper' at the top and nothing else. try it :) – Hanzawa Naoki Jul 22 '14 at 02:17