Sha256: 0cdc2e3bb109a1c42a8a18315cf17d6b3a77e6344b3afcc6db66602e1013c248

Contents?: true

Size: 1016 Bytes

Versions: 3

Compression:

Stored size: 1016 Bytes

Contents

require 'spec_helper'

describe QuickbooksWebConnector::Job do

  describe '.queued' do
    it 'returns all queued jobs' do
      expect(described_class.queued.size).to be(0)

      described_class.create(SomeBuilder, SomeHandler, 12)
      described_class.create(SomeBuilder, SomeHandler, 31)

      expect(described_class.queued.size).to eq(2)
    end
  end

  it 'becomes a failure if building the request XML raises an exception' do
    allow(SomeBuilder).to receive(:perform).and_raise(Exception)
    job = described_class.new 'request_builder_class' => 'SomeBuilder'

    expect(job.request_xml).to eq(:failed)

    expect(QuickbooksWebConnector::Failure.count).to be(1)
  end

  it 'becomes a failure if handling the response raises an exception' do
    allow(SomeHandler).to receive(:perform).and_raise(Exception)
    job = described_class.new 'response_handler_class' => 'SomeHandler'

    expect { job.perform }.to_not raise_exception

    expect(QuickbooksWebConnector::Failure.count).to be(1)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
quickbooks_web_connector-0.7.0 spec/lib/quickbooks_web_connector/job_spec.rb
quickbooks_web_connector-0.6.3 spec/lib/quickbooks_web_connector/job_spec.rb
quickbooks_web_connector-0.6.2 spec/lib/quickbooks_web_connector/job_spec.rb