require 'rails_helper'

describe Dunlop::Loggable do
  let(:model) { ExecutionBatch::MyBatch }

  it "handles failures" do
    expect_any_instance_of(model).to receive(:process_steps).and_raise "Oh no!"
    record = model.execute!
    record.should     have_log_entries "ERROR - Oh no!"
    record.should_not have_log_entries "and_raise"
    log_entry = record.log_entries.last
    log_entry.backtrace.should include "and_raise"
  end

end
