class MachineWithIntegrationTest
Public Instance Methods
after_initialize()
click to toggle source
# File test/unit/machine_test.rb, line 570 def after_initialize @initialized = true end
create_with_scope(name)
click to toggle source
# File test/unit/machine_test.rb, line 574 def create_with_scope(name) (@with_scopes ||= []) << name lambda {} end
create_without_scope(name)
click to toggle source
# File test/unit/machine_test.rb, line 579 def create_without_scope(name) (@without_scopes ||= []) << name lambda {} end
setup()
click to toggle source
# File test/unit/machine_test.rb, line 562 def setup StateMachine::Integrations.const_set('Custom', Module.new do include StateMachine::Integrations::Base @defaults = {:action => :save, :use_transactions => false} attr_reader :initialized, :with_scopes, :without_scopes, :ran_transaction def after_initialize @initialized = true end def create_with_scope(name) (@with_scopes ||= []) << name lambda {} end def create_without_scope(name) (@without_scopes ||= []) << name lambda {} end def transaction(object) @ran_transaction = true yield end end) @machine = StateMachine::Machine.new(Class.new, :integration => :custom) end
teardown()
click to toggle source
# File test/unit/machine_test.rb, line 623 def teardown StateMachine::Integrations.send(:remove_const, 'Custom') end
test_should_call_after_initialize_hook()
click to toggle source
# File test/unit/machine_test.rb, line 593 def test_should_call_after_initialize_hook assert @machine.initialized end
test_should_define_a_singular_and_plural_with_scope()
click to toggle source
# File test/unit/machine_test.rb, line 615 def test_should_define_a_singular_and_plural_with_scope assert_equal %w(with_state with_states), @machine.with_scopes end
test_should_define_a_singular_and_plural_without_scope()
click to toggle source
# File test/unit/machine_test.rb, line 619 def test_should_define_a_singular_and_plural_without_scope assert_equal %w(without_state without_states), @machine.without_scopes end
test_should_use_the_custom_action_if_specified()
click to toggle source
# File test/unit/machine_test.rb, line 601 def test_should_use_the_custom_action_if_specified machine = StateMachine::Machine.new(Class.new, :integration => :custom, :action => :save!) assert_equal :save!, machine.action end
test_should_use_the_custom_use_transactions_if_specified()
click to toggle source
# File test/unit/machine_test.rb, line 610 def test_should_use_the_custom_use_transactions_if_specified machine = StateMachine::Machine.new(Class.new, :integration => :custom, :use_transactions => true) assert_equal true, machine.use_transactions end
test_should_use_the_default_action()
click to toggle source
# File test/unit/machine_test.rb, line 597 def test_should_use_the_default_action assert_equal :save, @machine.action end
test_should_use_the_default_use_transactions()
click to toggle source
# File test/unit/machine_test.rb, line 606 def test_should_use_the_default_use_transactions assert_equal false, @machine.use_transactions end
transaction(object) { || ... }
click to toggle source
# File test/unit/machine_test.rb, line 584 def transaction(object) @ran_transaction = true yield end