Cuprum

An opinionated implementation of the Command pattern for Ruby applications. Cuprum wraps your business logic in a consistent, object-oriented interface and features status and error management, composability and control flow management.

Module: Cuprum::RSpec::Deferred::ParameterValidationExamples

Parent Namespace
Cuprum::RSpec::Deferred
Included Modules
Cuprum::RSpec::Matchers, RSpec::SleepingKingStudios::Deferred::Provider
Defined In
lib/cuprum/rspec/deferred/parameter_validation_examples.rb

Table Of Contents

Overview

Deferred examples for testing parameter validation.

Examples

With A Validation Type

RSpec.describe LaunchRocket do
  include Cuprum::RSpec::Deferred::ParameterValidationExamples

  describe '#call' do
    let(:launch_site) { 'KSC' }

    def call_command
      subject.call(launch_site:)
    end

    describe 'with invalid parameters' do
      let(:launch_site) { nil }

      include_deferred 'should validate the parameter',
        :launch_site,
        'sleeping_king_studios.tools.assertions.presence',
        as: 'launch site'
    end
  end
end

With A Message

RSpec.describe LaunchRocket do
  include Cuprum::RSpec::Deferred::ParameterValidationExamples

  describe '#call' do
    let(:launch_site) { 'KSC' }

    def call_command
      subject.call(launch_site:)
    end

    describe 'with invalid parameters' do
      let(:launch_site) { nil }

      include_deferred 'should validate the parameter',
        :launch_site,
        message: "launch site can't be blank"
    end
  end
end

Back To Top

Instance Methods

#be_a_failing_result(expected_class = nil) => Cuprum::RSpec::BeAResultMatcher

Inherited From
Cuprum::RSpec::Matchers

Asserts that the object is a result with status: :failure.

Parameters

Returns

#be_a_passing_result(expected_class = nil) => Cuprum::RSpec::BeAResultMatcher

Inherited From
Cuprum::RSpec::Matchers

Asserts that the object is a Cuprum::Result with status: :success.

Parameters

Returns

#be_a_result(expected_class = nil) => Cuprum::RSpec::BeAResultMatcher

Inherited From
Cuprum::RSpec::Matchers

Asserts that the object is a Cuprum::Result.

Returns

#be_callable => RSpec::Matchers::BuiltIn::RespondTo

Inherited From
Cuprum::RSpec::Matchers

Asserts that the command defines a :process method.

Returns

Back To Top


Back to Documentation | Reference | Cuprum | Cuprum::RSpec | Cuprum::RSpec::Deferred