1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

Merge pull request #145 from avdgaag/fix-for-kernel-array

Bugfix: do not confuse Kernel#Array
This commit is contained in:
Steve Klabnik 2012-03-13 11:55:41 -07:00
commit 89126e48d6
2 changed files with 12 additions and 4 deletions

View file

@ -204,11 +204,15 @@ module Draper
def method_missing(method, *args, &block)
super unless allow?(method)
if model.respond_to?(method)
self.class.send :define_method, method do |*args, &block|
model.send method, *args, &block
end
send method, *args, &block
else
super
end
rescue NoMethodError => no_method_error
super if no_method_error.name == method

View file

@ -622,6 +622,10 @@ describe Draper::Base do
end
context "when the delegated method calls a non-existant method" do
it 'should not try to delegate to non-existant methods to not confuse Kernel#Array' do
Array(subject).should be_kind_of(Array)
end
it "raises the correct NoMethodError" do
begin
subject.some_action