interactor_with_steroids 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a641ca1acbb8c2de2ec87757ef54c644189997860477ccdbfd138ded126ccd3b
4
- data.tar.gz: c5d85b0aa88784f4b60c5dafbc49338d7508674f589528a75671568dcc697383
3
+ metadata.gz: 67bd7f73460605c15913de2b7600e2688ce69d3522aa977ebbdaa7b48dfb7174
4
+ data.tar.gz: 7ea029bbf6175cdda0daef695c3adb2203c56d2f17e071c8ae5a6d51c45db8ff
5
5
  SHA512:
6
- metadata.gz: e703700a5efd8100e78c846fd31aa9b6ee1bd535608f8bfb92f6d8512804e279e73b2a62f2b9d70bcd822a1cbd1e0ad16012d6d874aa519bf2edf32682c209b4
7
- data.tar.gz: 55c97b6ad6da3e4f9f35ccc6be6df32414e8bf12a00c3c865af9fe72dfa3d19ab895e53d1bf7fd182b3994d91dbbb0aeb7f57de7097edeca67c68bcc7ccaf84b
6
+ metadata.gz: afe86c28c86697ed2a72a39a6fc255ed52862220a987eb86390466d2a04f50102780fe0ca62fa1ec2f54ae257e5f388235d00fd14e17d2f58616bf34c8bbf9f0
7
+ data.tar.gz: a5c27b60c2f6058d079d2962035866bea1587e2183d1ac66219410dc42d6d5666b1f231e50cbc5eec9b5b6e9c516b9674d92d065e72ae36a758fedbeed27d8de
data/interactor.gemspec CHANGED
@@ -2,7 +2,7 @@ require "English"
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "interactor_with_steroids"
5
- spec.version = "1.5.0"
5
+ spec.version = "1.5.1"
6
6
 
7
7
  spec.author = "Collective Idea/Sorare Team"
8
8
  spec.email = "hello@sorare.com"
@@ -18,7 +18,8 @@ module Interactor
18
18
  new_required_arguments = required_arguments - @required_arguments
19
19
  @required_arguments += new_required_arguments
20
20
 
21
- (required_arguments + optional_arguments.keys).each { |arg| received_arguments << arg }
21
+ required_arguments.each { |arg| received_arguments << arg }
22
+ optional_arguments.keys.each { |arg| received_optional_arguments << arg }
22
23
 
23
24
  delegate(*new_required_arguments, to: :context) unless new_required_arguments.empty?
24
25
  delegate(*optional_arguments.keys, to: :context) unless optional_arguments.empty?
@@ -69,6 +70,10 @@ module Interactor
69
70
  @received_arguments ||= []
70
71
  end
71
72
 
73
+ def received_optional_arguments
74
+ @received_optional_arguments ||= []
75
+ end
76
+
72
77
  def hold(*held_fields, **held_fields_with_default_value)
73
78
  attributes = [*held_fields, *held_fields_with_default_value.keys]
74
79
  delegate(*attributes, to: :context)
@@ -83,11 +83,11 @@ module Interactor
83
83
  end
84
84
 
85
85
  context 'with a nil default value' do
86
- let(:declared) {
86
+ let(:declared) do
87
87
  build_declared do
88
88
  receive foo: nil
89
89
  end
90
- }
90
+ end
91
91
 
92
92
  it 'can be initialized without foo' do
93
93
  expect(subject.build.foo).to be nil
@@ -99,11 +99,11 @@ module Interactor
99
99
  end
100
100
 
101
101
  context 'with a Proc default value' do
102
- let(:declared) {
102
+ let(:declared) do
103
103
  build_declared do
104
104
  receive :bar, foo: ->(context) { context.bar }
105
105
  end
106
- }
106
+ end
107
107
 
108
108
  it 'can be initialized without foo' do
109
109
  expect(subject.build(bar: 'bar').foo).to eq('bar')
@@ -114,18 +114,19 @@ module Interactor
114
114
  end
115
115
 
116
116
  it 'can introspect the received arguments' do
117
- expect(declared.received_arguments).to eq(%i[bar foo])
117
+ expect(declared.received_arguments).to eq(%i[bar])
118
+ expect(declared.received_optional_arguments).to eq(%i[foo])
118
119
  end
119
120
  end
120
121
  end
121
122
  end
122
123
 
123
124
  describe '#hold' do
124
- let(:declared) {
125
+ let(:declared) do
125
126
  build_declared do
126
127
  hold :foo
127
128
  end
128
- }
129
+ end
129
130
 
130
131
  it 'can hold foo' do
131
132
  c = subject.build
@@ -138,11 +139,11 @@ module Interactor
138
139
  end
139
140
 
140
141
  context 'with default value' do
141
- let(:declared) {
142
+ let(:declared) do
142
143
  build_declared do
143
144
  hold foo: 'bar'
144
145
  end
145
- }
146
+ end
146
147
 
147
148
  it 'can hold foo with default value' do
148
149
  c = subject.build
@@ -153,11 +154,11 @@ module Interactor
153
154
  end
154
155
 
155
156
  context 'when default value is a proc' do
156
- let(:declared) {
157
+ let(:declared) do
157
158
  build_declared do
158
159
  hold foo: proc { [] }
159
160
  end
160
- }
161
+ end
161
162
 
162
163
  it 'can hold foo with default value different for each new context through proc' do
163
164
  c = subject.build
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interactor_with_steroids
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Collective Idea/Sorare Team