Register key bindings in the env with RunControl

This commit is contained in:
Thibault Jouan
2015-04-14 21:26:29 +00:00
parent b1aa430ef3
commit 2a1a1f1185
5 changed files with 31 additions and 4 deletions

View File

@@ -48,6 +48,20 @@ module Uh
.to raise_error env.object_id.to_s
end
end
describe '#key' do
let(:code) { -> { :keybind_code } }
before { rc.key :f, &code }
it 'registers a key binding in the env' do
expect(env.keybinds.keys).to include :f
end
it 'registers given block with the key binding' do
expect(env.keybinds[:f].call).to eq :keybind_code
end
end
end
end
end

View File

@@ -76,8 +76,9 @@ module Uh
end
it 'registers key bindings event hooks' do
env.keybinds[:f] = -> { }
runner.register_event_hooks
expect(runner.events[:key, :q]).not_to be_empty
expect(runner.events[:key, :f]).not_to be_empty
end
end
@@ -90,8 +91,9 @@ module Uh
runner.connect_manager
end
it 'tells the manager to grab keys' do
expect(runner.manager).to receive(:grab_key).with :q
it 'tells the manager to grab keys for env key bindings' do
env.keybinds[:f] = -> { }
expect(runner.manager).to receive(:grab_key).with :f
runner.connect_manager
end
end