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

Allow IdentifiableCollection#[] with Identifier #695

Merged
merged 1 commit into from Aug 15, 2015
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
2 changes: 2 additions & 0 deletions lib/nanoc/base/identifiable_collection.rb
Expand Up @@ -24,6 +24,8 @@ def freeze

def [](arg)
case arg
when Nanoc::Identifier
object_with_identifier(arg)
when String
object_with_identifier(arg) || object_matching_glob(arg)
when Regexp
Expand Down
11 changes: 10 additions & 1 deletion spec/nanoc/base/views/identifiable_collection_spec.rb
Expand Up @@ -71,7 +71,7 @@
it { is_expected.to equal(nil) }
end

context 'direct identifier' do
context 'string' do
let(:arg) { '/home.erb' }

it 'returns wrapped object' do
Expand All @@ -80,6 +80,15 @@
end
end

context 'identifier' do
let(:arg) { Nanoc::Identifier.new('/home.erb') }

it 'returns wrapped object' do
expect(subject.class).to equal(view_class)
expect(subject.unwrap).to equal(home_object)
end
end

context 'glob' do
let(:arg) { '/home.*' }

Expand Down