Sha256: f163ea068d65635f42fde26339084feaf8824f1ad246cc095417e56a1513a32e

Contents?: true

Size: 682 Bytes

Versions: 5

Compression:

Stored size: 682 Bytes

Contents

require "spec_helper"

describe Emites::Entities::Base do

  class DummyEntity < Emites::Entities::Base
    attribute :property_1, String
    attribute :property_2, String
  end

  let(:hash) { {property_1: 1, property_2: 2} }
  subject    { DummyEntity.new(hash) }

  it "builds an object from a hash" do
    expect(subject).to respond_to(:property_1)
    expect(subject).to respond_to(:property_2)
    expect(subject.property_1).to eq("1")
    expect(subject.property_2).to eq("2")
  end

  describe "#attributes" do
    it "returns a hash from object attributes" do
      expect(subject.to_hash).to eq({
        property_1: "1",
        property_2: "2"
      })
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
emites-client-0.1.1 spec/emites/entities/base_spec.rb
emites-client-0.1.0 spec/emites/entities/base_spec.rb
emites-client-0.0.4 spec/emites/entities/base_spec.rb
emites-client-0.0.3 spec/emites/entities/base_spec.rb
emites-client-0.0.2 spec/emites/entities/base_spec.rb