lib/angelo/minitest/helpers.rb in angelo-0.1.24 vs lib/angelo/minitest/helpers.rb in angelo-0.2.0

- old
+ new

@@ -36,11 +36,15 @@ url += path if path url end def hc_req method, path, params = {}, headers = {} - @last_response = hc.__send__ method, url(path), params, headers + @last_response = if block_given? + hc.__send__ method, url(path), params, headers, &Proc.new + else + hc.__send__ method, url(path), params, headers + end end private :hc_req def http_req method, path, params = {}, headers = {} params = case params @@ -62,11 +66,17 @@ end private :http_req [:get, :post, :put, :delete, :options, :head].each do |m| define_method m do |path, params = {}, headers = {}| + # http_req m, path, params, headers - hc_req m, path, params, headers + + if block_given? + hc_req m, path, params, headers, &Proc.new + else + hc_req m, path, params, headers + end end end def get_sse path, params = {}, headers = {}, &block @last_response = hc.get url(path), params, headers, &block