spec/nanoc/base/views/config_view_spec.rb in nanoc-4.8.7 vs spec/nanoc/base/views/config_view_spec.rb in nanoc-4.8.8
- old
+ new
@@ -3,11 +3,11 @@
describe Nanoc::ConfigView do
let(:config) do
Nanoc::Int::Configuration.new(hash: hash)
end
- let(:hash) { { amount: 9000, animal: 'donkey' } }
+ let(:hash) { { amount: 9000, animal: 'donkey', foo: { bar: :baz } } }
let(:view) { described_class.new(config, view_context) }
let(:view_context) do
Nanoc::ViewContext.new(
@@ -39,35 +39,35 @@
before do
expect(dependency_tracker).to receive(:bounce).with(config, attributes: [key])
end
- context 'with existant key' do
+ context 'with existing key' do
let(:key) { :animal }
it { is_expected.to eql('donkey') }
end
- context 'with non-existant key' do
+ context 'with non-existing key' do
let(:key) { :weapon }
it { is_expected.to eql(nil) }
end
end
describe '#fetch' do
before do
expect(dependency_tracker).to receive(:bounce).with(config, attributes: [key])
end
- context 'with existant key' do
+ context 'with existing key' do
let(:key) { :animal }
subject { view.fetch(key) }
it { is_expected.to eql('donkey') }
end
- context 'with non-existant key' do
+ context 'with non-existing key' do
let(:key) { :weapon }
context 'with fallback' do
subject { view.fetch(key, 'nothing sorry') }
it { is_expected.to eql('nothing sorry') }
@@ -93,16 +93,16 @@
before do
expect(dependency_tracker).to receive(:bounce).with(config, attributes: [key])
end
- context 'with existant key' do
+ context 'with existing key' do
let(:key) { :animal }
it { is_expected.to eql(true) }
end
- context 'with non-existant key' do
+ context 'with non-existing key' do
let(:key) { :weapon }
it { is_expected.to eql(false) }
end
end
@@ -113,10 +113,28 @@
example do
res = []
view.each { |k, v| res << [k, v] }
- expect(res).to eql([[:amount, 9000], [:animal, 'donkey']])
+ expect(res).to eql([[:amount, 9000], [:animal, 'donkey'], [:foo, { bar: :baz }]])
+ end
+ end
+
+ describe '#dig' do
+ subject { view.dig(*keys) }
+
+ before do
+ expect(dependency_tracker).to receive(:bounce).with(config, attributes: [:foo])
+ end
+
+ context 'with existing keys' do
+ let(:keys) { %i[foo bar] }
+ it { is_expected.to eql(:baz) }
+ end
+
+ context 'with non-existing keys' do
+ let(:keys) { %i[foo baz bar] }
+ it { is_expected.to be_nil }
end
end
describe '#inspect' do
subject { view.inspect }