Sha256: e6f0bae389b345aa8a134bf2f920dea7cecbdeabbfc40e072e579d98e5331680
Contents?: true
Size: 1.11 KB
Versions: 5
Compression:
Stored size: 1.11 KB
Contents
describe StatusCat::Checkers::ActiveRecord do let(:checker) { StatusCat::Checkers::ActiveRecord.new.freeze } it_should_behave_like 'a status checker' it 'constructs a value from the configuration' do config = { adapter: 'postgres', username: 'dba', database: 'test' } allow(::ActiveRecord::Base).to receive(:connection_config).and_return(config) expected = "#{config[:adapter]}:#{config[:username]}@#{config[:database]}" expect(checker.value).to eql(expected) end describe '#status' do context 'pass' do it 'passes if it can execute a query against the database' do allow(ActiveRecord::Base.connection).to receive(:execute) checker = StatusCat::Checkers::ActiveRecord.new expect(checker.status).to be_nil end end context 'fail' do it 'returns an error message if it fails to query the database' do fail = 'This is only a test' expect(ActiveRecord::Base.connection).to receive(:execute).and_raise(fail) checker = StatusCat::Checkers::ActiveRecord.new expect(checker.status.to_s).to eql(fail) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems