summaryrefslogtreecommitdiff
path: root/test/support/assert_responses.rb
diff options
context:
space:
mode:
authorazul <azul@leap.se>2014-07-18 12:21:49 +0200
committerazul <azul@leap.se>2014-07-18 12:21:49 +0200
commitbbd41c9bfd2cb88a88d7436dd58a8b46a5d10cf1 (patch)
tree00b39da219151473437c02ce35344117bcd5b2fa /test/support/assert_responses.rb
parentade74d8a9091ae607586d7b287a0579a2ee7af8e (diff)
parent20352249fa5dafe3abb2d4b751b1e5c8c0a59abc (diff)
Merge pull request #180 from azul/feature/messages-api
Feature/messages api
Diffstat (limited to 'test/support/assert_responses.rb')
-rw-r--r--test/support/assert_responses.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/test/support/assert_responses.rb b/test/support/assert_responses.rb
index 1c9d49d..7724fb4 100644
--- a/test/support/assert_responses.rb
+++ b/test/support/assert_responses.rb
@@ -20,6 +20,22 @@ module AssertResponses
response
end
+ def response_content
+ json_response || get_response.body
+ end
+
+ def assert_success(message)
+ assert_response :success
+ assert_response_includes :success
+ assert_equal message.to_s, json_response[:success] if message.present?
+ end
+
+ def assert_not_found
+ assert_response :not_found
+ assert_response_includes :error
+ assert_equal 'not_found', json_response[:error]
+ end
+
def assert_text_response(body = nil)
assert_equal 'text/plain', content_type
unless body.nil?
@@ -45,8 +61,7 @@ module AssertResponses
# checks for the presence of a key in a json response
# or a string in a text response
def assert_response_includes(string_or_key)
- response = json_response || get_response.body
- assert response.include?(string_or_key),
+ assert response_content.include?(string_or_key),
"response should have included #{string_or_key}"
end