use_cases 0.3.0 → 0.3.4

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: 9e37115bbba6763134166d41497c5b1bd75725618cfa81a0cca04dccdeda1590
4
- data.tar.gz: bc732410906c5e053d75bf982561a34c663faafed062f5f6ccac006f4f1f3cee
3
+ metadata.gz: b23fbdabf2ed8296b4d97887efd8ad0397f8404e04a25416b8325fd2de4d9157
4
+ data.tar.gz: bc7d2ed3d1f051e130144886354f4a92ef22eb5cdc9afa19255d16ead5f2fc45
5
5
  SHA512:
6
- metadata.gz: f7a9ff7502bf8b6db76f10a56d68a4d43055ecd54a106c50a37abde3543ba832611deb3561f03dd4a0a65e07642144b51620beede3701cb2f437634f39aab100
7
- data.tar.gz: a170718b5d281df6f761b4c297d6cbb5ecfa0dbf5deb34ac01254dfd21a125898de4cf9935b05d49b73a2699c2007b52fcac1caa2e6c160d66e580307deec83a
6
+ metadata.gz: 04ab7eeacb1b52422519df50d6ed34bea32fe8ca69488f0f2247f177354610e5c30ba83f9ffde0475a6a374cf7d4f5808c486d1450b2091404c1e86aa9bd56e9
7
+ data.tar.gz: a0496ea6b528412ac49711044914c2c76817ae131d3569013a30cd0816f6ce9236f4155a0d2218916e5b576a2f074ba094e971fdacba25f5b7ea8f31a4f3751c
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
- .byebug_history
12
+ .byebug_history
13
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- use_cases (0.2.5)
4
+ use_cases (0.3.4)
5
5
  activesupport
6
6
  dry-events
7
7
  dry-matcher
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "byebug"
4
-
5
3
  module UseCases
6
4
  module Notifications
7
5
  def self.included(base)
@@ -5,43 +5,59 @@ require "rspec"
5
5
  RSpec::Matchers.define(:be_failure_with_code) do |expected_code|
6
6
  match do |test_subject|
7
7
  expect(test_subject.failure?).to be true
8
- expect(test_subject.failure.first).to eq expected_code
8
+ expect(test_subject.failure.first).to eql expected_code
9
9
  end
10
10
 
11
11
  failure_message do |test_subject|
12
- "the use case was expected to fail with code #{expected_code} but it returned #{test_subject.failure.first}"
12
+ if text_subject.failure?
13
+ "the use case was expected to fail with code #{expected_code} but it returned #{test_subject.failure.first}"
14
+ else
15
+ "the use case was expected to fail with code #{expected_code} but it did not fail"
16
+ end
13
17
  end
14
18
  end
15
19
 
16
20
  RSpec::Matchers.define(:be_failure_with_payload) do |expected_result|
17
21
  match do |test_subject|
18
22
  expect(test_subject.failure?).to be true
19
- expect(test_subject.failure.last).to eq expected_result
23
+ expect(test_subject.failure.last).to eql expected_result
20
24
  end
21
25
 
22
26
  failure_message do |test_subject|
23
- "the use case was expected to fail with #{expected_result.inspect} but it returned #{test_subject.failure.last.inspect}"
27
+ if test_subject.failure?
28
+ "the use case was expected to fail with #{expected_result.inspect} but it returned #{test_subject.failure.last.inspect}"
29
+ else
30
+ "the use case was expected to fail but it succeeded with #{test_subject.success.inspect}"
31
+ end
24
32
  end
25
33
  end
26
34
 
27
35
  RSpec::Matchers.define(:be_failure_with) do |*expected_failure|
28
36
  match do |test_subject|
29
37
  expect(test_subject.failure?).to be true
30
- expect(test_subject.failure).to eq expected_failure
38
+ expect(test_subject.failure).to eql expected_failure
31
39
  end
32
40
 
33
41
  failure_message do |test_subject|
34
- "the use case was expected to fail with #{expected_result.inspect} but it returned #{test_subject.failure.inspect}"
42
+ if test_subject.failure?
43
+ "the use case was expected to fail with #{expected_result.inspect} but it returned #{test_subject.failure.inspect}"
44
+ else
45
+ "the use case was expected to fail but it succeeded with #{test_subject.success.inspect}"
46
+ end
35
47
  end
36
48
  end
37
49
 
38
50
  RSpec::Matchers.define(:be_successful_with) do |expected_result|
39
51
  match do |test_subject|
40
52
  expect(test_subject.success?).to be true
41
- expect(test_subject.success).to eq expected_result
53
+ expect(test_subject.success).to eql expected_result
42
54
  end
43
55
 
44
56
  failure_message do |test_subject|
45
- "the use case was expected to succeed with #{expected_result.inspect} but it returned #{test_subject.success.inspect}"
57
+ if test_subject.success?
58
+ "the use case was expected to succeed with #{expected_result.inspect} but it returned #{test_subject.success.inspect}"
59
+ else
60
+ "the use case was expected to succeed but it failed with #{test_subject.failure.inspect}"
61
+ end
46
62
  end
47
63
  end
@@ -12,8 +12,8 @@ module UseCases
12
12
  prev_result = previous_step_result.value
13
13
  raise InvalidReturnValue, "The return value should not be a Monad." if result.is_a?(Dry::Monads::Result)
14
14
 
15
- failure_code = options[:failure] || :check_failure
16
- failure_message = options[:failure_message] || "Failed"
15
+ failure_code = options[:failure] || :unauthorized
16
+ failure_message = options[:failure_message] || "Not Authorized"
17
17
 
18
18
  result ? Success(prev_result) : Failure([failure_code, failure_message])
19
19
  end
@@ -6,7 +6,7 @@ module UseCases
6
6
  def do_call(*base_args)
7
7
  args = [object.class.name, name.to_s, *base_args]
8
8
  args = ::UseCases::StepActiveJobAdapter.serialize_step_arguments(args)
9
- byebug
9
+
10
10
  job_options = options.slice(:queue, :wait, :wait_until, :priority)
11
11
 
12
12
  ::UseCases::StepActiveJobAdapter.set(job_options).perform_later(*args)
@@ -13,7 +13,7 @@ module UseCases
13
13
 
14
14
  Success(result)
15
15
  rescue options[:catch] || StandardError => e
16
- Failure([options[:failure], e.message])
16
+ Failure([options[:failure], options[:failure_message] || e.message])
17
17
  end
18
18
  end
19
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UseCases
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: use_cases
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ring Twice
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-26 00:00:00.000000000 Z
11
+ date: 2021-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport