lib/smoke/request.rb in benschwarz-smoke-0.3.10 vs lib/smoke/request.rb in benschwarz-smoke-0.3.11
- old
+ new
@@ -10,11 +10,11 @@
end
SUPPORTED_TYPES = %w(json xml javascript)
attr_reader :uri, :content_type, :body, :type
- def initialize(uri, *options)
+ def initialize(uri, options = {})
@uri, @options = uri, options
dispatch
end
private
@@ -27,11 +27,11 @@
request = RestClient.get(@uri, opts)
@content_type = request.headers[:content_type]
@body = request
}.join
- present! unless @options.include?(:raw_response)
+ present! unless @options[:raw_response]
rescue RestClient::Exception => e
Failure.new(@uri, e)
end
@@ -39,10 +39,10 @@
set_type
parse!
end
def set_type
- @type = (SUPPORTED_TYPES.detect{|t| @content_type =~ /#{t}/ } || "unknown").to_sym
+ @type = @options[:type] || (SUPPORTED_TYPES.detect{|t| @content_type =~ /#{t}/ } || "unknown").to_sym
end
def parse!
case @type
when :json, :javascript
\ No newline at end of file