test/lib/vedeu/esc/esc_test.rb in vedeu-0.6.10 vs test/lib/vedeu/esc/esc_test.rb in vedeu-0.6.11
- old
+ new
@@ -1,76 +1,80 @@
require 'test_helper'
module Vedeu
- describe Esc do
+ module EscapeSequences
- let(:described) { Vedeu::Esc }
+ describe Esc do
- describe '.escape' do
- let(:stream) { "\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l" }
+ let(:described) { Vedeu::EscapeSequences::Esc }
- subject { described.escape(stream) }
+ describe '.escape' do
+ let(:stream) { "\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l" }
- it { subject.must_be_instance_of(String) }
+ subject { described.escape(stream) }
- it 'escapes the escape sequences' do
- subject.must_equal('\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l')
- end
+ it { subject.must_be_instance_of(String) }
- context 'when a stream is not given' do
- let(:stream) { '' }
+ it 'escapes the escape sequences' do
+ subject.must_equal('\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l')
+ end
- it { subject.must_equal('') }
- end
- end
+ context 'when a stream is not given' do
+ let(:stream) { '' }
- describe '.border' do
- context 'when the block is given' do
- it { described.border { 'b' }.must_equal("\e(0b\e(B") }
+ it { subject.must_equal('') }
+ end
end
- context 'when the block is not given' do
- it { described.border.must_equal('') }
- end
- end
+ describe '.border' do
+ context 'when the block is given' do
+ it { described.border { 'b' }.must_equal("\e(0b\e(B") }
+ end
- describe '.string' do
- context 'when the style is not provided' do
- it { described.string.must_equal('') }
+ context 'when the block is not given' do
+ it { described.border.must_equal('') }
+ end
end
- context 'when the style is provided' do
- it { described.string('bg_reset').must_equal("\e[49m") }
- it { described.string('blink').must_equal("\e[5m") }
- it { described.string('blink_off').must_equal("\e[25m") }
- it { described.string('bold').must_equal("\e[1m") }
- it { described.string('bold_off').must_equal("\e[22m") }
- it { described.string('clear').must_equal("\e[39m\e[49m\e[2J") }
- it { described.string('clear_line').must_equal("\e[39m\e[49m\e[2K") }
- it { described.string('colour_reset').must_equal("\e[39m\e[49m") }
- it { described.string('fg_reset').must_equal("\e[39m") }
- it { described.string('hide_cursor').must_equal("\e[?25l") }
- it { described.string('screen_init').
- must_equal("\e[0m\e[39m\e[49m\e[2J\e[?25l") }
- it { described.string('negative').must_equal("\e[7m") }
- it { described.string('positive').must_equal("\e[27m") }
- it { described.string('reset').must_equal("\e[0m") }
- it { described.string('normal').must_equal("\e[24m\e[22m\e[27m") }
- it { described.string('dim').must_equal("\e[2m") }
- it { described.string('show_cursor').must_equal("\e[?25h") }
- it { described.string('underline').must_equal("\e[4m") }
- it { described.string('underline_off').must_equal("\e[24m") }
- it { described.string('cursor_position').must_equal("\e[6n") }
- end
+ describe '.string' do
+ context 'when the style is not provided' do
+ it { described.string.must_equal('') }
+ end
- context 'screen_exit' do
- before { Vedeu::Terminal.stubs(:size).returns([80, 25]) }
+ context 'when the style is provided' do
+ it { described.string('bg_reset').must_equal("\e[49m") }
+ it { described.string('blink').must_equal("\e[5m") }
+ it { described.string('blink_off').must_equal("\e[25m") }
+ it { described.string('bold').must_equal("\e[1m") }
+ it { described.string('bold_off').must_equal("\e[22m") }
+ it { described.string('clear').must_equal("\e[39m\e[49m\e[2J") }
+ it { described.string('clear_line').must_equal("\e[39m\e[49m\e[2K") }
+ it { described.string('colour_reset').must_equal("\e[39m\e[49m") }
+ it { described.string('fg_reset').must_equal("\e[39m") }
+ it { described.string('hide_cursor').must_equal("\e[?25l") }
+ it { described.string('screen_init').
+ must_equal("\e[0m\e[39m\e[49m\e[2J\e[?25l") }
+ it { described.string('negative').must_equal("\e[7m") }
+ it { described.string('positive').must_equal("\e[27m") }
+ it { described.string('reset').must_equal("\e[0m") }
+ it { described.string('normal').must_equal("\e[24m\e[22m\e[27m") }
+ it { described.string('dim').must_equal("\e[2m") }
+ it { described.string('show_cursor').must_equal("\e[?25h") }
+ it { described.string('underline').must_equal("\e[4m") }
+ it { described.string('underline_off').must_equal("\e[24m") }
+ it { described.string('cursor_position').must_equal("\e[6n") }
+ end
- it { described.string('screen_exit').
- must_equal("\e[?25h\e[39m\e[49m\e[0m\e[80;25H\n") }
+ context 'screen_exit' do
+ before { Vedeu::Terminal.stubs(:size).returns([80, 25]) }
+
+ it { described.string('screen_exit').
+ must_equal("\e[?25h\e[39m\e[49m\e[0m\e[80;25H\n") }
+ end
end
- end
- end # Esc
+ end # Esc
+
+ end # EscapeSequences
end # Vedeu