Skip to content

Commit

Permalink
Added a test to demonstrate classify vs. camelize; Updated Draper::Ba…
Browse files Browse the repository at this point in the history
…se#decorates to use camelize instead of classify
  • Loading branch information
melriffe committed Aug 27, 2011
1 parent 8f92237 commit 3709bf4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/draper/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.find(input)
end

def self.decorates(input)
self.model_class = input.to_s.classify.constantize
self.model_class = input.to_s.camelize.constantize
model_class.send :include, Draper::ModelSupport
end

Expand Down
17 changes: 17 additions & 0 deletions spec/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@
describe Draper::Base do
subject{ Draper::Base.new(source) }
let(:source){ Product.new }

context("classify_vs_camelize") do
it "should create 'Busines' when using classify" do
:business.to_s.classify.should == 'Busines'
end

it "should create 'Business' when using camelize" do
:business.to_s.camelize.should == 'Business'
end

it "should fail for 'decorates :business'" do
class Business; end
lambda do
Draper::Base.decorates(:business)
end.should_not raise_error
end
end

context(".lazy_helpers") do
it "makes Rails helpers available without using the h. proxy" do
Expand Down

0 comments on commit 3709bf4

Please sign in to comment.