Sha256: 6b78ee2480552d37a4da868b8d482d4bc793e6567a13cf3053fa8bd6b49920e3
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
require 'spec_helper' describe 'configuration' do before do # Backup connection and configs @backup_conn = Standby.instance_variable_get :@standby_connections @backup_config = ActiveRecord::Base.configurations.dup @backup_disabled = Standby.disabled @backup_conn.each_key do |klass_name| Object.send(:remove_const, klass_name) if Object.const_defined?(klass_name) end Standby.instance_variable_set :@standby_connections, {} end after do # Restore connection and configs Standby.instance_variable_set :@standby_connections, @backup_conn ActiveRecord::Base.configurations = @backup_config Standby.disabled = @backup_disabled end it 'raises error if standby configuration not specified' do ActiveRecord::Base.configurations['test_standby'] = nil expect { Standby.on_standby { User.count } }.to raise_error(Standby::Error) end it 'connects to primary if standby configuration is disabled' do ActiveRecord::Base.configurations['test_standby'] = nil Standby.disabled = true expect(Standby.on_standby { User.count }).to be 2 end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
slavery-4.0.0 | spec/configuration_spec.rb |
standby-4.0.0 | spec/configuration_spec.rb |