Skip to content

Commit

Permalink
Merge pull request #692 from nanoc/pattern-from-inspect
Browse files Browse the repository at this point in the history
Improve Pattern.from error message
  • Loading branch information
denisdefreyne committed Aug 15, 2015
2 parents 72429ce + d2cf96d commit 734efb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nanoc/base/entities/pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.from(obj)
when Regexp
Nanoc::Int::RegexpPattern.new(obj)
else
raise ArgumentError, "Do not know how to convert #{obj} into a Nanoc::Pattern"
raise ArgumentError, "Do not know how to convert `#{obj.inspect}` into a Nanoc::Pattern"
end
end

Expand Down
5 changes: 5 additions & 0 deletions spec/nanoc/base/entities/pattern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
it 'errors on other inputs' do
expect { described_class.from(123) }.to raise_error(ArgumentError)
end

it 'errors with a proper error message on other inputs' do
expect { described_class.from(nil) }
.to raise_error(ArgumentError, "Do not know how to convert `nil` into a Nanoc::Pattern")
end
end

describe '#initialize' do
Expand Down

0 comments on commit 734efb1

Please sign in to comment.