actioninteractor 0.0.15 → 0.0.16

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: 1cf59e621fd60a8cfb99220e97d08b679bc639a38d161e4c3254720969f761c6
4
- data.tar.gz: bdbd3020978080ea42f44a17424c9f0ae71787ebd8fe37cbbe9e2b00569ea70a
3
+ metadata.gz: cef520c222e604cb756a2d86025c65c18e13e7cb989a28d424953ce1eeb1e0b0
4
+ data.tar.gz: f62278ed5410aebd05a6541ef8bcd578b32fcb8b3a5f6b74972b491f2a9709e8
5
5
  SHA512:
6
- metadata.gz: d55546b260465dedecc262964d10001f2e12964af2d6bc2d35a4546eaa6aed91131c109590a86b68b901b7fdcb64d3b180a77c4df712e139ce839fd8ebe16691
7
- data.tar.gz: 01c4533072dd4020a359257e516b35fac8f80b316eadd2000e63de3b350aa81ae0d2f616357365fdecfadde5331bdad37cdc39a62b948448b39c0de4cd70323b
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
@@ -13,10 +13,16 @@ class BaseTest < Test::Unit::TestCase
13
13
  assert_instance_of(ActionInteractor::Base, interactor)
14
14
  end
15
15
 
16
- test "the result is an empty hash" do
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
- assert_equal({}, interactor.result)
25
+ assert_instance_of(ActionInteractor::Results, interactor.results)
20
26
  end
21
27
 
22
28
  test "#success? is true" do
@@ -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.15
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: 2018-12-25 00:00:00.000000000 Z
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
- rubyforge_project:
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