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.
Deferred examples for testing parameter validation.
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
endWith 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#be_a_failing_result(expected_class = nil) => Cuprum::RSpec::BeAResultMatcher
Asserts that the object is a result with status: :failure.
#be_a_passing_result(expected_class = nil) => Cuprum::RSpec::BeAResultMatcher
Asserts that the object is a Cuprum::Result with status: :success.
#be_a_result(expected_class = nil) => Cuprum::RSpec::BeAResultMatcher
Asserts that the object is a Cuprum::Result.
#be_callable => RSpec::Matchers::BuiltIn::RespondTo
Asserts that the command defines a :process method.
Back to Documentation | Reference | Cuprum | Cuprum::RSpec | Cuprum::RSpec::Deferred