Skip to content

Commit

Permalink
Re-add oops states test.
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenk committed Dec 15, 2014
1 parent 407f3d6 commit b8f1e28
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions spec/lib/oops_request/states_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'spec_helper'

describe 'OopsRequest::States' do
let(:request) { create :oops_request }
before { allow(request).to receive(:execute_and_save) }

it 'have state pending' do
expect(request.state).to eq('pending')
end

context 'with an error' do
let(:message) { 'error from stub' }
before do
allow(request).to receive(:execute_and_save).
and_raise(Oops::Error, message)
begin
request.run
rescue Oops::Error
end
end

it 'have state failed' do
expect(request.state).to eq('failed')
end

it 'have the error message' do
expect(request.last_error).to eq(message)
end
end

context 'without an error' do
before { request.run }

it 'have state done' do
expect(request.state).to eq('done')
end

it 'have no error' do
expect(request.last_error).to be_nil
end
end
end

0 comments on commit b8f1e28

Please sign in to comment.