aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_unit.rb13
-rw-r--r--actionpack/test/controller/caching_test.rb9
-rw-r--r--actionpack/test/controller/mime_responds_test.rb2
-rw-r--r--actionpack/test/controller/new_base/metal_test.rb6
-rw-r--r--actionpack/test/controller/new_base/middleware_test.rb2
5 files changed, 25 insertions, 7 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index a3486aa039..5b2ff3e871 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -44,6 +44,19 @@ ORIGINAL_LOCALES = I18n.available_locales.map {|locale| locale.to_s }.sort
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
+module RackTestUtils
+ def body_to_string(body)
+ if body.respond_to?(:each)
+ str = ""
+ body.each {|s| str << s }
+ str
+ else
+ body
+ end
+ end
+ extend self
+end
+
module SetupOnce
extend ActiveSupport::Concern
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 5157454be0..f0ad652d50 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -285,6 +285,8 @@ class ActionCacheTest < ActionController::TestCase
assert_not_equal cached_time, @response.body
end
+ include RackTestUtils
+
def test_action_cache_with_layout
get :with_layout
cached_time = content_to_cache
@@ -294,8 +296,8 @@ class ActionCacheTest < ActionController::TestCase
get :with_layout
assert_not_equal cached_time, @response.body
-
- assert_equal @response.body, read_fragment('hostname.com/action_caching_test/with_layout')
+ body = body_to_string(read_fragment('hostname.com/action_caching_test/with_layout'))
+ assert_equal @response.body, body
end
def test_action_cache_with_layout_and_layout_cache_false
@@ -308,7 +310,8 @@ class ActionCacheTest < ActionController::TestCase
get :layout_false
assert_not_equal cached_time, @response.body
- assert_equal cached_time, read_fragment('hostname.com/action_caching_test/layout_false')
+ body = body_to_string(read_fragment('hostname.com/action_caching_test/layout_false'))
+ assert_equal cached_time, body
end
def test_action_cache_conditional_options
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 5c1eaf453c..53cd3f0801 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -765,7 +765,7 @@ class RespondWithControllerTest < ActionController::TestCase
Customer.any_instance.stubs(:errors).returns(errors)
post :using_resource_with_action
- assert_equal "foo - #{[:html].to_s}", @controller.response_body
+ assert_equal "foo - #{[:html].to_s}", @controller.response.body
end
def test_respond_as_responder_entry_point
diff --git a/actionpack/test/controller/new_base/metal_test.rb b/actionpack/test/controller/new_base/metal_test.rb
index ab61fd98ee..45a6619eb4 100644
--- a/actionpack/test/controller/new_base/metal_test.rb
+++ b/actionpack/test/controller/new_base/metal_test.rb
@@ -18,6 +18,8 @@ module MetalTest
end
class TestMiddleware < ActiveSupport::TestCase
+ include RackTestUtils
+
def setup
@app = Rack::Builder.new do
use MetalTest::MetalMiddleware
@@ -29,14 +31,14 @@ module MetalTest
env = Rack::MockRequest.env_for("/authed")
response = @app.call(env)
- assert_equal "Hello World", response[2]
+ assert_equal "Hello World", body_to_string(response[2])
end
test "it can return a response using the normal AC::Metal techniques" do
env = Rack::MockRequest.env_for("/")
response = @app.call(env)
- assert_equal "Not authed!", response[2]
+ assert_equal "Not authed!", body_to_string(response[2])
assert_equal 401, response[0]
end
end
diff --git a/actionpack/test/controller/new_base/middleware_test.rb b/actionpack/test/controller/new_base/middleware_test.rb
index ada0215b1a..65942ebc15 100644
--- a/actionpack/test/controller/new_base/middleware_test.rb
+++ b/actionpack/test/controller/new_base/middleware_test.rb
@@ -44,7 +44,7 @@ module MiddlewareTest
test "middleware that is 'use'd is called as part of the Rack application" do
result = @app.call(env_for("/"))
- assert_equal "Hello World", result[2]
+ assert_equal "Hello World", RackTestUtils.body_to_string(result[2])
assert_equal "Success", result[1]["Middleware-Test"]
end