1
votes

I currently have a ruby on rails project where I am not using ActiveRecord. On rails 4.0.8 it works fine, when I upgrade to rails 4.1.4 it fails with a ActiveRecord::ConnectionNotEstablished. I cannot figure out how to disable it trying to connect to active record.

I have set config.use_transactional_fixtures = false in the spec file

In my config/application.rb file I have

# Pick the frameworks you want:                                                    
# require "active_record/railtie"                                                  
require 'action_controller/railtie'                                                
require 'action_mailer/railtie'                                                    
require 'sprockets/railtie'                                                        
# require "rails/test_unit/railtie" 

The project that has the following:

ruby 2.1.2
rails 4.0.8
rspec-rails 3.0.2

This is the stack trace I get:

 Failure/Error: Unable to find matching line from backtrace
 ActiveRecord::ConnectionNotEstablished:
   ActiveRecord::ConnectionNotEstablished
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_handling.rb:87:in `connection'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/fixtures.rb:499:in `create_fixtures'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/fixtures.rb:984:in `load_fixtures'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/fixtures.rb:957:in `setup_fixtures'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/fixtures.rb:806:in `before_setup'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-rails-3.0.2/lib/rspec/rails/adapters.rb:71:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example.rb:294:in `instance_exec'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example.rb:294:in `instance_exec'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/hooks.rb:430:in `block (2 levels) in run'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example.rb:210:in `call'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/hooks.rb:432:in `run'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/hooks.rb:485:in `run'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example.rb:303:in `with_around_example_hooks'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example.rb:145:in `run'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:494:in `block in run_examples'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:490:in `map'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:490:in `run_examples'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:457:in `run'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:458:in `block in run'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:458:in `map'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:458:in `run'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:458:in `block in run'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:458:in `map'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:458:in `run'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:112:in `block (2 levels) in run_specs'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:112:in `map'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:112:in `block in run_specs'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/reporter.rb:54:in `report'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:108:in `run_specs'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:86:in `run'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:70:in `run'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:38:in `invoke'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.3/exe/rspec:4:in `<top (required)>'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/bin/rspec:23:in `load'
 # /home/owen/workspace/cms/vendor/bundle/ruby/2.1.0/bin/rspec:23:in `<main>'

My spec/spec_helper.rb is the default blank one with lots of comments, my rspec helper is as follows:

if ENV['COVERAGE']
  require 'simplecov'
  require 'simplecov-console'
  require 'coveralls'

  SimpleCov.minimum_coverage 100

  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
    SimpleCov::Formatter::HTMLFormatter,
    SimpleCov::Formatter::Console,
    Coveralls::SimpleCov::Formatter,
  ]

  SimpleCov.start 'rails'
end

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

Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

RSpec.configure do |config|
  config.infer_spec_type_from_file_location!

  config.before :all do
    CouchPotato.couchrest_database.create!
  end

  config.before do
    if CouchPotato.couchrest_database.info['update_seq'] > 0
      CouchPotato.couchrest_database.recreate!
    end
  end
end

Has anyone got any suggestions? Thanks.

1
Your test appears to be using fixtures, which require activerecord. Can you gist your rails_helper/spec_helper?sevenseacat
show database.yml please.Зелёный

1 Answers