2012-11-06 05:51:14 -05:00
|
|
|
# require 'spec_helper'
|
2011-10-15 11:32:28 -04:00
|
|
|
|
2012-11-06 05:51:14 -05:00
|
|
|
# describe "state machines" do
|
2011-10-15 11:32:28 -04:00
|
|
|
|
2014-05-24 02:42:20 -04:00
|
|
|
# def number_of_objects(klass)
|
|
|
|
# ObjectSpace.each_object(klass) {}
|
2012-11-06 05:51:14 -05:00
|
|
|
# end
|
2012-11-06 05:31:13 -05:00
|
|
|
|
2012-11-06 05:51:14 -05:00
|
|
|
# def machines
|
|
|
|
# AASM::StateMachine.instance_variable_get("@machines")
|
|
|
|
# end
|
2011-10-15 11:32:28 -04:00
|
|
|
|
2012-11-06 05:51:14 -05:00
|
|
|
# it "should be created without memory leak" do
|
|
|
|
# machines_count = machines.size
|
2014-11-28 16:22:43 -05:00
|
|
|
# state_count = number_of_objects(AASM::Core::State)
|
|
|
|
# event_count = number_of_objects(AASM::Core::Event)
|
2012-11-06 05:51:14 -05:00
|
|
|
# puts "event_count = #{event_count}"
|
2014-11-28 16:22:43 -05:00
|
|
|
# transition_count = number_of_objects(AASM::Core::Transition)
|
2011-10-15 11:32:28 -04:00
|
|
|
|
2012-11-06 05:51:14 -05:00
|
|
|
# load File.expand_path(File.dirname(__FILE__) + '/../models/not_auto_loaded/process.rb')
|
|
|
|
# machines.size.should == machines_count + 1 # + Process
|
|
|
|
# number_of_objects(Models::Process).should == 0
|
2014-11-28 16:22:43 -05:00
|
|
|
# number_of_objects(AASM::Core::State).should == state_count + 3 # + Process
|
|
|
|
# puts "event_count = #{number_of_objects(AASM::Core::Event)}"
|
|
|
|
# number_of_objects(AASM::Core::Event).should == event_count + 2 # + Process
|
|
|
|
# number_of_objects(AASM::Core::Transition).should == transition_count + 2 # + Process
|
2011-10-15 11:32:28 -04:00
|
|
|
|
2012-11-06 05:51:14 -05:00
|
|
|
# Models.send(:remove_const, "Process") if Models.const_defined?("Process")
|
|
|
|
# load File.expand_path(File.dirname(__FILE__) + '/../models/not_auto_loaded/process.rb')
|
|
|
|
# machines.size.should == machines_count + 1 # + Process
|
2014-11-28 16:22:43 -05:00
|
|
|
# number_of_objects(AASM::Core::State).should == state_count + 3 # + Process
|
|
|
|
# # ObjectSpace.each_object(AASM::Core::Event) {|o| puts o.inspect}
|
|
|
|
# puts "event_count = #{number_of_objects(AASM::Core::Event)}"
|
|
|
|
# number_of_objects(AASM::Core::Event).should == event_count + 2 # + Process
|
|
|
|
# number_of_objects(AASM::Core::Transition).should == transition_count + 2 # + Process
|
2012-11-06 05:51:14 -05:00
|
|
|
# end
|
2011-10-15 11:32:28 -04:00
|
|
|
|
2012-11-06 05:51:14 -05:00
|
|
|
# end
|