Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Configuration#key? #820

Merged
merged 1 commit into from Feb 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/nanoc/base/entities/configuration.rb
Expand Up @@ -51,6 +51,10 @@ def to_h
@wrapped
end

def key?(key)
@wrapped.key?(key)
end

def [](key)
@wrapped[key]
end
Expand Down
19 changes: 19 additions & 0 deletions spec/nanoc/base/entities/configuration_spec.rb
@@ -0,0 +1,19 @@
describe Nanoc::Int::Configuration do
let(:configuration) { described_class.new(hash) }

let(:hash) { { foo: 'bar' } }

describe '#key?' do
subject { configuration.key?(key) }

context 'non-existent key' do
let(:key) { :donkey }
it { is_expected.not_to be }
end

context 'existent key' do
let(:key) { :foo }
it { is_expected.to be }
end
end
end
4 changes: 3 additions & 1 deletion spec/nanoc/base/views/config_view_spec.rb
@@ -1,8 +1,10 @@
describe Nanoc::ConfigView do
let(:config) do
{ amount: 9000, animal: 'donkey' }
Nanoc::Int::Configuration.new(hash)
end

let(:hash) { { amount: 9000, animal: 'donkey' } }

let(:view) { described_class.new(config, nil) }

describe '#frozen?' do
Expand Down
18 changes: 18 additions & 0 deletions spec/nanoc/regressions/gh_815_spec.rb
@@ -0,0 +1,18 @@
describe 'GH-813', site: true, stdio: true do
before do
File.write('nanoc.yaml', "animal: \"donkey\"\n")
File.write('content/foo.md', '<%= @config.key?(:animal) %>')
File.write('Rules', <<EOS)
compile '/**/*' do
filter :erb
write item.identifier.without_ext + '.txt'
end
EOS
end

specify 'Nanoc generates diff for proper path' do
Nanoc::CLI.run(['compile'])

expect(File.read('output/foo.txt')).to eql('true')
end
end