spec/support/rack_apps.rb in mixpanel-4.0.3 vs spec/support/rack_apps.rb in mixpanel-4.0.4

- old
+ new

@@ -16,14 +16,25 @@ class DummyApp def initialize(options) @response_with = {} @response_with[:status] = options[:status] || "200" @response_with[:headers] = options[:headers] || {} - @response_with[:body] = options[:body] || "" + @response_with[:body] = wrap(options[:body] || '') end def call(env) - [@response_with[:status], @response_with[:headers], [@response_with[:body]]] + [@response_with[:status], @response_with[:headers], @response_with[:body]] + end + + private + def wrap(object) + if object.nil? + [] + elsif object.respond_to?(:to_ary) + object.to_ary || [object] + else + [object] + end end end def large_script <<-EOT