summaryrefslogtreecommitdiff
path: root/core/lib/extensions/testing.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-12 19:16:55 +0100
committerAzul <azul@leap.se>2012-11-12 19:16:55 +0100
commitc886cc17b6f37ddd556e70fe2d76a3ea28db52bf (patch)
treee27fe040bfaba5840730f466d4c6f90213759d5e /core/lib/extensions/testing.rb
parentca2e1b9f379ccba068ad0ebb852d855f1639cd3a (diff)
parent5b300b554682c232c0955bdb0dd3d8263dde901e (diff)
Merge branch 'feature-warden-srp' into develop
Diffstat (limited to 'core/lib/extensions/testing.rb')
-rw-r--r--core/lib/extensions/testing.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/core/lib/extensions/testing.rb b/core/lib/extensions/testing.rb
index 14a5698..86a059f 100644
--- a/core/lib/extensions/testing.rb
+++ b/core/lib/extensions/testing.rb
@@ -1,15 +1,22 @@
module LeapWebCore
module AssertResponses
+ # response that works with different TestCases:
+ # ActionController::TestCase has @response
+ # ActionDispatch::IntegrationTest has @response
+ # Rack::Test::Methods defines last_response
+ def get_response
+ @response || last_response
+ end
+
def assert_attachement_filename(name)
assert_equal %Q(attachment; filename="#{name}"),
- @response.headers["Content-Disposition"]
+ get_response.headers["Content-Disposition"]
end
-
def assert_json_response(object)
object.stringify_keys! if object.respond_to? :stringify_keys!
- assert_equal object, JSON.parse(@response.body)
+ assert_equal object, JSON.parse(get_response.body)
end
end