Feature: Diagnostic checks Checks allow you to determine if a "diagnostic check" has passed, gave a warning, or failed. They can also contain metadata info such as attributes, lists, texts, and tables. Scenario: Status methods on a check Given a file named "status_methods.rb" with: """ $:.unshift(File.dirname(__FILE__) + '/../../lib') require 'diagnostics' check = diagnostic_check :system do |c| c.passed { true } c.warning { false } c.failed { false } end puts check.passed? puts check.warning? puts check.failed? puts check.status.inspect """ When I run "ruby status_methods.rb" Then the output should contain exactly: """ true false false :passed """ Scenario: Attributes on a check Given a file named "attributes.rb" with: """ $:.unshift(File.dirname(__FILE__) + '/../../lib') require 'diagnostics' check = diagnostic_check :system do |c| c.data do |d| d['Master'] = 'Up' d['Slave'] = 'Down' end end puts check.data.attributes(:plain) puts puts check.data.attributes(:html) puts check.data.attributes.map do |attribute| puts "#{attribute.name}---#{attribute.value}" end """ When I run "ruby attributes.rb" Then the output should contain exactly: """ Master: Up Slave: Down Master: Up Slave: Down Master---Up Slave---Down """ Scenario: Lists on a check Given a file named "lists.rb" with: """ $:.unshift(File.dirname(__FILE__) + '/../../lib') require 'diagnostics' check = diagnostic_check :system do |c| c.data do |d| d << ['a', 'b', 'c'] d << [1, 2, 3] end end puts check.data.lists(:plain) puts puts check.data.lists(:html) """ When I run "ruby lists.rb" Then the output should contain exactly: """ a b c 1 2 3 a
b
c 1
2
3 """ Scenario: Texts on a check Given a file named "texts.rb" with: """ $:.unshift(File.dirname(__FILE__) + '/../../lib') require 'diagnostics' check = diagnostic_check :system do |c| c.data do |d| d << 'a' d << 'b' end end puts check.data.texts(:plain) puts puts check.data.texts(:html) """ When I run "ruby texts.rb" Then the output should contain exactly: """ a b

a

b

""" Scenario: Tables on a check Given a file named "tables.rb" with: """ $:.unshift(File.dirname(__FILE__) + '/../../lib') require 'diagnostics' check = diagnostic_check :system do |c| c.data do |d| d << { 'heading1' => [1,2,3], 'heading2' => [4,5,6] } end end print check.data.tables(:html) """ When I run "ruby tables.rb" Then the output should contain the table: """
heading1 heading2
1 4
2 5
3 6
"""