Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding riot macro for returning an assertion around the rack response

  • Loading branch information...
commit ae32058fa1f1cd6d2e5c7d2590e63491421c4bc2 1 parent eeb06f2
Justin Knowlden authored May 17, 2010
1  .gitignore
... ...
@@ -1 +1,2 @@
1 1
 *.gem
  2
+*.tmproj
8  lib/chicago/riot/macros.rb
@@ -3,6 +3,14 @@
3 3
 module Chicago
4 4
   module Riot
5 5
     module Macros
  6
+      def asserts_response(method=nil)
  7
+        if method
  8
+          asserts("response #{method}") { last_response.send(method) }
  9
+        else
  10
+          asserts("response") { last_response }
  11
+        end
  12
+      end
  13
+
6 14
       def asserts_response_status(expected)
7 15
         asserts("response status is #{expected}") { last_response.status }.equals(expected)
8 16
       end
9  test/riot_macros_test.rb
@@ -40,4 +40,13 @@
40 40
       asserts_json_response("text/javascript;charset=utf-8") { {:foo => bar_value}.to_json }
41 41
     end # with content expectation provided as block
42 42
   end # json response
  43
+
  44
+  context "response body" do
  45
+    context "with a block for the expected value" do
  46
+      setup { get('/basic-json') }
  47
+      asserts_response(:body).equals do
  48
+        {:foo => "bar"}.to_json
  49
+      end
  50
+    end # with a block for the expected value
  51
+  end # response body
43 52
 end

0 notes on commit ae32058

Please sign in to comment.
Something went wrong with that request. Please try again.