Sha256: 38231ded9bbac1c4032a3ec2df2954d8f7aa6e719d87d1e2c23ba27b89fb851e

Contents?: true

Size: 1.02 KB

Versions: 30

Compression:

Stored size: 1.02 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/common')
require_relative '../lib/keyboard_input'

describe KeyboardInput do

  class Go
    @time = 58
    def self.cur_time
      @time += 1
    end

    def self.got
      @got
    end

    @muted = true
    class << self
      attr_accessor :muted
    end

    def self.status
      @muted = !@muted
      if @muted
        "muted"
      else
        "unmuted"
      end
    end

    def self.keyboard_input input
      @got = input
    end
  end

  before do
    @a = KeyboardInput.new Go
    Go.muted = true
  end

  it "should display on one line" do
    @a.get_line_printout.should include("\b\b\b")
  end

  it "should display whether muted or not" do
    @a.get_line_printout.should include("unmuted")
    @a.get_line_printout.should_not include("unmuted")
  end

  it "should translate keys to characters" do
    @a.handle_keystroke 77
    Go.got.should == "M"
    @a.handle_keystroke 109
    Go.got.should == "m"
  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
sensible-cinema-0.17.0 spec/keyboard_input.spec.rb
sensible-cinema-0.16.7 spec/keyboard_input.spec.rb
sensible-cinema-0.16.5 spec/keyboard_input.spec.rb
sensible-cinema-0.16.3 spec/keyboard_input.spec.rb
sensible-cinema-0.16.2 spec/keyboard_input.spec.rb
sensible-cinema-0.16.1 spec/keyboard_input.spec.rb
sensible-cinema-0.15.0 spec/keyboard_input.spec.rb
sensible-cinema-0.14.6 spec/keyboard_input.spec.rb
sensible-cinema-0.14.5 spec/keyboard_input.spec.rb
sensible-cinema-0.14.4 spec/keyboard_input.spec.rb
sensible-cinema-0.14.3 spec/keyboard_input.spec.rb
sensible-cinema-0.14.1 spec/keyboard_input.spec.rb
sensible-cinema-0.13.1 spec/keyboard_input.spec.rb
sensible-cinema-0.13.0 spec/keyboard_input.spec.rb
sensible-cinema-0.12.0 spec/keyboard_input.spec.rb
sensible-cinema-0.11.0 spec/keyboard_input.spec.rb
sensible-cinema-0.10.2 spec/keyboard_input.spec.rb
sensible-cinema-0.10.1 spec/keyboard_input.spec.rb
sensible-cinema-0.9.7 spec/keyboard_input.spec.rb
sensible-cinema-0.9.4 spec/keyboard_input.spec.rb