Module: TestBench::Output::Assertions
- Defined in:
- lib/test_bench/output/assertions.rb
Instance Method Summary collapse
- #color_output? ⇒ Boolean
- #text_written ⇒ Object
- #wrote?(text) ⇒ Boolean
- #wrote_line?(text, indent: nil, **colors) ⇒ Boolean
- #wrote_nothing? ⇒ Boolean
Instance Method Details
#color_output? ⇒ Boolean
4 5 6 7 8 9 10 11 |
# File 'lib/test_bench/output/assertions.rb', line 4 def color_output? text = 'Some Text' color = :gray write text, :fg => color, :bg => color wrote_line? text, :fg => color, :bg => color end |
#text_written ⇒ Object
13 14 15 16 |
# File 'lib/test_bench/output/assertions.rb', line 13 def text_written device.rewind device.read end |
#wrote?(text) ⇒ Boolean
18 19 20 |
# File 'lib/test_bench/output/assertions.rb', line 18 def wrote? text text_written == text end |
#wrote_line?(text, indent: nil, **colors) ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/test_bench/output/assertions.rb', line 22 def wrote_line? text, indent: nil, **colors color ||= {} indent ||= 0 color_escape = Palette.escape_code(**colors) unless color_escape.empty? text = "#{color_escape}#{text}\e[0m" end matcher = Regexp.escape "#{' ' * indent}#{text}" pattern = /^#{matcher}$/n pattern.match text_written end |
#wrote_nothing? ⇒ Boolean
38 39 40 |
# File 'lib/test_bench/output/assertions.rb', line 38 def wrote_nothing? text_written.empty? end |