Sha256: c4d416fd614dff590c18d2c009db7dff27c49c2497964f862708c4827366a128
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
require 'spec_helper' module Alf module Support describe Config, '.new' do let(:conf_subclass){ Class.new(Config){ option :ready, Boolean, false } } subject{ conf_subclass.new(h) } context 'when options must be coerced' do let(:h){ {ready: "true"} } it 'coerces them' do subject.ready?.should eq(true) end end context 'when an option is not known' do let(:h){ {nosuchone: "blah"} } it 'raises an error' do lambda{ subject }.should raise_error(ConfigError, /No such option `nosuchone`/) end end context 'when an option cannot be coerced' do let(:h){ {ready: "blah"} } it 'raises an error' do lambda{ subject }.should raise_error(ConfigError, /Invalid option value `ready`: `blah`/) end end context 'with a block passed' do subject{ conf_subclass.new{|c| c.ready = true } } it 'yields the block' do subject.ready?.should be_true end end context 'when nothing is passed' do subject{ conf_subclass.new } it 'uses default values' do subject.ready?.should be_false end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alf-core-0.15.0 | spec/unit/alf-support/config/test_new.rb |
alf-core-0.14.0 | spec/unit/alf-support/config/test_new.rb |