spec/support/json_test_app.rb in capybara-json-0.0.2 vs spec/support/json_test_app.rb in capybara-json-0.0.3

- old
+ new

@@ -1,7 +1,24 @@ require 'capybara/spec/test_app' +# for capybara < 1.0 +module Capybara + class Server + class Identify + def call(env) + if env["PATH_INFO"] == "/__identify__" + #[200, {}, @app.object_id.to_s] + [200, {}, [ @app.object_id.to_s] ] + else + @app.call(env) + end + end + end + end +end + + class JsonTestApp < TestApp def invoke res = catch(:halt) { yield } res = [ MultiJson.encode(res => res) ] if Fixnum === res or String === res @@ -31,10 +48,10 @@ end headers = env.select {|key, value| key.start_with?('HTTP_') }.inject({}) do |hash, (key, value)| hash[key.sub('HTTP_', '')] = value hash end - + envs.merge('params' => params, 'headers' => headers, 'rack.input' => env['rack.input'].string) end end end