Sha256: 92f1f4bc24467028a1ab97d08d6e09251895f0d03df11c55cc252ea8f9fdee2b

Contents?: true

Size: 1.04 KB

Versions: 23

Compression:

Stored size: 1.04 KB

Contents

# Helper defines a active-model like model so tests can work in rails2/3 environments
begin
  require 'active_model'
  class ModelBase
    include ActiveModel::Validations
  end
rescue LoadError # can't load active_model, so rails < 3
  require 'active_record'
  class ModelBase < ActiveRecord::Base
  end

  require 'nulldb_rspec'

  # Custom NullDB so can reconnect to regular adapter after running
  module NullDB::CustomNullifiedDatabase
    def self.included(spec_example)
      spec_example.before :all do
        ActiveRecord::Base.establish_connection :adapter => :nulldb, :schema => 'spec/schema.rb'
      end

      spec_example.before :each do
        ActiveRecord::Base.connection.checkpoint!
      end

      spec_example.after :all do
        ActiveRecord::Base.remove_connection

        begin
          connect_to_sqlite
        rescue ActiveRecord::AdapterNotSpecified
          # swallow reconnection when running in nulldb / lite environment
          # without any app boot, and hence no db config for :test
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rails_core_extensions-0.15.0 spec/spec_helper_model_base.rb
rails_core_extensions-0.14.0 spec/spec_helper_model_base.rb
rails_core_extensions-0.13.2 spec/spec_helper_model_base.rb
rails_core_extensions-0.13.1 spec/spec_helper_model_base.rb
rails_core_extensions-0.13.0 spec/spec_helper_model_base.rb
rails_core_extensions-0.12.0 spec/spec_helper_model_base.rb
rails_core_extensions-0.11.3 spec/spec_helper_model_base.rb
rails_core_extensions-0.11.2 spec/spec_helper_model_base.rb
rails_core_extensions-0.11.1 spec/spec_helper_model_base.rb
rails_core_extensions-0.11.0.beta.11 spec/spec_helper_model_base.rb
rails_core_extensions-0.10.0 spec/spec_helper_model_base.rb
rails_core_extensions-0.9.0 spec/spec_helper_model_base.rb
rails_core_extensions-0.8.0 spec/spec_helper_model_base.rb
rails_core_extensions-0.7.1 spec/spec_helper_model_base.rb
rails_core_extensions-0.7.0 spec/spec_helper_model_base.rb
rails_core_extensions-0.6.1 spec/spec_helper_model_base.rb
rails_core_extensions-0.6.0 spec/spec_helper_model_base.rb
rails_core_extensions-0.4.0 spec/spec_helper_model_base.rb
rails_core_extensions-0.3.0 spec/spec_helper_model_base.rb
rails_core_extensions-0.2.0 spec/spec_helper_model_base.rb