require 'spec_helper' RSpec.describe ComplexConfig::Settings do before do # Disable all plugins for this spec b/c they interfere with how rspec works allow(ComplexConfig::Provider.instance).to receive(:plugins).and_return([]) end let :settings do ComplexConfig::Settings[ foo: { bar: { baz: true }, qux: 'quux' } ] end it "can return an attribute's value" do expect(settings.foo.bar.baz).to eq true end it 'can display its attribute_names' do expect(settings.foo.attribute_names).to eq [ :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 return a hash with pathes as keys' do expect(settings.pathes(path_sep: ?:)).to eq( 'foo:bar:baz' => true, 'foo:qux' => "quux" ) end it 'can be represented as a string' do expect(settings.to_s(pair_sep: ' → ', path_sep: ?/)).to eq <