1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

added test for issue #19

This commit is contained in:
Thorsten Böttger 2011-09-16 17:12:10 +02:00
parent 3458f17f06
commit dc4abd783f
2 changed files with 27 additions and 2 deletions

View file

@ -54,3 +54,14 @@ class Banker
def initialize(balance = 0); self.balance = balance; end
def rich?; self.balance >= RICH; end
end
class Argument
include AASM
aasm_initial_state :invalid
aasm_state :invalid
aasm_state :valid
aasm_event :valid do
transitions :to => :valid, :from => [:invalid]
end
end

View file

@ -27,6 +27,20 @@ describe AASM, '- class level definitions' do
end
describe "naming" do
it "work for valid" do
Argument.aasm_states.should include(:invalid)
Argument.aasm_states.should include(:valid)
argument = Argument.new
argument.invalid?.should be_true
argument.aasm_current_state.should == :invalid
argument.valid!
argument.valid?.should be_true
argument.aasm_current_state.should == :valid
end
end
describe AASM, '- subclassing' do
it 'should have the parent states' do
@ -235,10 +249,10 @@ describe AASM, '- event callbacks' do
@foo.stub!(:enter).and_raise(StandardError)
lambda{@foo.safe_close!}.should raise_error(NoMethodError)
end
it "should propagate an error if no error callback is declared" do
@foo.stub!(:enter).and_raise("Cannot enter safe")
lambda{@foo.close!}.should raise_error(StandardError, "Cannot enter safe")
lambda{@foo.close!}.should raise_error(StandardError, "Cannot enter safe")
end
end