Sha256: c94c934b8cacd89f381157b115d0b1abef7c476901df67a359c84672a812f384

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

include Mac

# TODO: support key lauouts other than QWERTY

describe KeyCode do
  describe '.new' do
    subject do
      KeyCode.new(key_code)
    end

    context 'key code for space key' do
      let(:key_code) do
        49
      end

      it do
        should be_printable
      end

      it do
        subject.to_s.should eql(' ')
      end
    end

    context 'key code for tab key' do
      let(:key_code) do
        48
      end

      it do
        should be_printable
      end

      it do
        subject.to_s.should eql("\t")
      end
    end

    context 'key code for "j"' do
      let(:key_code) do
        38
      end

      it do
        should be_printable
      end

      it do
        subject.to_s.should eql('j')
      end
    end

    context 'key code for return key' do
      let(:key_code) do
        36
      end

      it do
        should be_printable
      end

      it do
        subject.to_s.should eql("\r")
      end
    end

    context 'key code for non-printable key' do
      let(:key_code) do
        96
      end

      it do
        should_not be_printable
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mac-key_code-0.0.2 spec/mac/key_code_spec.rb
mac-key_code-0.0.1 spec/mac/key_code_spec.rb