Sha256: 8cbab2d4e22dd33889d72d8b8d77fa7b6e33d6f7e487465142ae75ae73640645

Contents?: true

Size: 934 Bytes

Versions: 11

Compression:

Stored size: 934 Bytes

Contents

require 'test_helper'

class RepresenterTest < MiniTest::Spec
  describe "Representer" do
    before do
      @c = Class.new do
        include Roar::Representer
      end
    end

    it "aliases #representable_property to #property" do
      @c.property :title
      assert_equal "title", @c.representable_attrs.first.name
    end

    it "aliases #representable_collection to #collection" do
      @c.collection :songs
      assert_equal "songs", @c.representable_attrs.first.name
    end
  end

  describe "Inheritance" do
    it "properly inherits properties from modules" do
      module PersonRepresentation
        include Roar::JSON
        property :name
      end

      class Person
        include AttributesConstructor
        include Roar::JSON
        include PersonRepresentation
        attr_accessor :name
      end

      assert_equal "{\"name\":\"Paulo\"}", Person.new(:name => "Paulo").to_json
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/roar-1.2.0/test/representer_test.rb
roar-1.2.0 test/representer_test.rb
roar-1.1.1 test/representer_test.rb
roar-1.1.0 test/representer_test.rb
roar-1.0.4 test/representer_test.rb
roar-1.0.3 test/representer_test.rb
roar-1.0.2 test/representer_test.rb
roar-1.0.1 test/representer_test.rb
roar-1.0.0 test/representer_test.rb
roar-1.0.0.beta2 test/representer_test.rb
roar-1.0.0.beta1 test/representer_test.rb