Sha256: 9281c87366230ae39cf560971cf8f56017b679057a6beaa2d9675654c5950411
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
require 'spec_helper' require 'puppet-herald' describe PuppetHerald::Database, '.spec' do before(:each) do PuppetHerald.environment = :test PuppetHerald.logger.level = 100 PuppetHerald.errlogger.level = 100 end let(:tempdir) { Dir.tmpdir } let(:echo) { false } subject { PuppetHerald::database::spec echo } context 'with invalid dbconn' do before :each do PuppetHerald::database::dbconn = "#{tempdir}/non-existing.db" end it { expect { subject }.to raise_error(RuntimeError, /Invalid database connection string given/) } end context 'using sqlite' do context 'with non existing database' do before :each do PuppetHerald::database::dbconn = 'sqlite:///non-existing/non-existing.db' end it { expect { subject }.to raise_error(Errno::ENOENT, /No such file or directory/) } end context 'with creatable database file' do before :each do PuppetHerald::database::dbconn = "sqlite://#{tempdir}/non-existing.db" end its(:class) { should be Hash } its(:size) { should eq 2 } context 'while echoing!!' do let(:echo) { true } its(:class) { should be Hash } its(:size) { should eq 2 } end end end context 'using postgres' do before :each do PuppetHerald::database::dbconn = "postgres://abc@localhost:6543/adb" end context 'with non existing passfile' do before :each do PuppetHerald::database::passfile = "/non-existing/passfile" end it { expect { subject }.to raise_error(Errno::ENOENT, /No such file or directory/) } end context 'with existing passfile' do before :each do PuppetHerald::database::passfile = __FILE__ end its(:class) { should be Hash } its(:size) { should eq 7 } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
puppet-herald-0.8.1 | spec/unit/puppet-herald/database_spec.rb |
puppet-herald-0.8.0 | spec/unit/puppet-herald/database_spec.rb |