Sha256: 3e8f4731983075de690e87f79732a798c32ce93a467a59a79e0cb2b56f8bacc2

Contents?: true

Size: 689 Bytes

Versions: 3

Compression:

Stored size: 689 Bytes

Contents

require "spec_helper"

describe Rexpense::Entities::Base do

  class DummyEntity < Rexpense::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

3 entries across 3 versions & 1 rubygems

Version Path
rexpense-2.1.0 spec/lib/rexpense/entities/base_spec.rb
rexpense-2.0.0 spec/lib/rexpense/entities/base_spec.rb
rexpense-1.0.0 spec/lib/rexpense/entities/base_spec.rb