Sha256: d354b1858359612f5f9844ddf89bcc380e98b0bdad6761563d165ca879f67c2f

Contents?: true

Size: 662 Bytes

Versions: 1

Compression:

Stored size: 662 Bytes

Contents

require 'test_helper'

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

  class SingersController < ActionController::Base
    module SingerRepresenter
      include Roar::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-1.0.0 test/render_test.rb