diff options
author | José Valim <jose.valim@gmail.com> | 2009-10-15 14:49:29 -0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-10-15 18:19:25 -0300 |
commit | 5988b87c30eb0ce50c235187f5dfcfcfb98da01b (patch) | |
tree | 9296872692328820d2a97f29ecfb434fd99a8aab /activesupport/test | |
parent | 11f9f556b83f90e33ae516cc7a74177a9befdb0b (diff) | |
download | rails-5988b87c30eb0ce50c235187f5dfcfcfb98da01b.tar.gz rails-5988b87c30eb0ce50c235187f5dfcfcfb98da01b.tar.bz2 rails-5988b87c30eb0ce50c235187f5dfcfcfb98da01b.zip |
Added parent_of? method to help tracing events.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/orchestra_test.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/activesupport/test/orchestra_test.rb b/activesupport/test/orchestra_test.rb index 7a6e9208b4..1b2f98c7dd 100644 --- a/activesupport/test/orchestra_test.rb +++ b/activesupport/test/orchestra_test.rb @@ -9,20 +9,36 @@ end class OrchestraEventTest < Test::Unit::TestCase def test_events_are_initialized_with_name_and_payload - event = ActiveSupport::Orchestra::Event.new(:foo, :payload => :bar) + event = event(:foo, :payload => :bar) assert_equal :foo, event.name assert_equal Hash[:payload => :bar], event.payload end def test_events_consumes_information_given_as_payload - event = ActiveSupport::Orchestra::Event.new(:foo, - :time => (time = Time.now), :result => 1, :duration => 10) + event = event(:foo, :time => (time = Time.now), :result => 1, :duration => 10) assert_equal Hash.new, event.payload assert_equal time, event.time assert_equal 1, event.result assert_equal 10, event.duration end + + def test_event_is_parent_based_on_time_frame + parent = event(:foo, :time => Time.utc(2009), :duration => 10000) + child = event(:foo, :time => Time.utc(2009, 01, 01, 0, 0, 1), :duration => 1000) + not_child = event(:foo, :time => Time.utc(2009, 01, 01, 0, 0, 1), :duration => 10000) + + assert parent.parent_of?(child) + assert !child.parent_of?(parent) + assert !parent.parent_of?(not_child) + assert !not_child.parent_of?(parent) + end + + protected + + def event(*args) + ActiveSupport::Orchestra::Event.new(*args) + end end class OrchestraMainTest < Test::Unit::TestCase |