actioninteractor 0.0.7 → 0.0.8

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
- SHA1:
3
- metadata.gz: 46e2e0f004e78df6b070d550197fc145ce7abbad
4
- data.tar.gz: 35ee20330120b626fe75a9b287c66627a7284a18
2
+ SHA256:
3
+ metadata.gz: 56f8b129a2e8cd1e7daa107e94c086e08271c74ffb69f1f183aee686a39e05c3
4
+ data.tar.gz: 564ad42fc890791b41ae055cbf5521b474f529a161843732ca3006316faf9ba5
5
5
  SHA512:
6
- metadata.gz: 45551299b5855625a6c18ae9a82d24a1916f85724a6e656a42f375cbfcd6f7bbb95bc42700acc5666187622377e6938b1b4029e53151c14804c5cd6958d8f646
7
- data.tar.gz: 9b65500a33c5c86e9359be7af3db1a478b9157336320c2a524190cdb990f125c29750604fa62a1f22f510636d880f6a617b449fe1ddfb6a112b0c5199db78ed3
6
+ metadata.gz: c84550f329cebab3347c79bf66bf3a73fa7cadf83ee121e17da4b1f8a1bb5d9b4220f8a003852eb4d9afa595d277a66d0d970662bf821316b627736edb55f308
7
+ data.tar.gz: 31711fa714666d1c2cc16c2f0525766c360af9354325d4e63a572e2dd4d0b553f607bfc677463b5745c58ad569685e0f7e5a0fb1057fa39b2a77d16b474178ae
@@ -16,6 +16,10 @@ module ActionInteractor
16
16
  @completed
17
17
  end
18
18
 
19
+ def incomplete?
20
+ !completed?
21
+ end
22
+
19
23
  def success?
20
24
  @success
21
25
  end
@@ -24,6 +28,10 @@ module ActionInteractor
24
28
  !success?
25
29
  end
26
30
 
31
+ def aborted?
32
+ failure? && incomplete?
33
+ end
34
+
27
35
  def reset!
28
36
  @result = {}
29
37
  fail!
@@ -35,6 +43,16 @@ module ActionInteractor
35
43
  complete!
36
44
  end
37
45
 
46
+ def failed!
47
+ fail!
48
+ complete!
49
+ end
50
+
51
+ def abort!
52
+ fail!
53
+ incomplete!
54
+ end
55
+
38
56
  def success!
39
57
  @success = true
40
58
  end
data/test/base_test.rb CHANGED
@@ -30,4 +30,11 @@ class BaseTest < Test::Unit::TestCase
30
30
  interactor = ActionInteractor::Base.execute(params)
31
31
  assert interactor.completed?
32
32
  end
33
+
34
+ test "#aborted? is true after #abort!" do
35
+ params = {}
36
+ interactor = ActionInteractor::Base.execute(params)
37
+ interactor.abort!
38
+ assert interactor.aborted?
39
+ end
33
40
  end
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  class RegistrationInteractor < ActionInteractor::Base
13
13
  def execute
14
- return unless params[:name]
14
+ return failed! unless params[:name]
15
15
  add_result(:user, User.new(name: params[:name]))
16
16
  finish!
17
17
  end
@@ -53,4 +53,16 @@ class InheritanceTest < Test::Unit::TestCase
53
53
  interactor = RegistrationInteractor.execute(params)
54
54
  assert interactor.completed?
55
55
  end
56
+
57
+ test "if params is empty, #failure? is true" do
58
+ params = {}
59
+ interactor = RegistrationInteractor.execute(params)
60
+ assert interactor.failure?
61
+ end
62
+
63
+ test "if params is empty, #completed? is true" do
64
+ params = {}
65
+ interactor = RegistrationInteractor.execute(params)
66
+ assert interactor.completed?
67
+ end
56
68
  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.7
4
+ version: 0.0.8
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-06 00:00:00.000000000 Z
11
+ date: 2018-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  version: 1.8.11
72
72
  requirements: []
73
73
  rubyforge_project:
74
- rubygems_version: 2.5.2.3
74
+ rubygems_version: 2.7.6
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: Action Interactor provides a simple interface for performing operations (part