简体   繁体   中英

Rails Activesupport error in rpect

I am beginner Ruby on Rails. I was following railstutorial.org to trying to do test but I am getting error related to activesupport. I am on Yosemite. I run command 'rails generate integration_test static_pages' to generate static_pages and after trying to run TDD for same. I run 'exec rspec spec/requests/static_pages_spec.rb' and I got error

/Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require': No such file to load -- test/unit/assertions (LoadError)
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/rspec-rails-2.13.1/lib/rspec/rails/adapters.rb:3:in `<top (required)>'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/rspec-rails-2.13.1/lib/rspec/rails.rb:11:in `<top (required)>'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:360:in `require_or_load'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:317:in `depend_on'
from /Users/pradeepkotwal1/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:233:in `require_dependency'
from /Users/pradeepkotwal1/rails_projects/sample_app/spec/spec_helper.rb:4:in `<top (required)>'

Can you please help me

Your spec_helper.rb should look like this, I'm not sure if you pasted it wrong:

  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'rspec/autorun'

  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
  ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
  RSpec.configure do |config|
    config.fixture_path = "#{::Rails.root}/spec/fixtures"
    config.use_transactional_fixtures = true
    config.infer_base_class_for_anonymous_controllers = false
    config.order = "random"
  end 

Check it and try again. If this doesn't work try backing up your Gemfile and replace it with:

https://github.com/railstutorial/sample_app_rails_4/blob/master/Gemfile

then run

bundle install

then try again:

bundle exec rspec spec/requests/static_pages_spec.rb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM