Sha256: c8a1bc858b3711bde4896419985216759319edd9650a2a93bbdc4ba54eae2e95
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
require 'test_helper' class Flucti::Utilities::MiscellaneousTest < Test::Unit::TestCase include Flucti::Utilities def setup @utils = Object.new.extend UserInterface, Miscellaneous @utils.stubs(:exit) end def test_error! assert_one_line_matching = lambda do |out, matcher| lines = out.split("\n").grep(/^!/) assert_equal 1, lines.size assert_match(matcher, lines.first) end assert_displays_unknown_error_with = lambda do |error| display_error(error) do |out| assert_one_line_matching[out, /unknown/i] end end assert_displays_unknown_error_with[nil] assert_displays_unknown_error_with[{'error' => nil}] assert_displays_unknown_error_with[{'errors' => nil}] assert_displays_unknown_error_with[{'errors' => {'error' => nil}}] assert_displays_unknown_error_with[{'errors' => {'error' => []}}] display_error({'errors' => {'error' => "msg"}}) do |out| assert_one_line_matching[out, /\bmsg\b/] end display_error({'errors' => {'error' => ["msg"]}}) do |out| assert_one_line_matching[out, /\bmsg\b/] end display_error("msg") do |out| assert_one_line_matching[out, /\bmsg\b/] end end def test_clean_name assert_equal "php-test", @utils.clean_name("php_test") assert_equal "funky-test-name", @utils.clean_name("Fun'ky - \"test\" Name..") end private def display_error(error) @utils.error! error, nil, io = StringIO.new yield io.string end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
Flucti-flucti-cli-0.1.16 | test/flucti/utilities/miscellaneous_test.rb |