Skip to content

Commit

Permalink
Added test for inheritance, to check issue #64
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernesto Tagwerker committed Apr 30, 2013
1 parent 7f98b99 commit 7e9d869
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/models/father.rb
@@ -0,0 +1,21 @@
require 'active_record'

class Father < ActiveRecord::Base
include AASM

aasm do
state :missing_details, :initial => true
state :pending_details_confirmation

event :add_details do
transitions :from => :missing_details, :to => :pending_details_confirmation
end
end

def update_state
if may_add_details?
add_details!
end
end

end
3 changes: 3 additions & 0 deletions spec/models/son.rb
@@ -0,0 +1,3 @@
class Son < Father
include AASM
end
18 changes: 18 additions & 0 deletions spec/unit/inheritance_spec.rb
@@ -0,0 +1,18 @@
require 'spec_helper'

describe 'inheritance behavior' do
let(:son) {Son.new}

it 'should be in the pending state' do
son.aasm_current_state.should == :missing_details
end

it 'should know how to respond to `may_add_details?`' do
son.may_add_details?.should be_true
end

it 'should not break if I call Son#update_state' do
son.update_state
son.aasm_current_state.should == :pending_details_confirmation
end
end

0 comments on commit 7e9d869

Please sign in to comment.