Sha256: 220df0e01ba950700c3a382d9002da1196c805eb3b0dd62a2380d974cfb09a2a

Contents?: true

Size: 1.27 KB

Versions: 21

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

module Stitches
  describe Error do
    describe '#initialize' do
      context 'required params are set' do
        it 'does not raise error' do
          expect do
            described_class.new(code: anything, message: anything)
          end.to_not raise_error
        end
      end

      context 'code is missing' do
        it 'raises a descriptive error' do
          expect do
            described_class.new(message: 'foo')
          end.to raise_error(
                    described_class::MissingParameter,
                    'Stitches::Error must be initialized with :code')
        end
      end

      context 'message is missing' do
        it 'raises a descriptive error' do
          expect do
            described_class.new(code: 123)
          end.to raise_error(
                    described_class::MissingParameter,
                    'Stitches::Error must be initialized with :message')
        end
      end

      context 'both are missing' do
        it 'raises an error about code' do
          expect do
            described_class.new(message: 'foo')
          end.to raise_error(
                  described_class::MissingParameter,
                  'Stitches::Error must be initialized with :code')
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
stitches-4.0.2 spec/error_spec.rb
stitches-4.1.0RC2 spec/error_spec.rb
stitches-4.0.1 spec/error_spec.rb
stitches-4.0.0 spec/error_spec.rb
stitches-4.0.0.RC1 spec/error_spec.rb
stitches-3.8.3 spec/error_spec.rb
stitches-3.8.2 spec/error_spec.rb
stitches-3.8.1 spec/error_spec.rb
stitches-3.8.0 spec/error_spec.rb
stitches-3.7.3 spec/error_spec.rb
stitches-3.7.2 spec/error_spec.rb
stitches-3.7.0 spec/error_spec.rb
stitches-3.6.1 spec/error_spec.rb
stitches-3.6.0 spec/error_spec.rb
stitches-3.6.0.RC1 spec/error_spec.rb
stitches-3.5.0 spec/error_spec.rb
stitches-3.4.0 spec/error_spec.rb
stitches-3.3.0 spec/error_spec.rb
stitches-3.2.3 spec/error_spec.rb
stitches-3.2.2 spec/error_spec.rb