Sha256: 8ef7b12b27d2d9c338232ce00a3c5d47a5c91d5932781c21a4a3a4f493566267
Contents?: true
Size: 1 KB
Versions: 8
Compression:
Stored size: 1 KB
Contents
require 'test_helper' module Vedeu describe Input do let(:reader) { Vedeu::Terminal } let(:keypress) { 'a' } let(:described) { Vedeu::Input } let(:instance) { described.new(reader) } before { reader.stubs(:read).returns(keypress) } describe '#initialize' do it { instance.must_be_instance_of(Input) } it { instance.instance_variable_get('@reader').must_equal(reader) } end describe '.capture' do context 'when the key is not special' do before { Vedeu.stubs(:trigger).returns([false]) } it 'triggers an event associated with the key pressed' do Input.capture(reader).must_equal([false]) end end context 'when the key is special' do let(:keypress) { "\e" } before { Vedeu.stubs(:trigger).raises(ModeSwitch) } it 'switches the terminal mode when escape is pressed' do proc { Input.capture(reader) }.must_raise(ModeSwitch) end end end end # Input end # Vedeu
Version data entries
8 entries across 8 versions & 1 rubygems