-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert keys to symbols when initializing a new
ConfigSL::Config
.
- Loading branch information
1 parent
4f83875
commit 29535e4
Showing
5 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class ConfigSpecConfig < ConfigSL::Config | ||
option :default, type: String, default: 'rspec-default' | ||
option :optional, type: String | ||
option :required, type: String, required: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe ConfigSL::Config do | ||
subject(:config) { ConfigSpecConfig } | ||
|
||
describe '#initialize' do | ||
it 'raises an error for unknown options' do | ||
expect { config.new(unknown: 'rspec') }.to \ | ||
raise_error(ConfigSL::InvalidOptionError) | ||
end | ||
|
||
it 'sets values for hash keys' do | ||
instance = config.new(required: 'rspec') | ||
|
||
expect(instance.required).to eq('rspec') | ||
end | ||
|
||
it 'sets values for string keys' do | ||
instance = config.new('required' => 'rspec') | ||
|
||
expect(instance.required).to eq('rspec') | ||
end | ||
end | ||
end |