File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
lib/protocol/http/middleware
test/protocol/http/middleware Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,13 @@ def to_app
3030 def self . build ( &block )
3131 builder = Builder . new
3232
33- builder . instance_eval ( &block )
33+ if block_given?
34+ if block . arity == 0
35+ builder . instance_exec ( &block )
36+ else
37+ yield builder
38+ end
39+ end
3440
3541 return builder . to_app
3642 end
Original file line number Diff line number Diff line change 2929
3030 expect ( app ) . to be_a ( Protocol ::HTTP ::Middleware )
3131 end
32+
33+ it "provides the builder as an argument" do
34+ current_self = self
35+
36+ app = Protocol ::HTTP ::Middleware . build do |builder |
37+ builder . use Protocol ::HTTP ::Middleware
38+
39+ expect ( self ) . to be_equal ( current_self )
40+ end
41+
42+ expect ( app ) . to be_a ( Protocol ::HTTP ::Middleware )
43+ end
3244end
You can’t perform that action at this time.
0 commit comments