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

working tests to prevent foo bleed across multiple scenarios

This commit is contained in:
HoyaBoya 2015-11-05 10:46:06 -05:00
parent e64a84f71f
commit 8002e5a1c8
2 changed files with 31 additions and 17 deletions

View file

@ -1,5 +1,6 @@
class Foo module Fooable
include AASM def self.included(base)
base.class_eval do
aasm do aasm do
state :open, :initial => true, :before_exit => :before_exit state :open, :initial => true, :before_exit => :before_exit
state :closed, :before_enter => :before_enter state :closed, :before_enter => :before_enter
@ -13,6 +14,8 @@ class Foo
transitions :from => [:open], :to => [:closed, :final], :guard => :always_false transitions :from => [:open], :to => [:closed, :final], :guard => :always_false
end end
end end
end
end
def always_false def always_false
false false
@ -23,10 +26,21 @@ class Foo
def before_enter def before_enter
end end
def before_exit def before_exit
end end
end end
class Foo
include AASM
include Fooable
end
class FooGlobal
include AASM
include Fooable
end
class FooTwo < Foo class FooTwo < Foo
include AASM include AASM
aasm do aasm do

View file

@ -371,7 +371,7 @@ end
describe 'global error_on_all_events_callback callbacks' do describe 'global error_on_all_events_callback callbacks' do
describe "with an error_on_all_events" do describe "with an error_on_all_events" do
before do before do
class Foo class FooGlobal
# this hack is needed to allow testing of parameters, since RSpec # this hack is needed to allow testing of parameters, since RSpec
# destroys a method's arity when mocked # destroys a method's arity when mocked
attr_accessor :data attr_accessor :data
@ -385,7 +385,7 @@ describe 'global error_on_all_events_callback callbacks' do
end end
end end
@foo = Foo.new @foo = FooGlobal.new
end end
it_behaves_like 'an implemented callback that accepts error' do it_behaves_like 'an implemented callback that accepts error' do
@ -408,7 +408,7 @@ end
describe 'global ensure_on_all_events_callback callbacks' do describe 'global ensure_on_all_events_callback callbacks' do
describe "with an ensure_on_all_events" do describe "with an ensure_on_all_events" do
before do before do
class Foo class FooGlobal
# this hack is needed to allow testing of parameters, since RSpec # this hack is needed to allow testing of parameters, since RSpec
# destroys a method's arity when mocked # destroys a method's arity when mocked
attr_accessor :data attr_accessor :data
@ -422,7 +422,7 @@ describe 'global ensure_on_all_events_callback callbacks' do
end end
end end
@foo = Foo.new @foo = FooGlobal.new
end end
it_behaves_like 'an implemented callback' do it_behaves_like 'an implemented callback' do