Skip to content

Commit

Permalink
fills in specs for improv performances
Browse files Browse the repository at this point in the history
  • Loading branch information
markrebec committed May 27, 2015
1 parent c73646a commit e0ec801
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions spec/transactor/improv/performance_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
require 'spec_helper'

RSpec.describe Transactor::Improv::Performance do
subject { Transactor::Improv::Performance.new(Transactor::Improv::Actor, test_one: 'one', test_two: 2) }

describe '#perform' do
it 'returns self' do
expect(subject.perform).to eql(subject)
end

context 'when passed a block' do
it 'stores the block to be called later' do
dummy_proc = Proc.new { nil }
subject.perform &dummy_proc
expect(subject.perform_block).to eql(dummy_proc)
end
end

context 'when not passed a block' do
context 'when a block was stored previously' do
it 'executes the stored block' do
subject.perform { @dummy_proc_executed = true }
subject.perform
expect(subject.actor.instance_variable_get(:@dummy_proc_executed)).to be_true
end
end

context 'when no block was stored previously' do
it 'executes a noop proc' do
expect { subject.perform }.to_not raise_exception
end
end
end
end

describe '#rollback' do
it 'returns self' do
expect(subject.rollback).to eql(subject)
end

context 'when passed a block' do
it 'stores the block to be called later' do
dummy_proc = Proc.new { nil }
subject.rollback &dummy_proc
expect(subject.rollback_block).to eql(dummy_proc)
end
end

context 'when not passed a block' do
context 'when a block was stored previously' do
it 'executes the stored block' do
subject.rollback { @dummy_proc_executed = true }
subject.rollback
expect(subject.actor.instance_variable_get(:@dummy_proc_executed)).to be_true
end
end

context 'when no block was stored previously' do
it 'executes a noop proc' do
expect { subject.rollback }.to_not raise_exception
end
end
end
end
end

0 comments on commit e0ec801

Please sign in to comment.