Sha256: 925630273a50e05359ebb4d90a1d7084c5f8b71bfb75319f9e1295341d9fc14f
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 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) } let(:raw_mode) { true } before do reader.stubs(:raw_mode?).returns(raw_mode) Vedeu.stubs(:trigger).returns([false]) end describe '#initialize' do it { instance.must_be_instance_of(Input) } it { instance.instance_variable_get('@reader').must_equal(reader) } end describe '.capture' do subject { described.capture(reader) } context 'when in cooked mode' do let(:raw_mode) { false } let(:command) { 'help' } before { reader.stubs(:read).returns(command) } it 'triggers an event with the command' do Vedeu.expects(:trigger).with(:_command_, command) subject end end context 'when in raw mode' do let(:raw_mode) { true } let(:keypress) { 'a' } before { reader.stubs(:read).returns(keypress) } context 'when the key is not special' do it 'triggers an event with the keypress' do Vedeu.expects(:trigger).with(:_keypress_, keypress) subject end end context 'when the key is special' do let(:keypress) { "\e[A" } it 'triggers an event with the keypress' do Vedeu.expects(:trigger).with(:_keypress_, :up) subject end end end end end # Input end # Vedeu
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.4.17 | test/lib/vedeu/input/input_test.rb |
vedeu-0.4.16 | test/lib/vedeu/input/input_test.rb |