spec/integration/relations/registry_dsl_spec.rb in rom-0.9.1 vs spec/integration/relations/registry_dsl_spec.rb in rom-1.0.0.beta1
- old
+ new
@@ -1,28 +1,29 @@
require 'spec_helper'
describe 'Relation registration DSL' do
+ include_context 'container'
include_context 'users and tasks'
it 'allows to expose chainable relations' do
- setup.relation(:tasks) do
+ configuration.relation(:tasks) do
def high_priority
restrict { |tuple| tuple[:priority] < 2 }
end
def by_title(title)
restrict(title: title)
end
end
- setup.relation(:users) do
+ configuration.relation(:users) do
def with_tasks
join(tasks)
end
end
- tasks = rom.relations.tasks
+ tasks = container.relations.tasks
expect(tasks.class.name).to eql("ROM::Relation[Tasks]")
expect(tasks.high_priority.inspect).to include("#<ROM::Relation[Tasks]")
expect(tasks.high_priority.by_title("be nice")).to match_array(
@@ -31,10 +32,10 @@
expect(tasks.by_title("be cool")).to match_array(
[name: "Jane", title: "be cool", priority: 2]
)
- users = rom.relations.users
+ users = container.relations.users
expect(users.with_tasks).to match_array(
[{ name: "Joe", email: "joe@doe.org", title: "be nice", priority: 1 },
{ name: "Joe", email: "joe@doe.org", title: "sleep well", priority: 2 },
{ name: "Jane", email: "jane@doe.org", title: "be cool", priority: 2 }]