Skip to content

Commit

Permalink
Raise proper error when passing symbol to #layout
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Jul 24, 2016
1 parent 9881c6b commit 0ec5e9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/nanoc/rule_dsl/recording_executor.rb
Expand Up @@ -22,6 +22,10 @@ def filter(_rep, filter_name, filter_args = {})
end

def layout(_rep, layout_identifier, extra_filter_args = {})
unless layout_identifier.is_a?(String)
raise ArgumentError.new('The layout passed to #layout must be a string')
end

unless @rule_memory.any_layouts?
@rule_memory.add_snapshot(:pre, true, nil)
end
Expand Down
4 changes: 4 additions & 0 deletions spec/nanoc/rule_dsl/recording_executor_spec.rb
Expand Up @@ -55,6 +55,10 @@
expect(executor.rule_memory[1].layout_identifier).to eql('/default.*')
expect(executor.rule_memory[1].params).to eql({ final: false })
end

it 'fails when passed a symbol' do
expect { executor.layout(rep, :default, final: false) }.to raise_error(ArgumentError)
end
end

describe '#snapshot' do
Expand Down

0 comments on commit 0ec5e9e

Please sign in to comment.