Module: Servactory::TestKit::Rspec::Helpers::ArgumentMatchers
- Included in:
- Servactory::TestKit::Rspec::Helpers
- Defined in:
- lib/servactory/test_kit/rspec/helpers/argument_matchers.rb
Overview
RSpec argument matchers with service-friendly aliases.
## Purpose
Provides semantic aliases for RSpec’s argument matchers that read more naturally in service testing contexts.
## Usage
**Fluent API:**
“‘ruby allow_service(Service).with(including(amount: 100)).succeeds(result: “ok”) allow_service(Service).with(excluding(secret: anything)).succeeds(result: “ok”) allow_service(Service).with(any_inputs).succeeds(result: “ok”) allow_service(EmptyService).with(no_inputs).succeeds(result: “ok”) “`
**Legacy API:**
“‘ruby allow_service_as_success!(Service, with: including(amount: 100)) { { result: “ok” } } allow_service_as_success!(Service, with: excluding(secret: anything)) { { result: “ok” } } allow_service_as_success!(Service, with: any_inputs) { { result: “ok” } } allow_service_as_success!(EmptyService, with: no_inputs) { { result: “ok” } } “`
Instance Method Summary collapse
-
#any_inputs ⇒ RSpec::Mocks::ArgumentMatchers::AnyArgMatcher
Matches any service inputs (wildcard matcher).
-
#excluding(hash) ⇒ RSpec::Mocks::ArgumentMatchers::HashExcludingMatcher
Matches a hash NOT containing specified key-value pairs.
-
#including(hash) ⇒ RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher
Matches a hash containing specified key-value pairs.
-
#no_inputs ⇒ RSpec::Mocks::ArgumentMatchers::NoArgsMatcher
Matches no arguments (for services without inputs).
Instance Method Details
#any_inputs ⇒ RSpec::Mocks::ArgumentMatchers::AnyArgMatcher
Matches any service inputs (wildcard matcher).
Useful for “don’t care” scenarios where input values don’t matter.
77 78 79 |
# File 'lib/servactory/test_kit/rspec/helpers/argument_matchers.rb', line 77 def any_inputs anything end |
#excluding(hash) ⇒ RSpec::Mocks::ArgumentMatchers::HashExcludingMatcher
Matches a hash NOT containing specified key-value pairs.
Alias for RSpec’s ‘hash_excluding` with service-friendly naming.
62 63 64 |
# File 'lib/servactory/test_kit/rspec/helpers/argument_matchers.rb', line 62 def excluding(hash) hash_excluding(hash) end |
#including(hash) ⇒ RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher
Matches a hash containing specified key-value pairs.
Alias for RSpec’s ‘hash_including` with service-friendly naming.
46 47 48 |
# File 'lib/servactory/test_kit/rspec/helpers/argument_matchers.rb', line 46 def including(hash) hash_including(hash) end |
#no_inputs ⇒ RSpec::Mocks::ArgumentMatchers::NoArgsMatcher
Matches no arguments (for services without inputs).
90 91 92 |
# File 'lib/servactory/test_kit/rspec/helpers/argument_matchers.rb', line 90 def no_inputs no_args end |