Sha256: e811b486794fd7a4daae876d7509c94bb125b2455a35dbbf1f1aefbc6d651e22
Contents?: true
Size: 1.93 KB
Versions: 1
Compression:
Stored size: 1.93 KB
Contents
require 'spec_helper' describe Travis::Config do let(:config) { Travis::Config.new } after { ENV.delete('travis_config') } describe 'Hashr behaviour' do it 'is a Hashr instance' do config.should be_kind_of(Hashr) end it 'returns Hashr instances on subkeys' do ENV['travis_config'] = YAML.dump('redis' => { 'url' => 'redis://localhost:6379' }) config.redis.should be_kind_of(Hashr) end it 'returns Hashr instances on subkeys that were set to Ruby Hashes' do config.foo = { :bar => { :baz => 'baz' } } config.foo.bar.should be_kind_of(Hashr) end end describe 'defaults' do it 'notifications defaults to []' do config.notifications.should == [] end it 'queues defaults to []' do config.queues.should == [] end it 'ampq.host defaults to "127.0.0.1"' do config.amqp.host.should == '127.0.0.1' end it 'ampq.prefetch defaults to 1' do config.amqp.prefetch.should == 1 end it 'database' do config.database.should == { :adapter => 'postgresql', :database => 'travis_test', :encoding => 'unicode', :min_messages => 'warning' } end end describe 'the example config file' do let(:data) { {} } before(:each) { Travis::Config.stubs(:load_file).returns(data) } it 'can access pusher' do lambda { config.pusher.key }.should_not raise_error end it 'can access all keys recursively' do nested_access = lambda do |config, data| data.keys.each do |key| lambda { config.send(key) }.should_not raise_error nested_access.call(config.send(key), data[key]) if data[key].is_a?(Hash) end end nested_access.call(config, data) end end it 'deep symbolizes arrays, too' do config = Travis::Config.new('queues' => [{ 'slug' => 'rails/rails', 'queue' => 'rails' }]) config.queues.first.values_at(:slug, :queue).should == ['rails/rails', 'rails'] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
travis-core-0.0.1 | spec/travis/config_spec.rb |