require 'spec_helper'

describe 'Commands / Delete' do
  include_context 'users and tasks'

  subject(:users) { rom.commands.users }

  before do
    setup.relation(:users) do
      def by_name(name)
        where(name: name)
      end
    end

    setup.commands(:users) do
      define(:delete)
    end

    rom.relations.users.insert(id: 2, name: 'Jane')
  end

  it 'deletes all tuples' do
    result = users.try { delete }

    expect(result.value.to_a)
      .to match_array([{ id: 1, name: 'Piotr' }, { id: 2, name: 'Jane' }])
  end

  it 'deletes all tuples in a restricted relation' do
    result = users.try { delete(:by_name, 'Jane').execute }

    expect(result.value).to match_array([{ id: 2, name: 'Jane' }])
  end
end

require 'spec_helper'

describe 'Commands / Delete' do
  include_context 'users and tasks'

  subject(:users) { rom.commands.users }

  before do
    setup.relation(:users) do
      def by_name(name)
        where(name: name)
      end
    end

    setup.commands(:users) do
      define(:delete)
    end

    rom.relations.users.insert(id: 2, name: 'Jane')
  end

  it 'deletes all tuples' do
    result = users.try { delete }

    expect(result.value.to_a)
      .to match_array([{ id: 1, name: 'Piotr' }, { id: 2, name: 'Jane' }])
  end

  it 'deletes all tuples in a restricted relation' do
    result = users.try { delete(:by_name, 'Jane') }

    expect(result.value).to match_array([{ id: 2, name: 'Jane' }])
  end
end

Update spec to pass on rom 0.5.0
Update spec to pass on rom 0.5.0
