summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-26 11:54:11 +0100
committerAzul <azul@leap.se>2012-11-26 11:54:11 +0100
commit595518684b9c4364f96c97a84cc481b5ae0da981 (patch)
treeee5aafd33cf90f4c2d099d364f6da1d6f7331024 /core
parentce0999ead0d61db1f6534ee9d8114c4551542e80 (diff)
simplified controller and adjusted tests
Also added #assert_json_error to tests.
Diffstat (limited to 'core')
-rw-r--r--core/lib/extensions/testing.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/core/lib/extensions/testing.rb b/core/lib/extensions/testing.rb
index 86a059f..925c023 100644
--- a/core/lib/extensions/testing.rb
+++ b/core/lib/extensions/testing.rb
@@ -15,10 +15,18 @@ module LeapWebCore
end
def assert_json_response(object)
- object.stringify_keys! if object.respond_to? :stringify_keys!
- assert_equal object, JSON.parse(get_response.body)
+ if object.is_a? Hash
+ object.stringify_keys! if object.respond_to? :stringify_keys!
+ assert_equal object, JSON.parse(get_response.body)
+ else
+ assert_equal object.to_json, get_response.body
+ end
end
+ def assert_json_error(object)
+ object.stringify_keys! if object.respond_to? :stringify_keys!
+ assert_json_response :errors => object
+ end
end
end