Module: Servactory::TestKit::Rspec::Matchers

Defined in:
lib/servactory/test_kit/rspec/matchers.rb,
lib/servactory/test_kit/rspec/matchers/base/submatcher.rb,
lib/servactory/test_kit/rspec/matchers/base/attribute_matcher.rb,
lib/servactory/test_kit/rspec/matchers/base/submatcher_context.rb,
lib/servactory/test_kit/rspec/matchers/base/submatcher_registry.rb,
lib/servactory/test_kit/rspec/matchers/concerns/value_comparison.rb,
lib/servactory/test_kit/rspec/matchers/have_service_input_matcher.rb,
lib/servactory/test_kit/rspec/matchers/have_service_output_matcher.rb,
lib/servactory/test_kit/rspec/matchers/have_service_internal_matcher.rb,
lib/servactory/test_kit/rspec/matchers/concerns/attribute_data_access.rb,
lib/servactory/test_kit/rspec/matchers/concerns/error_message_builder.rb,
lib/servactory/test_kit/rspec/matchers/result/be_failure_service_matcher.rb,
lib/servactory/test_kit/rspec/matchers/result/be_success_service_matcher.rb,
lib/servactory/test_kit/rspec/matchers/submatchers/shared/must_submatcher.rb,
lib/servactory/test_kit/rspec/matchers/submatchers/shared/types_submatcher.rb,
lib/servactory/test_kit/rspec/matchers/submatchers/input/default_submatcher.rb,
lib/servactory/test_kit/rspec/matchers/submatchers/shared/schema_submatcher.rb,
lib/servactory/test_kit/rspec/matchers/submatchers/shared/target_submatcher.rb,
lib/servactory/test_kit/rspec/matchers/submatchers/input/optional_submatcher.rb,
lib/servactory/test_kit/rspec/matchers/submatchers/input/required_submatcher.rb,
lib/servactory/test_kit/rspec/matchers/submatchers/shared/message_submatcher.rb,
lib/servactory/test_kit/rspec/matchers/submatchers/input/valid_with_submatcher.rb,
lib/servactory/test_kit/rspec/matchers/submatchers/shared/inclusion_submatcher.rb,
lib/servactory/test_kit/rspec/matchers/submatchers/shared/consists_of_submatcher.rb

Overview

RSpec matchers for Servactory service testing.

Defined Under Namespace

Modules: Base, Concerns, Result, Submatchers Classes: HaveServiceInputMatcher, HaveServiceInternalMatcher, HaveServiceOutputMatcher

Instance Method Summary collapse

Instance Method Details

#be_failure_serviceResult::BeFailureServiceMatcher

Creates a matcher for validating failed service results.

Examples:

expect(result).to be_failure_service
  .type(:validation_error)
  .message("Invalid input")

Returns:



140
141
142
# File 'lib/servactory/test_kit/rspec/matchers.rb', line 140

def be_failure_service
  Result::BeFailureServiceMatcher.new
end

#be_success_serviceResult::BeSuccessServiceMatcher

Creates a matcher for validating successful service results.

Examples:

expect(result).to be_success_service
  .with_output(:data, "value")

Returns:



128
129
130
# File 'lib/servactory/test_kit/rspec/matchers.rb', line 128

def be_success_service
  Result::BeSuccessServiceMatcher.new
end

#have_service_input(input_name) ⇒ HaveServiceInputMatcher

Creates a matcher for validating service input attribute definitions.

Examples:

expect(MyService).to have_service_input(:user_id)
  .type(Integer)
  .required

Parameters:

  • input_name (Symbol)

    The name of the input to validate

Returns:



92
93
94
# File 'lib/servactory/test_kit/rspec/matchers.rb', line 92

def have_service_input(input_name) # rubocop:disable Naming/PredicatePrefix
  HaveServiceInputMatcher.new(described_class, input_name)
end

#have_service_internal(internal_name) ⇒ HaveServiceInternalMatcher

Creates a matcher for validating service internal attribute definitions.

Examples:

expect(MyService).to have_service_internal(:processed_data)
  .type(Hash)

Parameters:

  • internal_name (Symbol)

    The name of the internal to validate

Returns:



104
105
106
# File 'lib/servactory/test_kit/rspec/matchers.rb', line 104

def have_service_internal(internal_name) # rubocop:disable Naming/PredicatePrefix
  HaveServiceInternalMatcher.new(described_class, internal_name)
end

#have_service_output(output_name) ⇒ HaveServiceOutputMatcher

Creates a matcher for validating service result output values.

Examples:

expect(result).to have_service_output(:user)
  .instance_of(User)
  .contains(name: "John")

Parameters:

  • output_name (Symbol)

    The name of the output to validate

Returns:



117
118
119
# File 'lib/servactory/test_kit/rspec/matchers.rb', line 117

def have_service_output(output_name) # rubocop:disable Naming/PredicatePrefix
  HaveServiceOutputMatcher.new(output_name)
end