summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-06 11:51:10 +0100
committerAzul <azul@leap.se>2012-11-06 11:51:10 +0100
commitda2804c8f8a800851fa1863f579e2b8e9a57b4cc (patch)
treeaa3dc8b9eb1741870e7f98e9c1c71a626c2979da /core
parentef90c45998b33ba8606c3786875e21496ace4686 (diff)
first steps towards warden srp testing
Diffstat (limited to 'core')
-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