Closed majormoses closed 6 years ago
Testing the code without slack in irb:
$ irb
irb(main):001:0> require_relative './bin/handler-slack.rb'
=> true
irb(main):003:0> class Slack < Sensu::Handler
irb(main):004:1> def check_status(status)
irb(main):005:2> status
irb(main):006:2> end
irb(main):007:1> end
=> :check_status
# init slack class
irb(main):025:0> slack = Sensu::Handler::Slack.new
(irb):25: warning: toplevel constant Slack referenced by Sensu::Handler::Slack
=> #<Slack:0x000056149efa84b8 @options={:json_config=>{:description=>"Configuration name", :short=>"-j JSONCONFIG", :long=>"--json JSONCONFIG", :default=>"slack", :on=>:on, :boolean=>false, :required=>false, :proc=>nil, :show_options=>false, :exit=>nil, :in=>nil}}, @config={:json_config=>"slack"}, @default_config={}, @opt_parser=#<OptionParser:0x000056149efa82d8
<INTENTIONALLY TRUNCATED>
# verify colors to status codes
irb(main):029:0> slack.color(0)
=> "#36a64f"
irb(main):030:0> slack.color(1)
=> "#FFCC00"
irb(main):031:0> slack.color(2)
=> "#FF0000"
irb(main):032:0> slack.color(3)
=> "#6600CC"
irb(main):033:0> slack.color(127)
=> "#6600CC"
Signed-off-by: Ben Abrams me@benabrams.it
Pull Request Checklist
fixes #34 was based off #61 but far more flexible
General
[ ] Update Changelog following the conventions laid out here
[ ] Update README with any necessary configuration snippets
[ ] Binstubs are created if needed
[ ] RuboCop passes
[ ] Existing tests pass
Purpose
Fixes #34 as well as any other non spec compliant status codes
Known Compatibility Issues
None