Sha256: f9dc5dc66940afc09df871e1c3ab8dd4e2126be4438d2cb14895f06d8c83c01e

Contents?: true

Size: 594 Bytes

Versions: 3

Compression:

Stored size: 594 Bytes

Contents

require 'spec_helper'

describe 'Commands / Error handling'  do
  include_context 'users and tasks'

  before do
    setup.relation(:users)
    setup.commands(:users) { define(:create) }
  end

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

  it 'rescues from ROM::CommandError' do
    result = false
    expect(users.try { raise ROM::CommandError } >-> test { result = true }).
      to be_instance_of(ROM::Result::Failure)
    expect(result).to be(false)
  end

  it 'raises other errors' do
    expect { users.try { raise ArgumentError, 'test' } }.to raise_error(ArgumentError, 'test')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-0.4.2 spec/integration/commands/error_handling_spec.rb
rom-0.4.1 spec/integration/commands/error_handling_spec.rb
rom-0.4.0 spec/integration/commands/error_handling_spec.rb