Sha256: 1ab9387a490b85ccb26bdec362755c533ea93f48dbae3db51f363d1099b626e0
Contents?: true
Size: 1.06 KB
Versions: 4
Compression:
Stored size: 1.06 KB
Contents
require 'spec_helper' describe 'Group operation' do include_context 'users and tasks' specify 'defining a grouped relation' do setup.relation(:users) do def with_tasks in_memory { group(join(tasks), tasks: [:title, :priority]) } end def by_name(name) restrict(name: name) end end users = rom.relations.users expect(users.with_tasks.to_a).to eql( [ { name: "Joe", email: "joe@doe.org", tasks: [ { title: "be nice", priority: 1 }, { title: "sleep well", priority: 2 } ] }, { name: "Jane", email: "jane@doe.org", tasks: [{ title: "be cool", priority: 2 }] } ] ) expect(users.with_tasks.by_name("Jane").to_a).to eql( [ { name: "Jane", email: "jane@doe.org", tasks: [{ title: "be cool", priority: 2 }] } ] ) expect(users.by_name("Jane").with_tasks.to_a).to eql( [ { name: "Jane", email: "jane@doe.org", tasks: [{ title: "be cool", priority: 2 }] } ] ) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rom-0.4.1 | spec/integration/ra/group_spec.rb |
rom-0.4.0 | spec/integration/ra/group_spec.rb |
rom-0.3.1 | spec/integration/ra/group_spec.rb |
rom-0.3.0 | spec/integration/ra/group_spec.rb |