servactory 2.14.0 → 2.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f6718e3b5e71152099847ec1713940116c44a7641dbc3c63d7a4ef60478ef3c
4
- data.tar.gz: 9ecd3809f2792504bb5f2694b4ceb9969e5bd4ad386dccfbdb5af6e0a8e55a9a
3
+ metadata.gz: ee6b7f861c6725a1cc1addd81413b0d84eef974ee2290543145293561b9b23d8
4
+ data.tar.gz: 855d74bbded65bd281bbb9c8018e7e7d0272d555593b0b78464432cda42481e7
5
5
  SHA512:
6
- metadata.gz: 1810233557cfb71509fcf04e618295cde0ab190511b8bb50569cd098cf359c606730de1299d89eaaeec8e6c55d65b901fc7bbea895e46532a1a3f825d5bfcc6f
7
- data.tar.gz: 4011679f170547c0ee3b4e1c527dfadccb961185446d4386c3a9ff6da81da9a6da683d7d5102ca339a5609c644d61ded644321115cc1697368451301c53a8078
6
+ metadata.gz: 34ba463f5c90df781dbc93761e7f73b5776532fa53ba5d6ff663e4c00d9fd5ffa744fe5a8f62704cd84496f6ee10b277b674b7c2c9e2262f02d6fead30a2cfc8
7
+ data.tar.gz: 32dbeb464202b1e3e64eb62677e3ed61ba8acd95616ac8098a269869e099946c2030bc9272124727288eb166d3f58414ca812cc27a173292af6d168d0453a749
@@ -3,16 +3,29 @@
3
3
  module Servactory
4
4
  module TestKit
5
5
  class Result
6
- def self.as_success(attributes = {})
6
+ def self.as_success(**attributes)
7
+ service_class = attributes.delete(:service_class) || self
8
+
7
9
  context = new(attributes)
8
10
 
9
- Servactory::Result.success_for(context:)
11
+ if service_class == Servactory::TestKit::Result
12
+ Servactory::Result.success_for(context:)
13
+ else
14
+ service_class.config.result_class.success_for(context:)
15
+ end
10
16
  end
11
17
 
12
- def self.as_failure(attributes = {}, exception: nil)
18
+ def self.as_failure(**attributes)
19
+ service_class = attributes.delete(:service_class) || self
20
+ exception = attributes.delete(:exception)
21
+
13
22
  context = new(attributes)
14
23
 
15
- Servactory::Result.failure_for(context:, exception:)
24
+ if service_class == Servactory::TestKit::Result
25
+ Servactory::Result.failure_for(context:, exception:)
26
+ else
27
+ service_class.config.result_class.failure_for(context:, exception:)
28
+ end
16
29
  end
17
30
 
18
31
  def initialize(attributes = {})
@@ -64,17 +64,7 @@ module Servactory
64
64
  {}
65
65
  end
66
66
 
67
- # puts
68
- # puts <<~RUBY
69
- # allow(#{service_class}).to(
70
- # receive(#{method_call.inspect})
71
- # .public_send(
72
- # #{and_return_or_raise.inspect},
73
- # Servactory::TestKit::Result.public_send(#{result_type.inspect}, #{result})
74
- # )
75
- # )
76
- # RUBY
77
- # puts
67
+ result[:service_class] = service_class
78
68
 
79
69
  allow(service_class).to(
80
70
  receive(method_call)
@@ -92,7 +82,7 @@ module Servactory
92
82
  if as_success || !with_bang
93
83
  Servactory::TestKit::Result.public_send(result_type, **result)
94
84
  else
95
- Servactory::TestKit::Result.public_send(result_type, result)
85
+ result.fetch(:exception)
96
86
  end
97
87
  )
98
88
  )
@@ -4,7 +4,7 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 2
6
6
  MINOR = 14
7
- PATCH = 0
7
+ PATCH = 1
8
8
  PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.0
4
+ version: 2.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-21 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -354,7 +354,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
354
354
  - !ruby/object:Gem::Version
355
355
  version: '0'
356
356
  requirements: []
357
- rubygems_version: 3.6.2
357
+ rubygems_version: 3.6.7
358
358
  specification_version: 4
359
359
  summary: A set of tools for building reliable services of any complexity
360
360
  test_files: []