Sha256: 2b037f74c4f2e1f84ed1894ac2e8e75624383145727481939399b81215757fb5

Contents?: true

Size: 792 Bytes

Versions: 3

Compression:

Stored size: 792 Bytes

Contents

require 'spec_helper'

describe 'Wrap operation' do
  include_context 'users and tasks'

  subject(:rom) { setup.finalize }

  specify 'defining a wrapped relation' do
    setup.relation(:users) do
      def with_task
        in_memory { wrap(join(tasks), task: [:title, :priority]) }
      end
    end

    users = rom.relations.users

    expect(users.with_task.to_a).to eql(
      [
        {
          name: "Joe",
          email: "joe@doe.org",
          task: { title: "be nice", priority: 1 }
        },
        {
          name: "Joe",
          email: "joe@doe.org",
          task: { title: "sleep well", priority: 2 }
        },
        {
          name: "Jane",
          email: "jane@doe.org",
          task: { title: "be cool", priority: 2 }
        }
      ]
    )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-0.4.0 spec/integration/ra/wrap_spec.rb
rom-0.3.1 spec/integration/ra/wrap_spec.rb
rom-0.3.0 spec/integration/ra/wrap_spec.rb