Added a test to demonstrate classify vs. camelize; Updated Draper::Base#decorates to use camelize instead of classify

This commit is contained in:
Mel Riffe 2011-08-27 00:23:48 -04:00
parent 8f9223778a
commit 3709bf4077
2 changed files with 18 additions and 1 deletions

View File

@ -21,7 +21,7 @@ module Draper
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

View File

@ -4,6 +4,23 @@ require 'draper'
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