Sha256: ad7434de9144b2d26c54a3b23284637548bd3fc311d8b08a52e9862c05950da4

Contents?: true

Size: 898 Bytes

Versions: 6

Compression:

Stored size: 898 Bytes

Contents

require 'test_helper'

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

  class SingersController < ActionController::Base
    module HalSingerRepresenter
      include Roar::JSON::HAL

      property :name
      link(:self) { "http://#{name}" }
    end

    include Roar::Rails::ControllerAdditions
    represents :hal, :entity => HalSingerRepresenter

    def show
      singer = Musician.new("Bumi")
      respond_with singer
    end
  end

  tests SingersController

  test "should render correctly in response to a application/hal+json request" do
    get :show, :id => "bumi", :format => :hal
    assert_body '{"name":"Bumi","_links":{"self":{"href":"http://Bumi"}}}'
  end

  test "should have a content_type of application/hal+json" do
    get :show, :id => "bumi", :format => :hal
    assert_equal response.content_type, 'application/hal+json'
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/roar-rails-1.2.0/test/json_hal_renderer_test.rb
roar-rails-1.2.0 test/json_hal_renderer_test.rb
roar-rails-1.1.0 test/json_hal_renderer_test.rb
roar-rails-1.0.2 test/json_hal_renderer_test.rb
roar-rails-1.0.1 test/json_hal_renderer_test.rb
roar-rails-1.0.0 test/json_hal_renderer_test.rb