Module: Asshert::Assertions
- Includes:
- MiniTest::Assertions
- Defined in:
- lib/asshert/assertions.rb
Instance Method Summary collapse
- #assert_runit_service_up(hosts, service, msg = nil) ⇒ Object
- #assert_shell(hosts, command, msg = nil) ⇒ Object
- #assert_shell_file_contains(hosts, file, contents, msg = nil) ⇒ Object
- #refute_runit_service_up(hosts, service, msg = nil) ⇒ Object
- #refute_shell(hosts, command, msg = nil) ⇒ Object
- #refute_shell_file_contains(hosts, file, contents, msg = nil) ⇒ Object
Instance Method Details
#assert_runit_service_up(hosts, service, msg = nil) ⇒ Object
43 44 45 46 47 |
# File 'lib/asshert/assertions.rb', line 43 def assert_runit_service_up(hosts, service, msg=nil) msg ||= "Failed to assert runit service #{service} up. Command `%s' on `%s'" command = "sv status /home/protonet/dashboard/shared/services/enabled/#{service}" assert_shell(hosts, command, msg) end |
#assert_shell(hosts, command, msg = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/asshert/assertions.rb', line 9 def assert_shell(hosts, command, msg=nil) msg ||= "Failed SSH assertion `%s' on `%s'" results = Hash.new SSHKit::Coordinator.new(hosts).each(in: :sequence) do |host| results[host.to_s] = test(command) end results.each do |host, result| assert(result, sprintf(msg, command, host)) end end |
#assert_shell_file_contains(hosts, file, contents, msg = nil) ⇒ Object
31 32 33 34 35 |
# File 'lib/asshert/assertions.rb', line 31 def assert_shell_file_contains(hosts, file, contents, msg=nil) msg ||= "Failed to assert #{file} contains #{contents} `%s' on `%s'" command = "grep \"#{contents}\" \"#{file}\"" assert_shell(hosts, command) end |
#refute_runit_service_up(hosts, service, msg = nil) ⇒ Object
49 50 51 52 53 |
# File 'lib/asshert/assertions.rb', line 49 def refute_runit_service_up(hosts, service, msg=nil) msg ||= "Failed to refute runit service #{service} up. Command `%s' on `%s'" command = "sv status /home/protonet/dashboard/shared/services/enabled/#{service}" refute_shell(hosts, command, msg) end |
#refute_shell(hosts, command, msg = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/asshert/assertions.rb', line 20 def refute_shell(hosts, command, msg=nil) msg ||= "Failed SSH refutation on `%s' on `%s'" results = Hash.new SSHKit::Coordinator.new(hosts).each(in: :sequence) do |host| results[host.to_s] = test(command) end results.each do |host, result| refute(result, sprintf(msg, command, host)) end end |
#refute_shell_file_contains(hosts, file, contents, msg = nil) ⇒ Object
37 38 39 40 41 |
# File 'lib/asshert/assertions.rb', line 37 def refute_shell_file_contains(hosts, file, contents, msg=nil) msg ||= "Failed to refute `%s' contains `%s' on `%s'" command = "grep \"#{contents}\" \"#{file}\"" refute_shell(hosts, command) end |