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:
parent
e64a84f71f
commit
8002e5a1c8
2 changed files with 31 additions and 17 deletions
|
@ -1,5 +1,6 @@
|
|||
class Foo
|
||||
include AASM
|
||||
module Fooable
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
aasm do
|
||||
state :open, :initial => true, :before_exit => :before_exit
|
||||
state :closed, :before_enter => :before_enter
|
||||
|
@ -13,6 +14,8 @@ class Foo
|
|||
transitions :from => [:open], :to => [:closed, :final], :guard => :always_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def always_false
|
||||
false
|
||||
|
@ -23,10 +26,21 @@ class Foo
|
|||
|
||||
def before_enter
|
||||
end
|
||||
|
||||
def before_exit
|
||||
end
|
||||
end
|
||||
|
||||
class Foo
|
||||
include AASM
|
||||
include Fooable
|
||||
end
|
||||
|
||||
class FooGlobal
|
||||
include AASM
|
||||
include Fooable
|
||||
end
|
||||
|
||||
class FooTwo < Foo
|
||||
include AASM
|
||||
aasm do
|
||||
|
|
|
@ -371,7 +371,7 @@ end
|
|||
describe 'global error_on_all_events_callback callbacks' do
|
||||
describe "with an error_on_all_events" do
|
||||
before do
|
||||
class Foo
|
||||
class FooGlobal
|
||||
# this hack is needed to allow testing of parameters, since RSpec
|
||||
# destroys a method's arity when mocked
|
||||
attr_accessor :data
|
||||
|
@ -385,7 +385,7 @@ describe 'global error_on_all_events_callback callbacks' do
|
|||
end
|
||||
end
|
||||
|
||||
@foo = Foo.new
|
||||
@foo = FooGlobal.new
|
||||
end
|
||||
|
||||
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 "with an ensure_on_all_events" do
|
||||
before do
|
||||
class Foo
|
||||
class FooGlobal
|
||||
# this hack is needed to allow testing of parameters, since RSpec
|
||||
# destroys a method's arity when mocked
|
||||
attr_accessor :data
|
||||
|
@ -422,7 +422,7 @@ describe 'global ensure_on_all_events_callback callbacks' do
|
|||
end
|
||||
end
|
||||
|
||||
@foo = Foo.new
|
||||
@foo = FooGlobal.new
|
||||
end
|
||||
|
||||
it_behaves_like 'an implemented callback' do
|
||||
|
|
Loading…
Reference in a new issue