Skip to content

Commit

Permalink
Add zip to the list of reserved keywords (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
niclin authored and pkuczynski committed Feb 2, 2018
1 parent 2ad2542 commit 0820c8d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Fix `key?` and `has_key?`, which raise NoMethodError in non Rails environment, by using ActiveSupport `#delegate` implicitly ([#185](https://github.com/railsconfig/config/pull/185))
* Update `deep_merge` dependency to latest version (v1.2.1) ([#191](https://github.com/railsconfig/config/pull/191))
* Upgrade `rubocop` to version 0.52.1 ([#193](https://github.com/railsconfig/config/pull/193))
* Add `zip` to the list of reserved keywords ([#197](https://github.com/railsconfig/config/pull/197))

## 1.6.0

Expand Down
2 changes: 1 addition & 1 deletion lib/config/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def merge!(hash)
end

# Some keywords that don't play nicely with OpenStruct
SETTINGS_RESERVED_NAMES = %w{select collect test count}
SETTINGS_RESERVED_NAMES = %w[select collect test count zip].freeze

# An alternative mechanism for property access.
# This let's you do foo['bar'] along with foo.bar.
Expand Down
7 changes: 4 additions & 3 deletions spec/fixtures/reserved_keywords.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
select: 123
collect: 456
count: 789
select: apple
collect: banana
count: lemon
zip: cherry
23 changes: 13 additions & 10 deletions spec/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@
end

it 'should allow to access them via object member notation' do
expect(config.select).to eq(123)
expect(config.collect).to eq(456)
expect(config.count).to eq(789)
expect(config.select).to eq('apple')
expect(config.collect).to eq('banana')
expect(config.count).to eq('lemon')
expect(config.zip).to eq('cherry')
end

it 'should allow to access them using [] operator' do
expect(config['select']).to eq(123)
expect(config['collect']).to eq(456)
expect(config['count']).to eq(789)

expect(config[:select]).to eq(123)
expect(config[:collect]).to eq(456)
expect(config[:count]).to eq(789)
expect(config['select']).to eq('apple')
expect(config['collect']).to eq('banana')
expect(config['count']).to eq('lemon')
expect(config['zip']).to eq('cherry')

expect(config[:select]).to eq('apple')
expect(config[:collect]).to eq('banana')
expect(config[:count]).to eq('lemon')
expect(config[:zip]).to eq('cherry')
end
end

Expand Down

0 comments on commit 0820c8d

Please sign in to comment.