Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d9a7e8
commit 16a6f2f
Showing
10 changed files
with
277 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# encoding: utf-8 | ||
|
||
describe Nanoc::ConfigView do | ||
let(:config) do | ||
{ amount: 9000, animal: 'donkey' } | ||
end | ||
|
||
let(:view) { described_class.new(config) } | ||
|
||
describe '#[]' do | ||
subject { view[key] } | ||
|
||
context 'with existant key' do | ||
let(:key) { :animal } | ||
it { should eql?('donkey') } | ||
end | ||
|
||
context 'with non-existant key' do | ||
let(:key) { :weapon } | ||
it { should eql?(nil) } | ||
end | ||
end | ||
|
||
describe '#fetch' do | ||
context 'with existant key' do | ||
let(:key) { :animal } | ||
|
||
subject { view.fetch(key) } | ||
|
||
it { should eql?('donkey') } | ||
end | ||
|
||
context 'with non-existant key' do | ||
let(:key) { :weapon } | ||
|
||
context 'with fallback' do | ||
subject { view.fetch(key, 'nothing sorry') } | ||
it { should eql?('nothing sorry') } | ||
end | ||
|
||
context 'with block' do | ||
subject { view.fetch(key) { 'nothing sorry' } } | ||
it { should eql?('nothing sorry') } | ||
end | ||
|
||
context 'with no fallback and no block' do | ||
subject { view.fetch(key) } | ||
|
||
it 'raises' do | ||
expect { subject }.to raise_error(KeyError) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe '#key?' do | ||
subject { view.key?(key) } | ||
|
||
context 'with existant key' do | ||
let(:key) { :animal } | ||
it { should eql?(true) } | ||
end | ||
|
||
context 'with non-existant key' do | ||
let(:key) { :weapon } | ||
it { should eql?(false) } | ||
end | ||
end | ||
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
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