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:
parent
3458f17f06
commit
dc4abd783f
2 changed files with 27 additions and 2 deletions
|
@ -54,3 +54,14 @@ class Banker
|
||||||
def initialize(balance = 0); self.balance = balance; end
|
def initialize(balance = 0); self.balance = balance; end
|
||||||
def rich?; self.balance >= RICH; end
|
def rich?; self.balance >= RICH; end
|
||||||
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
|
||||||
|
|
|
@ -27,6 +27,20 @@ describe AASM, '- class level definitions' do
|
||||||
|
|
||||||
end
|
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
|
describe AASM, '- subclassing' do
|
||||||
it 'should have the parent states' do
|
it 'should have the parent states' do
|
||||||
|
@ -235,10 +249,10 @@ describe AASM, '- event callbacks' do
|
||||||
@foo.stub!(:enter).and_raise(StandardError)
|
@foo.stub!(:enter).and_raise(StandardError)
|
||||||
lambda{@foo.safe_close!}.should raise_error(NoMethodError)
|
lambda{@foo.safe_close!}.should raise_error(NoMethodError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should propagate an error if no error callback is declared" do
|
it "should propagate an error if no error callback is declared" do
|
||||||
@foo.stub!(:enter).and_raise("Cannot enter safe")
|
@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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue