Sha256: e2d25890f0c7204d7b1c52b9f1b5721ac44ab6be4c181d57bc788ac29a804b6e

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

Contents

require 'test_helper'

class RenderTest < ActionController::TestCase
  include Roar::Rails::TestCase

  class SingersController < ActionController::Base
    module SingerRepresenter
      include Roar::Representer::JSON

      property :name, :as => :title
    end

    include Roar::Rails::ControllerAdditions
    include Roar::Rails::ControllerAdditions::Render

    represents :json, :entity => SingerRepresenter

    def show
      singer = Musician.new("Bumi")
      render :json => singer
    end
  end

  tests SingersController

  test "should use Representer for #render" do
    get :show, :id => "bumi", :format => :json
    assert_body '{"title":"Bumi"}'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roar-rails-0.1.6 test/render_test.rb