Fixed the wrapping of subject methods that use blocks
This commit is contained in:
parent
b4f632b4a6
commit
235dfd5933
|
@ -37,8 +37,8 @@ module Draper
|
|||
def build_methods
|
||||
select_methods.each do |method|
|
||||
(class << self; self; end).class_eval do
|
||||
define_method method do |*args|
|
||||
source.send method, *args
|
||||
define_method method do |*args, &block|
|
||||
source.send method, *args, &block
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,20 @@ describe Draper::Base do
|
|||
subject.source.should == source
|
||||
end
|
||||
|
||||
it "should wrap source methods so they still accept blocks" do
|
||||
subject.gsub("Sample"){|match| "Super"}.should == "Super String"
|
||||
end
|
||||
|
||||
it "should return a collection of wrapped objects when given a collection of source objects" do
|
||||
pending("need to fix the proxying of blocks")
|
||||
sources = ["one", "two", "three"]
|
||||
output = Draper::Base.new(sources)
|
||||
output.should respond_to(:each)
|
||||
output.size.should == sources.size
|
||||
output.each{ |decorated| decorated.should be_instance_of(Draper::Base) }
|
||||
debugger
|
||||
end
|
||||
|
||||
it "echos the methods of the wrapped class" do
|
||||
source.methods.each do |method|
|
||||
subject.should respond_to(method)
|
||||
|
|
Loading…
Reference in New Issue