Sha256: 72c113c7e594943a2f6e0f145d9b3517dc825dabcb0348c6e5272e2d1f242f0a

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

module Relish
  module Command
    module Dsl
      describe Command do
        
        describe '#define' do
          let(:context_class) { Class.new }
          let(:command) { described_class.new(context_class) }
          let(:the_instance) { context_class.new }
          
          before do
            context_class.should_receive(:name).and_return('::Dog')
            HelpText.stub(:add)
          end
          
          it 'defines an instance method on the context class' do
            command.define(:my_command) {}
            the_instance.should respond_to(:my_command)
          end
          
          context 'the instance method' do
            
            it 'evaluates the block' do
              command.define(:my_command) { 'my command value' }
              the_instance.my_command.should eq('my command value')
            end
            
            it 'rescues RestClient::Exception' do
              command.define(:my_command) do
                raise RestClient::Exception.new('uh oh an exception')
              end
              the_instance.should_receive(:warn).with('uh oh an exception')
              the_instance.should_receive(:exit).with(1)
              the_instance.my_command
            end
              
          end
          
        end
        
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relish-0.0.9 spec/relish/commands/dsl/command_spec.rb