Sha256: 8c9dfa9986dd2b6949fd18500593fae5f2d8f138784674dfb4dab54a895126d1

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

module ReversePolishCalculator
  describe Errors do
    
    describe '.handle' do
      context 'given a NoMethodError exception' do
        let(:exception) { NoMethodError.new }
        
        it 'calls .no_method_error' do
          described_class.should_receive(:no_method_error).with(exception)
          described_class.handle(exception)
        end
      end
    end
    
    describe '.no_method_error' do
      context 'given a NoMethodError exception' do
        let(:exception) { NoMethodError.new('message', 'name') }
        
        it 'removes the offending input from the stack' do
          ReversePolishCalculator.stack.should_receive(:remove).with('name')
          described_class.no_method_error(exception)
        end
      end
    end
    
    describe '.math_domain_error' do
      context 'given a Math::DomainError exception' do
        let(:exception) { Math::DomainError.new('the "name"') }
        
        it 'removes the offending input from the stack' do
          ReversePolishCalculator.stack.should_receive(:remove).with('name')
          described_class.math_domain_error(exception)
        end
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reverse-polish-calculator-0.0.1 spec/unit/reverse-polish-calculator/errors_spec.rb