Sha256: 18f69918e005c52d7f7da1be394be93b8b574e14a9cfc361db9355844ad51d07

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

require 'test_helper'

module Vedeu

  describe Key do

    let(:described) { Vedeu::Key }
    let(:instance)  { described.new(input) { :output } }
    let(:input)     { 'a' }

    describe '.build' do
      subject { described.build(input) { :output } }

      it { subject.must_be_instance_of(Key) }

      context 'when the required block is not given' do
        subject { described.build(input) }

        it { proc { subject }.must_raise(InvalidSyntax) }
      end
    end

    describe '#initialize' do
      it { instance.must_be_instance_of(Key) }
      it { instance.instance_variable_get('@input').must_equal(input) }

      context 'when the required block is not given' do
        subject { described.new(input) }

        it { proc { subject }.must_raise(InvalidSyntax) }
      end
    end

    describe '#input' do
      subject { instance.input }

      it 'returns the key defined' do
        subject.must_equal('a')
      end

      it { instance.must_respond_to(:key) }
    end

    describe '#output' do
      subject { instance.output }

      it 'returns the result of calling the proc' do
        subject.must_equal(:output)
      end

      it { instance.must_respond_to(:action) }
      it { instance.must_respond_to(:press) }
    end

  end # Key

end # Vedeu

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.4.1 test/lib/vedeu/input/key_test.rb
vedeu-0.4.0 test/lib/vedeu/input/key_test.rb
vedeu-0.3.5 test/lib/vedeu/input/key_test.rb