Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inconsistencies with Dash defaults
The normal behavior of Dash with respect to property defaults differed from the behavior of a Dash/Trash with IgnoreUndeclared mixed in. This is because some situations called the defaults and some did not. This change normalizes the behavior so that all situations where the defaults should be used to override unset values behave consistently, as well as all situations where the default should not override a `nil` value.
- Loading branch information
1 parent
b741e5d
commit 1ab55b8
Showing
8 changed files
with
85 additions
and
21 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
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,26 @@ | ||
RSpec.shared_examples 'Dash default handling' do |property, name = property| | ||
it 'uses the default when initializing' do | ||
expect(test.new(name => nil).public_send(property)).to eq '' | ||
end | ||
|
||
it 'allows you to set the value to nil with the hash writer' do | ||
trash = test.new(name => 'foo') | ||
trash[name] = nil | ||
|
||
expect(trash.public_send(property)).to be_nil | ||
end | ||
|
||
it 'allows you to set the value to nil with the method writer' do | ||
trash = test.new(name => 'foo') | ||
trash[name] = nil | ||
|
||
expect(trash.public_send(property)).to be_nil | ||
end | ||
|
||
it 'uses the default when updating with defaults' do | ||
trash = test.new(name => 'foo') | ||
trash.update_attributes!(name => nil) | ||
|
||
expect(trash.public_send(property)).to eq '' | ||
end | ||
end |