Sha256: 40b1e672e3560068ea4c4d7c53ca44c36202d83c330d973367b4ca2dd310f38d

Contents?: true

Size: 945 Bytes

Versions: 1

Compression:

Stored size: 945 Bytes

Contents

require 'spec_helper'

describe Uia::Keys do
  def encode(*keys)
    Keys.encode keys
  end

  Then { encode('Bacon sandwich') == 'Bacon sandwich' }
  Then { encode([:control, :shift, 'a']) == '^(+a)' }

  context 'special keys' do
    Then { encode(:shift, :f2, :left) == '+{F2}{LEFT}' }
  end

  context 'special characters' do
    Then { encode('1 + 2') == '1 {+} 2' }
    Then { encode('1 ^^ 2') == '1 {^}{^} 2' }
    Then { encode('a%b') == 'a{%}b' }
    Then { encode('~ish') == '{~}ish' }
    Then { encode('(1 - 2)') == '{(}1 - 2{)}' }
    Then { encode('{DUDE}') == '{{}DUDE{}}' }
    Then { encode('[DUDE]') == '{[}DUDE{]}' }
    Then { encode('(Bacon + sand%wich^ [sweet] {}') == '{(}Bacon {+} sand{%}wich{^} {[}sweet{]} {{}{}}' }
  end

  context 'invalid' do
    When(:bad_keys) { encode('something', :bad_key) }
    Then { bad_keys == Failure(InvalidKey, "#{:bad_key} is not a valid key") }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uia-1.0 spec/uia/keys_spec.rb