2015-12-18 13:27:42 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-12-18 17:36:48 -05:00
|
|
|
describe 'Custom AASM::Base' do
|
|
|
|
context 'when aasm_with invoked with SimpleCustomExample' do
|
|
|
|
let(:simple_custom) { SimpleCustomExample.new }
|
2015-12-18 13:27:42 -05:00
|
|
|
|
2015-12-18 17:36:48 -05:00
|
|
|
subject do
|
|
|
|
simple_custom.fill_out!
|
|
|
|
simple_custom.authorise
|
|
|
|
end
|
2015-12-18 13:27:42 -05:00
|
|
|
|
2015-12-18 17:36:48 -05:00
|
|
|
it 'has invoked authorizable?' do
|
|
|
|
expect { subject }.to change { simple_custom.authorizable_called }.from(nil).to(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has invoked fillable?' do
|
|
|
|
expect { subject }.to change { simple_custom.fillable_called }.from(nil).to(true)
|
|
|
|
end
|
2015-12-18 13:27:42 -05:00
|
|
|
|
2015-12-18 17:36:48 -05:00
|
|
|
it 'has two transition counts' do
|
|
|
|
expect { subject }.to change { simple_custom.transition_count }.from(nil).to(2)
|
|
|
|
end
|
2015-12-18 13:27:42 -05:00
|
|
|
end
|
|
|
|
|
2015-12-18 17:36:48 -05:00
|
|
|
context 'when aasm_with invoked with non AASM::Base' do
|
|
|
|
subject do
|
|
|
|
class SomeModel
|
|
|
|
include AASM
|
|
|
|
|
|
|
|
aasm_with String do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should raise an ArgumentError' do
|
|
|
|
expect { subject }.to raise_error(ArgumentError, 'The class String must inherit from AASM::Base!')
|
|
|
|
end
|
2015-12-18 13:27:42 -05:00
|
|
|
end
|
|
|
|
end
|