File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,26 @@ struct AthenaStyleTest < ASPEC::TestCase
2121 string.should match(Regex .new(File .read(normalized_path))), file: file, line: line
2222 end
2323
24+ def test_error_style : Nil
25+ error_output = ACON ::Output ::IO .new io = IO ::Memory .new
26+ output = ACON ::Output ::ConsoleOutput .new
27+ output.stderr = error_output
28+
29+ style = ACON ::Style ::Athena .new ACON ::Input ::Hash .new({} of String => String ), output
30+ style.error_style.puts " foo"
31+
32+ io.to_s.should eq " foo\n "
33+ end
34+
35+ def test_error_style_non_console_output : Nil
36+ output = ACON ::Output ::IO .new io = IO ::Memory .new
37+
38+ style = ACON ::Style ::Athena .new ACON ::Input ::Hash .new({} of String => String ), output
39+ style.error_style.puts " foo"
40+
41+ io.to_s.should eq " foo\n "
42+ end
43+
2444 @[DataProvider (" output_provider" )]
2545 def test_outputs (command_proc : ACON ::Commands ::Generic ::Proc , file_path : String ) : Nil
2646 command = ACON ::Commands ::Generic .new " foo" , & command_proc
Original file line number Diff line number Diff line change @@ -53,4 +53,12 @@ abstract class Athena::Console::Style::Output
5353 def verbosity = (verbosity : ACON ::Output ::Verbosity ) : Nil
5454 @output .verbosity = verbosity
5555 end
56+
57+ protected def error_output : ACON ::Output ::Interface
58+ unless (output = @output ).is_a? ACON ::Output ::ConsoleOutputInterface
59+ return @output
60+ end
61+
62+ output.error_output
63+ end
5664end
You can’t perform that action at this time.
0 commit comments