Sha256: 2266dd336e3642c718224ef10aa821c37a880f0b59d24a36b88377b90472002a
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 KB
Contents
require 'test_helper' class UnnamespaceSingersController < ActionController::Base include Roar::Rails::ControllerAdditions respond_to :json, :xml def consume_json singer = consume!(Singer.new) render :text => singer.inspect end end class ConsumeTest < ActionController::TestCase include Roar::Rails::TestCase tests UnnamespaceSingersController test "#consume parses incoming document and updates the model" do post :consume_json, "{\"name\": \"Bumi\"}", :format => 'json' assert_equal %{#<struct Singer name="Bumi">}, @response.body end end class ConsumeWithConfigurationTest < ActionController::TestCase include Roar::Rails::TestCase module MusicianRepresenter include Roar::Representer::JSON property :name, :from => :called end class SingersController < ActionController::Base include Roar::Rails::ControllerAdditions respond_to :json represents :json, :entity => MusicianRepresenter def consume_json singer = consume!(Singer.new) render :text => singer.inspect end end tests SingersController test "#consume uses ConsumeWithConfigurationTest::MusicianRepresenter to parse incoming document" do post :consume_json, %{{"called":"Bumi"}}, :format => :json assert_equal %{#<struct Singer name="Bumi">}, @response.body end end class ConsumeWithOptionsOverridingConfigurationTest < ActionController::TestCase include Roar::Rails::TestCase class SingersController < ActionController::Base include Roar::Rails::ControllerAdditions represents :json, :entity => Object def consume_json singer = consume!(Singer.new, :represent_with => ::ConsumeWithConfigurationTest::MusicianRepresenter) render :text => singer.inspect end end tests SingersController 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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roar-rails-0.1.1 | test/consume_test.rb |
roar-rails-0.1.0 | test/consume_test.rb |