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.11.9 test/representer_test.rb
roar-0.11.8 test/representer_test.rb
roar-0.11.7 test/representer_test.rb
roar-0.11.6 test/representer_test.rb
roar-0.11.5 test/representer_test.rb