use_cases 0.3.0 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +1 -1
- data/lib/use_cases/notifications.rb +0 -2
- data/lib/use_cases/rspec/matchers.rb +24 -8
- data/lib/use_cases/step_adapters/authorize.rb +2 -2
- data/lib/use_cases/step_adapters/enqueue.rb +1 -1
- data/lib/use_cases/step_adapters/try.rb +1 -1
- data/lib/use_cases/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b23fbdabf2ed8296b4d97887efd8ad0397f8404e04a25416b8325fd2de4d9157
|
4
|
+
data.tar.gz: bc7d2ed3d1f051e130144886354f4a92ef22eb5cdc9afa19255d16ead5f2fc45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04ab7eeacb1b52422519df50d6ed34bea32fe8ca69488f0f2247f177354610e5c30ba83f9ffde0475a6a374cf7d4f5808c486d1450b2091404c1e86aa9bd56e9
|
7
|
+
data.tar.gz: a0496ea6b528412ac49711044914c2c76817ae131d3569013a30cd0816f6ce9236f4155a0d2218916e5b576a2f074ba094e971fdacba25f5b7ea8f31a4f3751c
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -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
|
8
|
+
expect(test_subject.failure.first).to eql expected_code
|
9
9
|
end
|
10
10
|
|
11
11
|
failure_message do |test_subject|
|
12
|
-
|
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
|
23
|
+
expect(test_subject.failure.last).to eql expected_result
|
20
24
|
end
|
21
25
|
|
22
26
|
failure_message do |test_subject|
|
23
|
-
|
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
|
38
|
+
expect(test_subject.failure).to eql expected_failure
|
31
39
|
end
|
32
40
|
|
33
41
|
failure_message do |test_subject|
|
34
|
-
|
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
|
53
|
+
expect(test_subject.success).to eql expected_result
|
42
54
|
end
|
43
55
|
|
44
56
|
failure_message do |test_subject|
|
45
|
-
|
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] || :
|
16
|
-
failure_message = options[:failure_message] || "
|
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
|
-
|
9
|
+
|
10
10
|
job_options = options.slice(:queue, :wait, :wait_until, :priority)
|
11
11
|
|
12
12
|
::UseCases::StepActiveJobAdapter.set(job_options).perform_later(*args)
|
data/lib/use_cases/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|