actioninteractor 0.0.12 → 0.0.13
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 +4 -0
- data/test/base_test.rb +2 -2
- data/test/inheritance_test.rb +24 -6
- 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: 3abdd934a8609ef4c3d040807ce20d6d93e39413d2976f160bd1ba9ba3c6657e
|
4
|
+
data.tar.gz: d772e562956ef64cc2268612e24e8cff3f869ade10812591f609703c99330fe1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6d881147238cccb70ebf235aa5e14952ca73d3b745cfafd03a77fa9f188a6f7778c1f79271d1f858ebd652053ad66b8a4eab315391cde7e804be64bd4d5afdc
|
7
|
+
data.tar.gz: 38be37a4641949355534368100432b315b866fdcb81e63696286a386b135ab5c22cf55245aaf5ac347dbae0333aaf7d79063d52017a1a86c166d3e59a7e62c7f
|
data/test/base_test.rb
CHANGED
@@ -25,10 +25,10 @@ class BaseTest < Test::Unit::TestCase
|
|
25
25
|
assert interactor.success?
|
26
26
|
end
|
27
27
|
|
28
|
-
test "#
|
28
|
+
test "#finished? is true" do
|
29
29
|
params = {}
|
30
30
|
interactor = ActionInteractor::Base.execute(params)
|
31
|
-
assert interactor.
|
31
|
+
assert interactor.finished?
|
32
32
|
end
|
33
33
|
|
34
34
|
test "#aborted? is true after #abort!" do
|
data/test/inheritance_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "test/unit"
|
2
|
-
|
2
|
+
require_relative "../lib/action_interactor/base.rb"
|
3
3
|
|
4
4
|
class User
|
5
5
|
attr_accessor :name
|
@@ -11,12 +11,21 @@ end
|
|
11
11
|
|
12
12
|
class RegistrationInteractor < ActionInteractor::Base
|
13
13
|
def execute
|
14
|
-
return
|
14
|
+
return fail! unless params[:name]
|
15
15
|
add_result(:user, User.new(name: params[:name]))
|
16
16
|
finish!
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
class NotificationInteractor < ActionInteractor::Base
|
21
|
+
def execute
|
22
|
+
return fail! unless params[:name] || params[:email]
|
23
|
+
results(name: params[:name], email: params[:email])
|
24
|
+
finish!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
20
29
|
class InheritanceTest < Test::Unit::TestCase
|
21
30
|
test ".execute does not raise error" do
|
22
31
|
params = { name: 'John'}
|
@@ -48,10 +57,10 @@ class InheritanceTest < Test::Unit::TestCase
|
|
48
57
|
assert interactor.success?
|
49
58
|
end
|
50
59
|
|
51
|
-
test "#
|
60
|
+
test "#finished? is true" do
|
52
61
|
params = { name: 'John'}
|
53
62
|
interactor = RegistrationInteractor.execute(params)
|
54
|
-
assert interactor.
|
63
|
+
assert interactor.finished?
|
55
64
|
end
|
56
65
|
|
57
66
|
test "if params is empty, #failure? is true" do
|
@@ -60,9 +69,18 @@ class InheritanceTest < Test::Unit::TestCase
|
|
60
69
|
assert interactor.failure?
|
61
70
|
end
|
62
71
|
|
63
|
-
test "if params is empty, #
|
72
|
+
test "if params is empty, #finished? is true" do
|
64
73
|
params = {}
|
65
74
|
interactor = RegistrationInteractor.execute(params)
|
66
|
-
assert interactor.
|
75
|
+
assert interactor.finished?
|
76
|
+
end
|
77
|
+
|
78
|
+
test "the result user name is Taro and email is taro@example.com" do
|
79
|
+
params = { name: 'Taro', email: 'taro@example.com'}
|
80
|
+
interactor = NotificationInteractor.execute(params)
|
81
|
+
name = interactor.result[:name]
|
82
|
+
assert_equal(name, 'Taro')
|
83
|
+
email = interactor.result[:email]
|
84
|
+
assert_equal(email, 'taro@example.com')
|
67
85
|
end
|
68
86
|
end
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Hashimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|