Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use assert_body #136

Closed
wants to merge 1 commit into from

1 participant

@jfirebaugh

Cleans up tests a bit.

John Firebaugh Use assert_body 166c8be
@jfirebaugh

Committed in 916c25a

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 19, 2010
  1. Use assert_body

    John Firebaugh authored
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 22 deletions.
  1. +14 −22 railties/test/railties/engine_test.rb
View
36 railties/test/railties/engine_test.rb
@@ -90,7 +90,7 @@ class Engine < ::Rails::Engine
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 @@ class Engine < ::Rails::Engine
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 @@ class Engine < ::Rails::Engine
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 @@ def bar
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 @@ class MyMailer < ActionMailer::Base
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 @@ def new
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
Something went wrong with that request. Please try again.