Sha256: 998e8771a9d155d017b10a20fec42f54462b92fe0b75914f13728dd4836b8fd3
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
require 'spec_helper' RSpec.describe ComplexConfig::Settings do let :provider do ComplexConfig::Provider end let :settings do ComplexConfig::Settings[ foo: { bar: { baz: true }, qux: 'quux' } ] end it 'can display its attribute_names' do expect(settings.foo.attribute_names).to eq %i[ bar qux ] end it 'can display its attribute_values' do values = settings.foo.attribute_values expect(values.first.to_h).to eq(baz: true) expect(values.last).to eq 'quux' end it 'can return the value of an attribute' do expect(settings.foo.bar.baz).to eq true end it 'can be converted into a hash' do expect(settings.foo.to_h).to eq(bar: { baz: true }, qux: 'quux') end it 'can be represented as a string' do expect(settings.to_s).to eq <<EOT --- :foo: :bar: :baz: true :qux: quux EOT end it 'raises exception if expected attribute is missing' do skip "doesn't work in spec?!?" # XXX expect { settings.foo.baz }.to raise_error(ComplexConfig::AttributeMissing) end it 'can be checked for set attributes' do expect(settings.foo.attribute_set?(:bar)).to eq true expect(settings.foo.bar?).to be_truthy expect(settings.foo.attribute_set?(:baz)).to eq false # XXX doesn't work in spec?!? expect(settings.foo.baz?).to be_falsy end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
complex_config-0.0.0 | spec/complex_config/settings_spec.rb |