diff options
author | John Firebaugh <john_firebaugh@us.ibm.com> | 2010-11-23 19:21:48 -0800 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-12-19 22:39:21 +0100 |
commit | 916c25aeeeab6ef0f2375a6063fb36a43ed55346 (patch) | |
tree | 2364029e2b2c9d4ce6b56fb0487706d4d5001b14 /railties/test | |
parent | ab2bde45f8140a3ebf8b478e688ef612fc4181fc (diff) | |
download | rails-916c25aeeeab6ef0f2375a6063fb36a43ed55346.tar.gz rails-916c25aeeeab6ef0f2375a6063fb36a43ed55346.tar.bz2 rails-916c25aeeeab6ef0f2375a6063fb36a43ed55346.zip |
Use assert_body
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/railties/engine_test.rb | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 552a846330..8a003228b7 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -90,7 +90,7 @@ module RailtiesTest env = Rack::MockRequest.env_for("/bukkits") response = Rails.application.call(env) - assert_equal rack_body(["HELLO WORLD"]), rack_body(response[2]) + assert_body "HELLO WORLD", response end test "it provides routes as default endpoint" do @@ -117,7 +117,7 @@ module RailtiesTest env = Rack::MockRequest.env_for("/bukkits/foo") response = Rails.application.call(env) - assert_equal rack_body(["foo"]), rack_body(response[2]) + assert_body "foo", response end test "engine can load its own plugins" do @@ -293,23 +293,15 @@ module RailtiesTest env = Rack::MockRequest.env_for("/app.html") response = Rails.application.call(env) - assert_equal rack_body(response[2]), rack_body(File.open(File.join(app_path, "public/app.html"))) + assert_body File.read(File.join(app_path, "public/app.html")), response env = Rack::MockRequest.env_for("/bukkits/bukkits.html") response = Rails.application.call(env) - assert_equal rack_body(response[2]), rack_body(File.open(File.join(@plugin.path, "public/bukkits.html"))) + assert_body File.read(File.join(@plugin.path, "public/bukkits.html")), response env = Rack::MockRequest.env_for("/bukkits/file_from_app.html") response = Rails.application.call(env) - assert_equal rack_body(response[2]), rack_body(File.open(File.join(app_path, "public/bukkits/file_from_app.html"))) - end - - def rack_body(obj) - buffer = "" - obj.each do |part| - buffer << part - end - buffer + assert_body File.read(File.join(app_path, "public/bukkits/file_from_app.html")), response end test "shared engine should include application's helpers and own helpers" do @@ -357,17 +349,17 @@ module RailtiesTest env = Rack::MockRequest.env_for("/foo") response = Rails.application.call(env) - assert_equal rack_body(["Something... Something... Something..."]), rack_body(response[2]) + assert_body "Something... Something... Something...", response response[2].close env = Rack::MockRequest.env_for("/foo/show") response = Rails.application.call(env) - assert_equal rack_body(["/foo"]), rack_body(response[2]) + assert_body "/foo", response response[2].close env = Rack::MockRequest.env_for("/foo/bar") response = Rails.application.call(env) - assert_equal rack_body(["It's a bar."]), rack_body(response[2]) + assert_body "It's a bar.", response response[2].close end @@ -469,27 +461,27 @@ module RailtiesTest env = Rack::MockRequest.env_for("/bukkits/from_app") response = AppTemplate::Application.call(env) - assert_equal rack_body(["false"]), rack_body(response[2]) + assert_body "false", response response[2].close env = Rack::MockRequest.env_for("/bukkits/foo/show") response = AppTemplate::Application.call(env) - assert_equal rack_body(["/bukkits/foo"]), rack_body(response[2]) + assert_body "/bukkits/foo", response response[2].close env = Rack::MockRequest.env_for("/bukkits/foo") response = AppTemplate::Application.call(env) - assert_equal rack_body(["Helped."]), rack_body(response[2]) + assert_body "Helped.", response response[2].close env = Rack::MockRequest.env_for("/bukkits/routes_helpers_in_view") response = AppTemplate::Application.call(env) - assert_equal rack_body(["/bukkits/foo, /bar"]), rack_body(response[2]) + assert_body "/bukkits/foo, /bar", response response[2].close env = Rack::MockRequest.env_for("/bukkits/polymorphic_path_without_namespace") response = AppTemplate::Application.call(env) - assert_equal rack_body(["/bukkits/posts/1"]), rack_body(response[2]) + assert_body "/bukkits/posts/1", response response[2].close end @@ -551,7 +543,7 @@ module RailtiesTest env = Rack::MockRequest.env_for("/bukkits/posts/new") response = AppTemplate::Application.call(env) - assert rack_body(response[2]) =~ /name="post\[title\]"/ + assert extract_body(response) =~ /name="post\[title\]"/ end test "loading seed data" do |