Sha256: 1e36960faaafa173fc258ca2319f69c2f20a64688e32cdd4b2692cd33991d3ab

Contents?: true

Size: 1.39 KB

Versions: 21

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

module Relish
  module Command
    module Dsl
      describe Command do
        
        it_should_behave_like 'a Dsl that utilizes ContextClass'
        
        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

21 entries across 21 versions & 1 rubygems

Version Path
relish-0.7.1 spec/relish/commands/dsl/command_spec.rb
relish-0.7 spec/relish/commands/dsl/command_spec.rb
relish-0.6 spec/relish/commands/dsl/command_spec.rb
relish-0.5.3 spec/relish/commands/dsl/command_spec.rb
relish-0.5.2 spec/relish/commands/dsl/command_spec.rb
relish-0.5.1 spec/relish/commands/dsl/command_spec.rb
relish-0.5.0 spec/relish/commands/dsl/command_spec.rb
relish-0.4.0 spec/relish/commands/dsl/command_spec.rb
relish-0.3.0 spec/relish/commands/dsl/command_spec.rb
relish-0.3.0.pre spec/relish/commands/dsl/command_spec.rb
relish-0.2.3 spec/relish/commands/dsl/command_spec.rb
relish-0.2.2 spec/relish/commands/dsl/command_spec.rb
relish-0.2.1 spec/relish/commands/dsl/command_spec.rb
relish-0.2.0 spec/relish/commands/dsl/command_spec.rb
relish-0.1.6 spec/relish/commands/dsl/command_spec.rb
relish-0.1.5 spec/relish/commands/dsl/command_spec.rb
relish-0.1.4 spec/relish/commands/dsl/command_spec.rb
relish-0.1.3 spec/relish/commands/dsl/command_spec.rb
relish-0.1.2 spec/relish/commands/dsl/command_spec.rb
relish-0.1.1 spec/relish/commands/dsl/command_spec.rb