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.1.1 | spec/spec_helper_model_base.rb |
rails_core_extensions-0.1.0 | spec/spec_helper_model_base.rb |
rails_core_extensions-0.0.1 | spec/spec_helper_model_base.rb |