Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding riot macro for returning an assertion around the rack response

  • Loading branch information...
commit ae32058fa1f1cd6d2e5c7d2590e63491421c4bc2 1 parent eeb06f2
@gus gus authored
View
1  .gitignore
@@ -1 +1,2 @@
*.gem
+*.tmproj
View
8 lib/chicago/riot/macros.rb
@@ -3,6 +3,14 @@
module Chicago
module Riot
module Macros
+ def asserts_response(method=nil)
+ if method
+ asserts("response #{method}") { last_response.send(method) }
+ else
+ asserts("response") { last_response }
+ end
+ end
+
def asserts_response_status(expected)
asserts("response status is #{expected}") { last_response.status }.equals(expected)
end
View
9 test/riot_macros_test.rb
@@ -40,4 +40,13 @@
asserts_json_response("text/javascript;charset=utf-8") { {:foo => bar_value}.to_json }
end # with content expectation provided as block
end # json response
+
+ context "response body" do
+ context "with a block for the expected value" do
+ setup { get('/basic-json') }
+ asserts_response(:body).equals do
+ {:foo => "bar"}.to_json
+ end
+ end # with a block for the expected value
+ end # response body
end
Please sign in to comment.
Something went wrong with that request. Please try again.