Sha256: 32f741efc589168cb0dfc4221a0f20ac07e78cb0cba32ad363bbcb3a2221c8f7

Contents?: true

Size: 981 Bytes

Versions: 7

Compression:

Stored size: 981 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 AttributesContructor
        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

7 entries across 7 versions & 1 rubygems

Version Path
roar-0.11.4 test/representer_test.rb
roar-0.11.3 test/representer_test.rb
roar-0.11.2 test/representer_test.rb
roar-0.11.1 test/representer_test.rb
roar-0.11.0 test/representer_test.rb
roar-0.10.2 test/representer_test.rb
roar-0.10.1 test/representer_test.rb