lib/bbq/test_client.rb in bbq-0.2.0 vs lib/bbq/test_client.rb in bbq-0.2.1

- old
+ new

@@ -13,22 +13,23 @@ HTTP_METHODS = %w(get post put delete head options patch) HTTP_METHODS.each do |method| class_eval <<-RUBY def #{method}(path, params = {}, headers = {}) - response = driver.send(:#{method}, path, params, default_headers.merge(headers)) + unless driver.respond_to? :#{method} + raise UnsupportedMethodError, "Your driver does not support #{method.upcase} method" + end + + response = driver.#{method}(path, params, default_headers.merge(headers)) parsed_response = parse_response(response) yield parsed_response if block_given? parsed_response - rescue NoMethodError - raise UnsupportedMethodError, "Your driver does not support #{method.upcase} method" end RUBY end protected - def app @options[:app] || Bbq.app end def default_headers @@ -69,10 +70,10 @@ def to_env_headers(http_headers) http_headers.map do |k, v| k = k.upcase.gsub("-", "_") k = "HTTP_#{k}" unless ["CONTENT_TYPE", "CONTENT_LENGTH"].include?(k) { k => v } - end.inject(:merge) + end.inject({}, :merge) end end include Rack::Test::Methods include ConvertHeaders