Sha256: b559050423c42e73ffddb7e73076a802b6ab97f763bacd062a26b47894306129

Contents?: true

Size: 640 Bytes

Versions: 6

Compression:

Stored size: 640 Bytes

Contents

RSpec.describe 'struct builder', '#call' do
  subject(:builder) { ROM::Repository::StructBuilder.new }

  let(:input) { [:users, [:id, :name]] }

  before { builder[*input] }

  it 'generates a struct for a given relation name and columns' do
    struct = builder.registry[input.hash]

    user = struct.new(id: 1, name: 'Jane')

    expect(user.id).to be(1)
    expect(user.name).to eql('Jane')

    expect(user[:id]).to be(1)
    expect(user[:name]).to eql('Jane')

    expect(Hash[user]).to eql(id: 1, name: 'Jane')
  end

  it 'stores struct in the registry' do
    expect(builder.registry[input.hash]).to be(builder[*input])
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rom-repository-0.2.0 spec/unit/struct_builder_spec.rb
rom-repository-0.2.0.rc1 spec/unit/struct_builder_spec.rb
rom-repository-0.2.0.beta1 spec/unit/struct_builder_spec.rb
rom-repository-0.1.0 spec/unit/struct_builder_spec.rb
rom-repository-0.0.2 spec/unit/struct_builder_spec.rb
rom-repository-0.0.1 spec/unit/struct_builder_spec.rb