spec/configuration_spec.rb in ledermann-rails-settings-2.5.0 vs spec/configuration_spec.rb in ledermann-rails-settings-2.6.0
- old
+ new
@@ -3,118 +3,119 @@
module RailsSettings
class Dummy
end
describe Configuration, 'successful' do
- it "should define single key" do
+ it 'should define single key' do
Configuration.new(Dummy, :dashboard)
- expect(Dummy.default_settings).to eq({ :dashboard => {} })
- expect(Dummy.setting_object_class_name).to eq('RailsSettings::SettingObject')
+ expect(Dummy.default_settings).to eq({ dashboard: {} })
+ expect(Dummy.setting_object_class_name).to eq(
+ 'RailsSettings::SettingObject',
+ )
end
- it "should define multiple keys" do
+ it 'should define multiple keys' do
Configuration.new(Dummy, :dashboard, :calendar)
- expect(Dummy.default_settings).to eq({ :dashboard => {}, :calendar => {} })
- expect(Dummy.setting_object_class_name).to eq('RailsSettings::SettingObject')
+ expect(Dummy.default_settings).to eq({ dashboard: {}, calendar: {} })
+ expect(Dummy.setting_object_class_name).to eq(
+ 'RailsSettings::SettingObject',
+ )
end
- it "should define single key with class_name" do
- Configuration.new(Dummy, :dashboard, :class_name => 'MyClass')
- expect(Dummy.default_settings).to eq({ :dashboard => {} })
+ it 'should define single key with class_name' do
+ Configuration.new(Dummy, :dashboard, class_name: 'MyClass')
+ expect(Dummy.default_settings).to eq({ dashboard: {} })
expect(Dummy.setting_object_class_name).to eq('MyClass')
end
- it "should define multiple keys with class_name" do
- Configuration.new(Dummy, :dashboard, :calendar, :class_name => 'MyClass')
+ it 'should define multiple keys with class_name' do
+ Configuration.new(Dummy, :dashboard, :calendar, class_name: 'MyClass')
- expect(Dummy.default_settings).to eq({ :dashboard => {}, :calendar => {} })
+ expect(Dummy.default_settings).to eq({ dashboard: {}, calendar: {} })
expect(Dummy.setting_object_class_name).to eq('MyClass')
end
- it "should define using block" do
+ it 'should define using block' do
Configuration.new(Dummy) do |c|
c.key :dashboard
c.key :calendar
end
- expect(Dummy.default_settings).to eq({ :dashboard => {}, :calendar => {} })
- expect(Dummy.setting_object_class_name).to eq('RailsSettings::SettingObject')
+ expect(Dummy.default_settings).to eq({ dashboard: {}, calendar: {} })
+ expect(Dummy.setting_object_class_name).to eq(
+ 'RailsSettings::SettingObject',
+ )
end
- it "should define using block with defaults" do
+ it 'should define using block with defaults' do
Configuration.new(Dummy) do |c|
- c.key :dashboard, :defaults => { :theme => 'red' }
- c.key :calendar, :defaults => { :scope => 'all' }
+ c.key :dashboard, defaults: { theme: 'red' }
+ c.key :calendar, defaults: { scope: 'all' }
end
- expect(Dummy.default_settings).to eq({ :dashboard => { 'theme' => 'red' }, :calendar => { 'scope' => 'all'} })
- expect(Dummy.setting_object_class_name).to eq('RailsSettings::SettingObject')
+ expect(Dummy.default_settings).to eq(
+ { dashboard: { 'theme' => 'red' }, calendar: { 'scope' => 'all' } },
+ )
+ expect(Dummy.setting_object_class_name).to eq(
+ 'RailsSettings::SettingObject',
+ )
end
- it "should define using block and class_name" do
- Configuration.new(Dummy, :class_name => 'MyClass') do |c|
+ it 'should define using block and class_name' do
+ Configuration.new(Dummy, class_name: 'MyClass') do |c|
c.key :dashboard
c.key :calendar
end
- expect(Dummy.default_settings).to eq({ :dashboard => {}, :calendar => {} })
+ expect(Dummy.default_settings).to eq({ dashboard: {}, calendar: {} })
expect(Dummy.setting_object_class_name).to eq('MyClass')
end
context 'persistent' do
- it "should keep settings between multiple configurations initialization" do
- Configuration.new(Dummy, :persistent => true) do |c|
- c.key :dashboard, :defaults => { :theme => 'red' }
+ it 'should keep settings between multiple configurations initialization' do
+ Configuration.new(Dummy, persistent: true) do |c|
+ c.key :dashboard, defaults: { theme: 'red' }
end
- Configuration.new(Dummy, :calendar, :persistent => true)
+ Configuration.new(Dummy, :calendar, persistent: true)
- expect(Dummy.default_settings).to eq({ :dashboard => { 'theme' => 'red' }, :calendar => {} })
+ expect(Dummy.default_settings).to eq(
+ { dashboard: { 'theme' => 'red' }, calendar: {} },
+ )
end
end
end
describe Configuration, 'failure' do
- it "should fail without args" do
- expect {
- Configuration.new
- }.to raise_error(ArgumentError)
+ it 'should fail without args' do
+ expect { Configuration.new }.to raise_error(ArgumentError)
end
- it "should fail without keys" do
- expect {
- Configuration.new(Dummy)
- }.to raise_error(ArgumentError)
+ it 'should fail without keys' do
+ expect { Configuration.new(Dummy) }.to raise_error(ArgumentError)
end
- it "should fail without keys in block" do
- expect {
- Configuration.new(Dummy) do |c|
- end
- }.to raise_error(ArgumentError)
+ it 'should fail without keys in block' do
+ expect { Configuration.new(Dummy) { |c| } }.to raise_error(ArgumentError)
end
- it "should fail with keys not being symbols" do
- expect {
- Configuration.new(Dummy, 42, "string")
- }.to raise_error(ArgumentError)
+ it 'should fail with keys not being symbols' do
+ expect { Configuration.new(Dummy, 42, 'string') }.to raise_error(
+ ArgumentError,
+ )
end
- it "should fail with keys not being symbols" do
+ it 'should fail with keys not being symbols' do
expect {
- Configuration.new(Dummy) do |c|
- c.key 42, "string"
- end
+ Configuration.new(Dummy) { |c| c.key 42, 'string' }
}.to raise_error(ArgumentError)
end
- it "should fail with unknown option" do
+ it 'should fail with unknown option' do
expect {
- Configuration.new(Dummy) do |c|
- c.key :dashboard, :foo => {}
- end
+ Configuration.new(Dummy) { |c| c.key :dashboard, foo: {} }
}.to raise_error(ArgumentError)
end
end
end