Sha256: 6ad52a1e53d4bb11428b15ed093e70252287aa233e13617f6b79880077950c07

Contents?: true

Size: 960 Bytes

Versions: 25

Compression:

Stored size: 960 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::Representer::JSON
        property :name
      end

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

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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
roar-0.12.9 test/representer_test.rb
roar-0.12.8 test/representer_test.rb
roar-0.12.7 test/representer_test.rb
roar-0.12.6 test/representer_test.rb
roar-0.12.5 test/representer_test.rb
roar-0.12.4 test/representer_test.rb
roar-0.12.3 test/representer_test.rb
roar-0.12.2 test/representer_test.rb
roar-0.12.1 test/representer_test.rb
roar-0.12.0 test/representer_test.rb
roar-0.11.19 test/representer_test.rb
roar-0.11.18 test/representer_test.rb
roar-0.11.17 test/representer_test.rb
roar-0.11.16 test/representer_test.rb
roar-0.11.15 test/representer_test.rb
roar-0.11.14 test/representer_test.rb
roar-0.11.13 test/representer_test.rb
roar-0.11.12 test/representer_test.rb
roar-0.11.11 test/representer_test.rb
roar-0.11.10 test/representer_test.rb