Class: HipchatNotifier
- Inherits:
-
Object
- Object
- HipchatNotifier
- Defined in:
- lib/abt/notifiers/hipchat_notifier.rb
Instance Method Summary collapse
-
#initialize(notifier_details) ⇒ HipchatNotifier
constructor
A new instance of HipchatNotifier.
- #send_formatted_message(result) ⇒ Object
- #send_message(message, color = 'yellow') ⇒ Object
Constructor Details
#initialize(notifier_details) ⇒ HipchatNotifier
Returns a new instance of HipchatNotifier.
4 5 6 7 8 |
# File 'lib/abt/notifiers/hipchat_notifier.rb', line 4 def initialize(notifier_details) @client = HipChat::API.new(notifier_details["hipchat_api_key"]) @room_name = notifier_details["room_name"] @title= notifier_details["title"] end |
Instance Method Details
#send_formatted_message(result) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/abt/notifiers/hipchat_notifier.rb', line 10 def (result) color = result.passed? ? 'green' : 'red' = "Result: <b>#{result.status}</b> [#{result.pass_percentage}%] <br> <strong>#{result.run_count}</strong> tests, <strong>#{result.assertion_count}</strong> assertions" if result.error_occurred? || result.failure_occurred? +=", <strong>#{result.failure_count}</strong> failures, <strong>#{result.error_count}</strong>, errors<br/>" result.faults.each { |f| +="<br><pre>#{f.to_s.gsub(/>/,' ').gsub(/</,' ')}</pre><br/>" } end (,color) end |
#send_message(message, color = 'yellow') ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/abt/notifiers/hipchat_notifier.rb', line 21 def (,color='yellow') puts "sending_message #{}" begin puts @client.(@room_name, @title, , false,color).body rescue =>ex ex.inspect end end |