Class: Test::Unit::Notify::Notifier
- Inherits:
-
Object
- Object
- Test::Unit::Notify::Notifier
- Defined in:
- lib/abt/test_collector.rb
Class Method Summary collapse
- .add_notifier(sender) ⇒ Object
- .add_params(params = {}) ⇒ Object
- .get_notifiers ⇒ Object
- .get_params ⇒ Object
Instance Method Summary collapse
- #attach_to_mediator(mediator) ⇒ Object
- #finished(elapsed_time) ⇒ Object
- #notify?(params, result) ⇒ Boolean
- #started(result) ⇒ Object
Class Method Details
.add_notifier(sender) ⇒ Object
35 36 37 38 39 |
# File 'lib/abt/test_collector.rb', line 35 def self.add_notifier(sender) @senders||=[] @senders<<sender puts "adding sender! #{@senders.inspect}" end |
.add_params(params = {}) ⇒ Object
26 27 28 29 |
# File 'lib/abt/test_collector.rb', line 26 def self.add_params(params={}) @params||={} @params.merge!(params) end |
.get_notifiers ⇒ Object
41 42 43 |
# File 'lib/abt/test_collector.rb', line 41 def self.get_notifiers @senders||[] end |
.get_params ⇒ Object
31 32 33 |
# File 'lib/abt/test_collector.rb', line 31 def self.get_params @params||{} end |
Instance Method Details
#attach_to_mediator(mediator) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/abt/test_collector.rb', line 45 def attach_to_mediator(mediator) mediator.add_listener(UI::TestRunnerMediator::STARTED, &method(:started)) mediator.add_listener(UI::TestRunnerMediator::FINISHED, &method(:finished)) end |
#finished(elapsed_time) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/abt/test_collector.rb', line 65 def finished(elapsed_time) = "Status:%s [%g%%] (%gs)" % [@result.status, @result.pass_percentage, elapsed_time] puts "Message:#{}:" puts "TEST_RESULT:#{@result.inspect}" params = Notifier.get_params senders = Notifier.get_notifiers senders.each do |sender| puts "sender:#{sender.inspect}" puts "Notify?:#{notify?(params,@result).inspect}" if sender && notify?(params,@result) if sender.respond_to?(:send_formatted_message) puts sender.(@result) elsif sender.respond_to?(:send_message) puts sender.() end end end end |
#notify?(params, result) ⇒ Boolean
56 57 58 59 60 61 62 63 |
# File 'lib/abt/test_collector.rb', line 56 def notify?(params,result) return true unless result.passed? if params && params[:notify_every] ((Time.now.hour % params[:notify_every].to_i == 0) && Time.now.min > 0 && Time.now.min < 10) else true end end |
#started(result) ⇒ Object
52 53 54 |
# File 'lib/abt/test_collector.rb', line 52 def started(result) @result = result end |