Permalink
Browse files

Merge pull request #36 from amaierhofer/patch-1

Update exhibit.rb to include a check for anonymous classes before trying to operate on it's name.
  • Loading branch information...
codeodor committed Apr 4, 2013
2 parents c82dbd5 + 974ff0e commit 8bd5bfb542ed3f6141e0d0ef97b784053be28752
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/display_case/exhibit.rb
  2. +6 −0 spec/exhibits/exhibit_spec.rb
@@ -29,7 +29,7 @@ def self.exhibit(object, context=nil)
::Rails.logger.debug "Exhibit context: #{context}"
end
- similar, unsimilar = exhibits.partition { |exhibit_class| context and exhibit_class.name and context.class.name.downcase.include?(exhibit_class.name.to_s.downcase.gsub("exhibit", "")) }
+ similar, unsimilar = exhibits.partition { |exhibit_class| context and exhibit_class.name and context.class.name and context.class.name.downcase.include?(exhibit_class.name.to_s.downcase.gsub("exhibit", "")) }
object = BasicExhibit.new(Exhibited.new(object, context), context)
(unsimilar+similar).inject(object) do |object, exhibit_class|
exhibit_class.exhibit_if_applicable(object, context)
@@ -59,5 +59,11 @@ class StringExhibit < DisplayCase::Exhibit; end;
mock(DisplayCase::Exhibit).exhibit(other_model, context){ result }
subject.exhibit(other_model).must_be_same_as(result)
end
+
+ it 'works when passed a context instance of an anonymous class' do
+ anonymous = Class.new.new
+ result = DisplayCase::Exhibit.exhibit(model, anonymous)
+ DisplayCase::Exhibit.exhibited_object?(result).must_equal true
+ end
end
end

0 comments on commit 8bd5bfb

Please sign in to comment.