Sha256: ec44846561119503addd12e4dac968e5759a0c91bd9e9284f04fbecc0197b225
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
require 'spec_helper' describe 'Commands / Delete' do include_context 'container' include_context 'users and tasks' subject(:users) { container.commands.users } before do configuration.relation(:users) do def by_name(name) restrict(name: name) end end end it 'deletes all tuples when there is no restriction' do configuration.commands(:users) do define(:delete) end result = users.try { users.delete.call } expect(result).to match_array([ { name: 'Jane', email: 'jane@doe.org' }, { name: 'Joe', email: 'joe@doe.org' } ]) expect(container.relation(:users)).to match_array([]) end it 'deletes tuples matching restriction' do configuration.commands(:users) do define(:delete) end result = users.try { users.delete.by_name('Joe').call } expect(result).to match_array([{ name: 'Joe', email: 'joe@doe.org' }]) expect(container.relation(:users)).to match_array([ { name: 'Jane', email: 'jane@doe.org' } ]) end it 'returns untouched relation if there are no tuples to delete' do configuration.commands(:users) do define(:delete) end result = users.try { users.delete.by_name('Not here').call } expect(result).to match_array([]) end it 'returns deleted tuple when result is set to :one' do configuration.commands(:users) do define(:delete_one, type: :delete) do result :one end end result = users.try { users.delete_one.by_name('Jane').call } expect(result.value).to eql(name: 'Jane', email: 'jane@doe.org') end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rom-2.0.2 | spec/integration/commands/delete_spec.rb |
rom-2.0.1 | spec/integration/commands/delete_spec.rb |
rom-2.0.0 | spec/integration/commands/delete_spec.rb |