actioninteractor 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/action_interactor/base.rb +11 -0
- data/test/base_test.rb +8 -2
- data/test/inheritance_test.rb +23 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cef520c222e604cb756a2d86025c65c18e13e7cb989a28d424953ce1eeb1e0b0
|
4
|
+
data.tar.gz: f62278ed5410aebd05a6541ef8bcd578b32fcb8b3a5f6b74972b491f2a9709e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '02286892b80e833c0f17a33c8f0a6f92fa5872d50a37da45d8eab9aa6bf21558c58819ec0ac9ff093939bdf46cd280930d92331dfe4bc1a844f1c1d7427904c8'
|
7
|
+
data.tar.gz: e93d7c3d3ae583077283dbd793716c67506316caa11371eb29c04f48eab3525a5b136bb4e260563d3e6ff6d12333ddab7376ddd02d825c59287b7ecd1612f8b6
|
@@ -19,6 +19,11 @@ module ActionInteractor
|
|
19
19
|
success!
|
20
20
|
end
|
21
21
|
|
22
|
+
def execute!
|
23
|
+
execute
|
24
|
+
success? || raise(ExecutionError.new("Failed to execute the interactor"))
|
25
|
+
end
|
26
|
+
|
22
27
|
def finished?
|
23
28
|
@_finished
|
24
29
|
end
|
@@ -64,6 +69,12 @@ module ActionInteractor
|
|
64
69
|
def execute(params)
|
65
70
|
new(params).tap(&:execute)
|
66
71
|
end
|
72
|
+
|
73
|
+
def execute!(params)
|
74
|
+
new(params).tap(&:execute!)
|
75
|
+
end
|
67
76
|
end
|
68
77
|
end
|
78
|
+
|
79
|
+
class ExecutionError < StandardError; end
|
69
80
|
end
|
data/test/base_test.rb
CHANGED
@@ -13,10 +13,16 @@ class BaseTest < Test::Unit::TestCase
|
|
13
13
|
assert_instance_of(ActionInteractor::Base, interactor)
|
14
14
|
end
|
15
15
|
|
16
|
-
test "
|
16
|
+
test ".execute! also returns an ActionInteractor::Base instance" do
|
17
|
+
params = {}
|
18
|
+
interactor = ActionInteractor::Base.execute!(params)
|
19
|
+
assert_instance_of(ActionInteractor::Base, interactor)
|
20
|
+
end
|
21
|
+
|
22
|
+
test "the result is an instance of ActionInteractor::Results" do
|
17
23
|
params = {}
|
18
24
|
interactor = ActionInteractor::Base.execute(params)
|
19
|
-
|
25
|
+
assert_instance_of(ActionInteractor::Results, interactor.results)
|
20
26
|
end
|
21
27
|
|
22
28
|
test "#success? is true" do
|
data/test/inheritance_test.rb
CHANGED
@@ -64,6 +64,29 @@ class InheritanceTest < Test::Unit::TestCase
|
|
64
64
|
assert interactor.finished?
|
65
65
|
end
|
66
66
|
|
67
|
+
test "if params is empty, .execute returns instance of RegistrationInteractor" do
|
68
|
+
params = {}
|
69
|
+
interactor = RegistrationInteractor.execute(params)
|
70
|
+
assert_instance_of(RegistrationInteractor, interactor)
|
71
|
+
end
|
72
|
+
|
73
|
+
test "if params is empty, #execute! raises a ExecutionError" do
|
74
|
+
params = {}
|
75
|
+
interactor = RegistrationInteractor.new(params)
|
76
|
+
error = assert_raises ActionInteractor::ExecutionError do
|
77
|
+
interactor.execute!
|
78
|
+
end
|
79
|
+
assert_equal "Failed to execute the interactor", error.message
|
80
|
+
end
|
81
|
+
|
82
|
+
test "if params is empty, #execute! raises a ExecutionError" do
|
83
|
+
params = {}
|
84
|
+
error = assert_raises ActionInteractor::ExecutionError do
|
85
|
+
RegistrationInteractor.execute!(params)
|
86
|
+
end
|
87
|
+
assert_equal "Failed to execute the interactor", error.message
|
88
|
+
end
|
89
|
+
|
67
90
|
test "if params is empty, #failure? is true" do
|
68
91
|
params = {}
|
69
92
|
interactor = RegistrationInteractor.execute(params)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actioninteractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Hashimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,8 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: 1.8.11
|
74
74
|
requirements: []
|
75
|
-
|
76
|
-
rubygems_version: 2.7.6
|
75
|
+
rubygems_version: 3.0.3
|
77
76
|
signing_key:
|
78
77
|
specification_version: 4
|
79
78
|
summary: Action Interactor provides a simple interface for performing operations (part
|