Sha256: de427d1808a4dc0cd36c386e90d080d43bcc514a6253a211007c083b990eab63

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

require 'rails_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

8 entries across 8 versions & 1 rubygems

Version Path
stitches-5.0.0 spec/error_spec.rb
stitches-5.0.0.RC1 spec/error_spec.rb
stitches-4.2.2 spec/error_spec.rb
stitches-4.2.1 spec/error_spec.rb
stitches-4.2.0 spec/error_spec.rb
stitches-4.2.0.RC3 spec/error_spec.rb
stitches-4.2.0.RC2 spec/error_spec.rb
stitches-4.2.0.RC1 spec/error_spec.rb