test/consume_test.rb in roar-rails-0.1.1 vs test/consume_test.rb in roar-rails-0.1.2
- old
+ new
@@ -68,5 +68,22 @@
test "#consume uses #represents config to parse incoming document" do
post :consume_json, %{{"called":"Bumi"}}, :format => :json
assert_equal %{#<struct Singer name="Bumi">}, @response.body
end
end
+
+class RequestBodyStringTest < ConsumeTest
+ test "allows Request instances supporting #string instead of #read" do
+ @request.instance_eval do
+ def body
+ Object.new.instance_eval do
+ def read; ""; end
+ def string; "{\"name\": \"Bumi\"}"; end # in rails 4, for whatever reasons, #read doesn't work as expected.
+
+ self
+ end
+ end
+ end
+ post :consume_json, "{\"name\": \"Bumi\"}", :format => 'json'
+ assert_equal %{#<struct Singer name="Bumi">}, @response.body
+ end
+end