Skip to content

Commit

Permalink
Fix message of invalid prefix error
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Jun 28, 2016
1 parent b5edd86 commit 7c74c48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/nanoc/base/entities/identifier.rb
Expand Up @@ -123,7 +123,7 @@ def +(other)
# @return [Nanoc::Identifier]
def prefix(string)
if string !~ /\A\//
raise InvalidPrefixError.new(@string)
raise InvalidPrefixError.new(string)
end
Nanoc::Identifier.new(string.sub(/\/+\z/, '') + @string, type: @type)
end
Expand Down
10 changes: 8 additions & 2 deletions spec/nanoc/base/entities/identifier_spec.rb
Expand Up @@ -244,15 +244,21 @@
let(:prefix) { 'asdf' }

it 'raises an error' do
expect { subject }.to raise_error(Nanoc::Identifier::InvalidPrefixError)
expect { subject }.to raise_error(
Nanoc::Identifier::InvalidPrefixError,
'Invalid prefix (does not start with a slash): "asdf"',
)
end
end

context 'prefix ending with a slash' do
let(:prefix) { 'asdf/' }

it 'raises an error' do
expect { subject }.to raise_error(Nanoc::Identifier::InvalidPrefixError)
expect { subject }.to raise_error(
Nanoc::Identifier::InvalidPrefixError,
'Invalid prefix (does not start with a slash): "asdf/"',
)
end
end

Expand Down

0 comments on commit 7c74c48

Please sign in to comment.