Sha256: bdcaa6f49e6a6bda8cdad11302da659a4fac19f3f448ae074c5fa9fa7aab12d9

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

require_relative '../../../test_helper'

module Vedeu
  class DummyCommand
    class << self
      def dispatch; end
    end
  end

  describe Command do
    let(:described_class)       { Command }
    let(:instance)    { described_class.new(cmd_name, cmd_klass, cmd_args, cmd_options) }
    let(:cmd_name)    { "dummy" }
    let(:cmd_klass)   { DummyCommand }
    let(:cmd_args)    { [] }
    let(:cmd_options) { {} }

    it { instance.must_be_instance_of(Command) }

    describe '#define' do
      subject do
        described_class.define(cmd_name, cmd_klass, cmd_args, cmd_options)
      end

      it { subject.must_be_instance_of(Hash) }

      it { subject.wont_be_empty }

      context "when the command name is empty" do
        let(:cmd_name) { "" }

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

      context "when the command class is empty" do
        let(:cmd_klass) { "" }

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

      context "when the command class is not defined" do
        before { Object.stubs(:const_defined?).returns(false) }

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

      context "when the command class doesn't have a .dispatch method" do
        before { cmd_klass.stubs(:singleton_methods).returns([]) }

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.0.7 test/lib/vedeu/process/command_test.rb
vedeu-0.0.6 test/lib/vedeu/process/command_test.rb
vedeu-0.0.5 test/lib/vedeu/process/command_test.rb
vedeu-0.0.4 test/lib/vedeu/process/command_test.rb