Sha256: db1a6e8513d12615bd7e7fe8bfff5421e4a3bfe4506526250a0881317b646459

Contents?: true

Size: 776 Bytes

Versions: 1

Compression:

Stored size: 776 Bytes

Contents

require 'gecko'

class Gecko::Helpers::SerializationHelperTest < Minitest::Test
  def setup
    @klass = Class.new(Gecko::Record::Base) do
      attribute :name,   String
      attribute :secret, String, readonly: true

      def root
        :widget
      end
    end
    @client = Gecko::Client.new('ABC', 'DEF')
  end

  def test_serializable_hash
    record = @klass.new(@client, name: "Gecko", secret: "Iguana")
    assert_equal({name: "Gecko"}, record.serializable_hash)
  end

  def test_as_json
    record = @klass.new(@client, name: "Gecko", secret: "Iguana")
    assert_equal({widget: {name: "Gecko"}}, record.as_json)
  end

  def test_root_key
    record = Gecko::Record::OrderLineItem.new(@client, @json)
    assert_equal(:order_line_item, record.root)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gecko-ruby-0.0.4 test/helpers/serialization_helper_test.rb