class Torkify::Popup::Observer
Attributes
me[R]
options[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/torkify/popup/observer.rb, line 7 def initialize(options = {}) @me = "popup" @options = options end
Public Instance Methods
alert_error(title, body)
click to toggle source
# File lib/torkify/popup/observer.rb, line 23 def alert_error(title, body) unless @block_alerts Torkify.logger.debug { "[#{me}] error notification, title: '#{title}', message: '#{body}'" } Notifier.notify( image: options[:error_image], title: title, message: body ) end end
alert_info(title, body)
click to toggle source
# File lib/torkify/popup/observer.rb, line 12 def alert_info(title, body) unless @block_alerts Torkify.logger.debug { "[#{me}] notification, title: '#{title}', message: '#{body}'" } Notifier.notify( image: options[:ok_image], title: title, message: body ) end end
method_missing(name, *args)
click to toggle source
# File lib/torkify/popup/observer.rb, line 57 def method_missing(name, *args) puts "Event: #{name}" end
on_fail(event)
click to toggle source
# File lib/torkify/popup/observer.rb, line 53 def on_fail(event) alert_error "Uh-oh, a test failed", event.file end
on_pass(event)
click to toggle source
# File lib/torkify/popup/observer.rb, line 34 def on_pass(event) alert_info "Yay, a test passed!", event.file end
on_ran_all_test_files(event)
click to toggle source
# File lib/torkify/popup/observer.rb, line 42 def on_ran_all_test_files(event) @block_alerts = false total = event.failed.length + event.passed.length if event.failed.any? alert_error('All tests ran with failures!', "#{total} tests, #{event.passed.length} passed, #{event.failed.length} failed in #{event.time} seconds") else alert_info('All tests ran successfully', "#{total} tests ran in #{event.time} seconds") end end
on_run_all_test_files()
click to toggle source
# File lib/torkify/popup/observer.rb, line 38 def on_run_all_test_files @block_alerts = true end