subroutine 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  module Subroutine
4
6
  class AuthTest < TestCase
5
-
6
7
  def user
7
- @user ||= ::User.new(email_address: "doug@example.com")
8
+ @user ||= ::User.new(email_address: 'doug@example.com')
8
9
  end
9
10
 
10
11
  def test_it_throws_an_error_if_authorization_is_not_defined
@@ -45,12 +46,12 @@ module Subroutine
45
46
  CustomAuthorizeOp.submit! user
46
47
 
47
48
  assert_raises ::Subroutine::Auth::NotAuthorizedError do
48
- CustomAuthorizeOp.submit! User.new(email_address: "foo@bar.com")
49
+ CustomAuthorizeOp.submit! User.new(email_address: 'foo@bar.com')
49
50
  end
50
51
  end
51
52
 
52
53
  def test_it_does_not_run_authorizations_if_explicitly_bypassed
53
- op = CustomAuthorizeOp.new User.new(email_address: "foo@bar.com")
54
+ op = CustomAuthorizeOp.new User.new(email_address: 'foo@bar.com')
54
55
  op.skip_auth_checks!
55
56
  op.submit!
56
57
  end
@@ -66,10 +67,10 @@ module Subroutine
66
67
  end
67
68
 
68
69
  def test_it_runs_policies_with_conditionals
69
- # if: false
70
+ # if: false
70
71
  op = IfConditionalPolicyOp.new(user, check_policy: false)
71
72
  assert op.submit!
72
- # unless: true
73
+ # unless: true
73
74
  op = UnlessConditionalPolicyOp.new(user, unless_check_policy: true)
74
75
  assert op.submit!
75
76
 
@@ -85,6 +86,5 @@ module Subroutine
85
86
  op.submit!
86
87
  end
87
88
  end
88
-
89
89
  end
90
90
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  module Subroutine
4
6
  class OpTest < TestCase
5
-
6
7
  def test_simple_fields_definition
7
8
  op = ::SignupOp.new
8
9
  assert_equal [:email, :password], op._fields.keys.sort
@@ -35,15 +36,15 @@ module Subroutine
35
36
 
36
37
  def test_inputs_from_ignores_except_fields
37
38
  op = ::ExceptFooBarOp.new
38
- refute op._fields.keys.include? :foo
39
- refute op._fields.keys.include? :bar
39
+ refute op._fields.key?(:foo)
40
+ refute op._fields.key?(:bar)
40
41
  assert_equal [:baz], op._fields.keys.sort
41
42
  end
42
43
 
43
44
  def test_inputs_from_only_fields
44
45
  op = ::OnlyFooBarOp.new
45
- assert op._fields.keys.include? :foo
46
- assert op._fields.keys.include? :bar
46
+ assert op._fields.key?(:foo)
47
+ assert op._fields.key?(:bar)
47
48
  refute_equal [:baz], op._fields.keys.sort
48
49
  end
49
50
 
@@ -101,18 +102,18 @@ module Subroutine
101
102
  end
102
103
 
103
104
  def test_validation_errors_can_be_inherited_and_transformed
104
- op = ::AdminSignupOp.new(:email => 'foo@bar.com', :password => 'password123')
105
+ op = ::AdminSignupOp.new(email: 'foo@bar.com', password: 'password123')
105
106
 
106
107
  refute op.submit
107
108
 
108
109
  assert op.perform_called
109
110
  refute op.perform_finished
110
111
 
111
- assert_equal ["has gotta be @admin.com"], op.errors[:email]
112
+ assert_equal ['has gotta be @admin.com'], op.errors[:email]
112
113
  end
113
114
 
114
115
  def test_when_valid_perform_completes_it_returns_control
115
- op = ::SignupOp.new(:email => 'foo@bar.com', :password => 'password123')
116
+ op = ::SignupOp.new(email: 'foo@bar.com', password: 'password123')
116
117
  op.submit!
117
118
 
118
119
  assert op.perform_called
@@ -124,7 +125,7 @@ module Subroutine
124
125
  end
125
126
 
126
127
  def test_it_raises_an_error_when_used_with_a_bang_and_performing_or_validation_fails
127
- op = ::SignupOp.new(:email => 'foo@bar.com')
128
+ op = ::SignupOp.new(email: 'foo@bar.com')
128
129
 
129
130
  err = assert_raises ::Subroutine::Failure do
130
131
  op.submit!
@@ -146,9 +147,8 @@ module Subroutine
146
147
  SignupOp.submit!
147
148
  end
148
149
 
149
- op = SignupOp.submit! :email => 'foo@bar.com', :password => 'password123'
150
+ op = SignupOp.submit! email: 'foo@bar.com', password: 'password123'
150
151
  assert_equal 'foo@bar.com', op.created_user.email_address
151
-
152
152
  end
153
153
 
154
154
  def test_it_ignores_specific_errors
@@ -159,87 +159,87 @@ module Subroutine
159
159
  def test_it_does_not_inherit_ignored_errors
160
160
  op = ::WhateverSignupOp.new
161
161
  other = ::SignupOp.new
162
- other.errors.add(:whatever, "fail")
162
+ other.errors.add(:whatever, 'fail')
163
163
  op.send(:inherit_errors, other)
164
164
  assert_equal [], op.errors[:whatever]
165
165
  end
166
166
 
167
167
  def test_it_sets_the_params_and_defaults_immediately
168
- op = ::AdminSignupOp.new(email: "foo")
168
+ op = ::AdminSignupOp.new(email: 'foo')
169
169
  assert_equal({
170
- "email" => "foo"
171
- }, op.params)
170
+ 'email' => 'foo'
171
+ }, op.params)
172
172
 
173
173
  assert_equal({
174
- "privileges" => "min",
175
- }, op.defaults)
174
+ 'privileges' => 'min'
175
+ }, op.defaults)
176
176
 
177
177
  assert_equal({
178
- "email" => "foo",
179
- "privileges" => "min",
180
- }, op.params_with_defaults)
178
+ 'email' => 'foo',
179
+ 'privileges' => 'min'
180
+ }, op.params_with_defaults)
181
181
  end
182
182
 
183
183
  def test_it_allows_defaults_to_be_overridden
184
- op = ::AdminSignupOp.new(email: "foo", privileges: nil)
184
+ op = ::AdminSignupOp.new(email: 'foo', privileges: nil)
185
185
 
186
186
  assert_equal({
187
- "email" => "foo",
188
- "privileges" => nil
189
- }, op.params)
187
+ 'email' => 'foo',
188
+ 'privileges' => nil
189
+ }, op.params)
190
190
 
191
191
  assert_equal({
192
- "privileges" => "min",
193
- }, op.defaults)
192
+ 'privileges' => 'min'
193
+ }, op.defaults)
194
194
 
195
195
  assert_equal({
196
- "email" => "foo",
197
- "privileges" => nil,
198
- }, op.params_with_defaults)
196
+ 'email' => 'foo',
197
+ 'privileges' => nil
198
+ }, op.params_with_defaults)
199
199
  end
200
200
 
201
201
  def test_it_overriding_default_does_not_alter_default
202
- op = ::AdminSignupOp.new(email: "foo")
203
- op.privileges << "bangbang"
202
+ op = ::AdminSignupOp.new(email: 'foo')
203
+ op.privileges << 'bangbang'
204
204
 
205
- op = ::AdminSignupOp.new(email: "foo", privileges: nil)
205
+ op = ::AdminSignupOp.new(email: 'foo', privileges: nil)
206
206
 
207
207
  assert_equal({
208
- "email" => "foo",
209
- "privileges" => nil
208
+ 'email' => 'foo',
209
+ 'privileges' => nil
210
210
  }, op.params)
211
211
 
212
212
  assert_equal({
213
- "privileges" => "min",
213
+ 'privileges' => 'min'
214
214
  }, op.defaults)
215
215
 
216
216
  assert_equal({
217
- "email" => "foo",
218
- "privileges" => nil,
217
+ 'email' => 'foo',
218
+ 'privileges' => nil
219
219
  }, op.params_with_defaults)
220
220
  end
221
221
 
222
222
  def test_it_overrides_defaults_with_nils
223
- op = ::AdminSignupOp.new(email: "foo", privileges: nil)
223
+ op = ::AdminSignupOp.new(email: 'foo', privileges: nil)
224
224
  assert_equal({
225
- "privileges" => nil,
226
- "email" => "foo"
227
- }, op.params)
225
+ 'privileges' => nil,
226
+ 'email' => 'foo'
227
+ }, op.params)
228
228
  end
229
229
 
230
230
  def test_it_casts_params_on_the_way_in
231
- op = ::TypeCastOp.new(integer_input: "25")
232
- assert_equal(25, op.params_with_defaults["integer_input"])
231
+ op = ::TypeCastOp.new(integer_input: '25')
232
+ assert_equal(25, op.params_with_defaults['integer_input'])
233
233
 
234
- op.decimal_input = "25.3"
235
- assert_equal(BigDecimal("25.3"), op.params_with_defaults["decimal_input"])
234
+ op.decimal_input = '25.3'
235
+ assert_equal(BigDecimal('25.3'), op.params_with_defaults['decimal_input'])
236
236
  end
237
237
 
238
238
  def test_it_allow_retrival_of_outputs
239
- op = ::SignupOp.submit!(:email => 'foo@bar.com', :password => 'password123')
239
+ op = ::SignupOp.submit!(email: 'foo@bar.com', password: 'password123')
240
240
  u = op.created_user
241
241
 
242
- assert_equal "foo@bar.com", u.email_address
242
+ assert_equal 'foo@bar.com', u.email_address
243
243
  end
244
244
 
245
245
  def test_it_raises_an_error_if_an_output_is_not_defined_but_is_set
@@ -272,12 +272,11 @@ module Subroutine
272
272
  op.submit!
273
273
  rescue Exception => e
274
274
  found = e.backtrace.detect do |msg|
275
- msg =~ /test\/support\/ops\.rb:[\d]+.+foo/
275
+ msg =~ %r{test/support/ops\.rb:[\d]+.+foo}
276
276
  end
277
277
 
278
- refute_nil found, "Expected backtrace to include original caller of foo"
278
+ refute_nil found, 'Expected backtrace to include original caller of foo'
279
279
  end
280
280
  end
281
-
282
281
  end
283
282
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  module Subroutine
4
6
  class TypeCasterTest < TestCase
5
-
6
7
  def op
7
8
  @op ||= TypeCastOp.new
8
9
  end
@@ -45,10 +46,10 @@ module Subroutine
45
46
  op.string_input = nil
46
47
  assert_nil op.string_input
47
48
 
48
- op.string_input = ""
49
- assert_equal '', op.string_input
49
+ op.string_input = "
50
+ assert_equal ", op.string_input
50
51
 
51
- op.string_input = "foo"
52
+ op.string_input = 'foo'
52
53
  assert_equal 'foo', op.string_input
53
54
 
54
55
  op.string_input = 4
@@ -106,17 +107,17 @@ module Subroutine
106
107
  op.object_input = ''
107
108
  assert_equal({}, op.object_input)
108
109
 
109
- op.object_input = [[:a,:b]]
110
- assert_equal({"a" => :b}, op.object_input)
110
+ op.object_input = [[:a, :b]]
111
+ assert_equal({ 'a' => :b }, op.object_input)
111
112
 
112
113
  op.object_input = false
113
114
  assert_equal({}, op.object_input)
114
115
 
115
- op.object_input = {foo: 'bar'}
116
- assert_equal({'foo' => 'bar'}, op.object_input)
116
+ op.object_input = { foo: 'bar' }
117
+ assert_equal({ 'foo' => 'bar' }, op.object_input)
117
118
 
118
- op.object_input = {"foo" => {"bar" => :baz}}
119
- assert_equal({"foo" => {"bar" => :baz}}, op.object_input)
119
+ op.object_input = { 'foo' => { 'bar' => :baz } }
120
+ assert_equal({ 'foo' => { 'bar' => :baz } }, op.object_input)
120
121
  end
121
122
 
122
123
  def test_array_inputs
@@ -132,15 +133,29 @@ module Subroutine
132
133
  op.array_input = ['foo']
133
134
  assert_equal ['foo'], op.array_input
134
135
 
135
- op.array_input = {"bar" => true}
136
- assert_equal [{"bar" => true}], op.array_input
136
+ op.array_input = { 'bar' => true }
137
+ assert_equal [{ 'bar' => true }], op.array_input
138
+ end
139
+
140
+ def test_typed_array_inputs
141
+ op.type_array_input = nil
142
+ assert_nil op.type_array_input
143
+
144
+ op.type_array_input = ''
145
+ assert_equal [], op.type_array_input
146
+
147
+ op.type_array_input = '3'
148
+ assert_equal [3], op.type_array_input
149
+
150
+ op.type_array_input = ['3.4']
151
+ assert_equal [3], op.type_array_input
137
152
  end
138
153
 
139
154
  def test_date_inputs
140
155
  op.date_input = nil
141
156
  assert_nil op.date_input
142
157
 
143
- op.date_input = "2022-12-22"
158
+ op.date_input = '2022-12-22'
144
159
  assert_equal ::Date, op.date_input.class
145
160
  refute_equal ::DateTime, op.date_input.class
146
161
 
@@ -148,7 +163,7 @@ module Subroutine
148
163
  assert_equal 12, op.date_input.month
149
164
  assert_equal 22, op.date_input.day
150
165
 
151
- op.date_input = "2023-05-05T10:00:30"
166
+ op.date_input = '2023-05-05T10:00:30'
152
167
  assert_equal ::Date, op.date_input.class
153
168
  refute_equal ::DateTime, op.date_input.class
154
169
 
@@ -156,7 +171,7 @@ module Subroutine
156
171
  assert_equal 5, op.date_input.month
157
172
  assert_equal 5, op.date_input.day
158
173
 
159
- op.date_input = "2020-05-03 13:44:45 -0400"
174
+ op.date_input = '2020-05-03 13:44:45 -0400'
160
175
 
161
176
  assert_equal ::Date, op.date_input.class
162
177
  refute_equal ::DateTime, op.date_input.class
@@ -169,12 +184,11 @@ module Subroutine
169
184
  assert_nil op.date_input
170
185
  end
171
186
 
172
-
173
187
  def test_time_inputs
174
188
  op.time_input = nil
175
189
  assert_nil op.time_input
176
190
 
177
- op.time_input = "2022-12-22"
191
+ op.time_input = '2022-12-22'
178
192
  assert_equal ::Time, op.time_input.class
179
193
  refute_equal ::DateTime, op.time_input.class
180
194
 
@@ -185,7 +199,7 @@ module Subroutine
185
199
  assert_equal 0, op.time_input.min
186
200
  assert_equal 0, op.time_input.sec
187
201
 
188
- op.time_input = "2023-05-05T10:00:30Z"
202
+ op.time_input = '2023-05-05T10:00:30Z'
189
203
  assert_equal ::Time, op.time_input.class
190
204
  refute_equal ::DateTime, op.time_input.class
191
205
 
@@ -201,41 +215,55 @@ module Subroutine
201
215
  op.iso_date_input = nil
202
216
  assert_nil op.iso_date_input
203
217
 
204
- op.iso_date_input = "2022-12-22"
218
+ op.iso_date_input = '2022-12-22'
205
219
  assert_equal ::String, op.iso_date_input.class
206
- assert_equal "2022-12-22", op.iso_date_input
220
+ assert_equal '2022-12-22', op.iso_date_input
207
221
 
208
- op.iso_date_input = Date.parse("2022-12-22")
222
+ op.iso_date_input = Date.parse('2022-12-22')
209
223
  assert_equal ::String, op.iso_date_input.class
210
- assert_equal "2022-12-22", op.iso_date_input
224
+ assert_equal '2022-12-22', op.iso_date_input
211
225
  end
212
226
 
213
227
  def test_iso_time_inputs
214
228
  op.iso_time_input = nil
215
229
  assert_nil op.iso_time_input
216
230
 
217
- op.iso_time_input = "2022-12-22T10:30:24Z"
231
+ op.iso_time_input = '2022-12-22T10:30:24Z'
218
232
  assert_equal ::String, op.iso_time_input.class
219
- assert_equal "2022-12-22T10:30:24Z", op.iso_time_input
233
+ assert_equal '2022-12-22T10:30:24Z', op.iso_time_input
220
234
 
221
- op.iso_time_input = Time.parse("2022-12-22T10:30:24Z")
235
+ op.iso_time_input = Time.parse('2022-12-22T10:30:24Z')
222
236
  assert_equal ::String, op.iso_time_input.class
223
- assert_equal "2022-12-22T10:30:24Z", op.iso_time_input
237
+ assert_equal '2022-12-22T10:30:24Z', op.iso_time_input
238
+ end
239
+
240
+ def test_file_inputs
241
+ op.file_input = nil
242
+ assert_nil op.file_input
243
+
244
+ op.file_input = File.new(__FILE__)
245
+ assert_equal ::File, op.file_input.class
246
+
247
+ op.file_input = 'foobarbaz'
248
+ assert_equal ::Tempfile, op.file_input.class
249
+ assert_equal 'foobarbaz', op.file_input.read
250
+ ensure
251
+ op.file_input.close
252
+ op.file_input.unlink
224
253
  end
225
254
 
226
255
  def test_field_provided
227
- op = ::SignupOp.new()
256
+ op = ::SignupOp.new
228
257
  assert_equal false, op.send(:field_provided?, :email)
229
258
 
230
- op = ::SignupOp.new(email: "foo")
259
+ op = ::SignupOp.new(email: 'foo')
231
260
  assert_equal true, op.send(:field_provided?, :email)
232
261
 
233
- op = ::DefaultsOp.new()
262
+ op = ::DefaultsOp.new
234
263
  assert_equal false, op.send(:field_provided?, :foo)
235
264
 
236
- op = ::DefaultsOp.new(foo: "foo")
265
+ op = ::DefaultsOp.new(foo: 'foo')
237
266
  assert_equal true, op.send(:field_provided?, :foo)
238
267
  end
239
-
240
268
  end
241
269
  end
data/test/support/ops.rb CHANGED
@@ -1,5 +1,7 @@
1
- require "subroutine/auth"
2
- require "subroutine/association"
1
+ # frozen_string_literal: true
2
+
3
+ require 'subroutine/auth'
4
+ require 'subroutine/association'
3
5
 
4
6
  ## Models ##
5
7
 
@@ -10,23 +12,21 @@ class User
10
12
  attr_accessor :email_address
11
13
  attr_accessor :password
12
14
 
13
- validates :email_address, :presence => true
15
+ validates :email_address, presence: true
14
16
  end
15
17
 
16
18
  class AdminUser < ::User
17
- validates :email_address, :format => {:with => /@admin\.com/, :message => 'has gotta be @admin.com'}
19
+ validates :email_address, format: { with: /@admin\.com/, message: 'has gotta be @admin.com' }
18
20
  end
19
21
 
20
-
21
22
  ## Ops ##
22
23
 
23
24
  class SignupOp < ::Subroutine::Op
24
-
25
- string :email, :aka => :email_address
25
+ string :email, aka: :email_address
26
26
  string :password
27
27
 
28
- validates :email, :presence => true
29
- validates :password, :presence => true
28
+ validates :email, presence: true
29
+ validates :password, presence: true
30
30
 
31
31
  outputs :perform_called
32
32
  outputs :perform_finished
@@ -66,42 +66,37 @@ class WhateverSignupOp < ::SignupOp
66
66
  end
67
67
 
68
68
  class AdminSignupOp < ::SignupOp
69
-
70
- field :privileges, :default => 'min'
69
+ field :privileges, default: 'min'
71
70
 
72
71
  protected
73
72
 
74
73
  def user_class
75
74
  ::AdminUser
76
75
  end
77
-
78
76
  end
79
77
 
80
78
  class BusinessSignupOp < ::Subroutine::Op
81
-
82
79
  string :business_name
83
80
 
84
81
  inputs_from ::SignupOp
85
82
  end
86
83
 
87
84
  class DefaultsOp < ::Subroutine::Op
88
-
89
- field :foo, :default => 'foo'
90
- field :bar, :default => 'bar'
91
- field :baz, :default => false
92
-
85
+ field :foo, default: 'foo'
86
+ field :bar, default: 'bar'
87
+ field :baz, default: false
93
88
  end
94
89
 
95
90
  class ExceptFooBarOp < ::Subroutine::Op
96
- inputs_from ::DefaultsOp, except: %i[foo bar]
91
+ inputs_from ::DefaultsOp, except: [:foo, :bar]
97
92
  end
98
93
 
99
94
  class OnlyFooBarOp < ::Subroutine::Op
100
- inputs_from ::DefaultsOp, only: %i[foo bar]
95
+ inputs_from ::DefaultsOp, only: [:foo, :bar]
101
96
  end
102
97
 
103
98
  class InheritedDefaultsOp < ::DefaultsOp
104
- field :bar, :default => 'barstool'
99
+ field :bar, default: 'barstool'
105
100
  end
106
101
 
107
102
  class TypeCastOp < ::Subroutine::Op
@@ -111,11 +106,13 @@ class TypeCastOp < ::Subroutine::Op
111
106
  string :string_input
112
107
  boolean :boolean_input
113
108
  date :date_input
114
- time :time_input, :default => lambda{ Time.now }
109
+ time :time_input, default: -> { Time.now }
115
110
  iso_date :iso_date_input
116
111
  iso_time :iso_time_input
117
112
  object :object_input
118
- array :array_input, :default => 'foo'
113
+ array :array_input, default: 'foo'
114
+ array :type_array_input, of: :integer
115
+ file :file_input
119
116
  end
120
117
 
121
118
  class OpWithAuth < ::Subroutine::Op
@@ -141,21 +138,17 @@ class NoUserRequirementsOp < OpWithAuth
141
138
  end
142
139
 
143
140
  class CustomAuthorizeOp < OpWithAuth
144
-
145
141
  require_user!
146
142
  authorize :authorize_user_is_correct
147
143
 
148
144
  protected
149
145
 
150
146
  def authorize_user_is_correct
151
- unless current_user.email_address.to_s =~ /example\.com$/
152
- unauthorized!
153
- end
147
+ unauthorized! unless current_user.email_address.to_s =~ /example\.com$/
154
148
  end
155
149
  end
156
150
 
157
151
  class PolicyOp < OpWithAuth
158
-
159
152
  class FakePolicy
160
153
  def user_can_access?
161
154
  false
@@ -171,7 +164,6 @@ class PolicyOp < OpWithAuth
171
164
  end
172
165
 
173
166
  class IfConditionalPolicyOp < OpWithAuth
174
-
175
167
  class FakePolicy
176
168
  def user_can_access?
177
169
  false
@@ -180,7 +172,7 @@ class IfConditionalPolicyOp < OpWithAuth
180
172
 
181
173
  require_user!
182
174
  boolean :check_policy
183
- validates :check_policy, inclusion: { in: [true,false] }
175
+ validates :check_policy, inclusion: { in: [true, false] }
184
176
  policy :user_can_access?, if: :check_policy
185
177
 
186
178
  def policy
@@ -189,7 +181,6 @@ class IfConditionalPolicyOp < OpWithAuth
189
181
  end
190
182
 
191
183
  class UnlessConditionalPolicyOp < OpWithAuth
192
-
193
184
  class FakePolicy
194
185
  def user_can_access?
195
186
  false
@@ -198,7 +189,7 @@ class UnlessConditionalPolicyOp < OpWithAuth
198
189
 
199
190
  require_user!
200
191
  boolean :unless_check_policy
201
- validates :unless_check_policy, inclusion: { in: [true,false] }
192
+ validates :unless_check_policy, inclusion: { in: [true, false] }
202
193
  policy :user_can_access?, unless: :unless_check_policy
203
194
 
204
195
  def policy
@@ -206,15 +197,12 @@ class UnlessConditionalPolicyOp < OpWithAuth
206
197
  end
207
198
  end
208
199
 
209
-
210
200
  class OpWithAssociation < ::Subroutine::Op
211
201
  include ::Subroutine::Association
212
202
  end
213
203
 
214
204
  class SimpleAssociationOp < ::OpWithAssociation
215
-
216
205
  association :user
217
-
218
206
  end
219
207
 
220
208
  class UnscopedSimpleAssociationOp < ::OpWithAssociation
@@ -226,7 +214,7 @@ class PolymorphicAssociationOp < ::OpWithAssociation
226
214
  end
227
215
 
228
216
  class AssociationWithClassOp < ::OpWithAssociation
229
- association :admin, class_name: "AdminUser"
217
+ association :admin, class_name: 'AdminUser'
230
218
  end
231
219
 
232
220
  class InheritedSimpleAssociation < ::Subroutine::Op
@@ -249,7 +237,7 @@ end
249
237
 
250
238
  class MissingOutputOp < ::Subroutine::Op
251
239
  def perform
252
- output :foo, "bar"
240
+ output :foo, 'bar'
253
241
  end
254
242
  end
255
243
 
@@ -270,19 +258,18 @@ end
270
258
  class NoOutputNoSuccessOp < ::Subroutine::Op
271
259
  outputs :foo
272
260
  def perform
273
- errors.add(:foo, "bar")
261
+ errors.add(:foo, 'bar')
274
262
  end
275
263
  end
276
264
 
277
265
  class ErrorTraceOp < ::Subroutine::Op
278
-
279
266
  class SomeObject
280
267
  include ::ActiveModel::Model
281
268
  include ::ActiveModel::Validations::Callbacks
282
269
 
283
270
  def foo
284
- errors.add(:base, "Failure of things")
285
- raise Subroutine::Failure.new(self)
271
+ errors.add(:base, 'Failure of things')
272
+ raise Subroutine::Failure, self
286
273
  end
287
274
 
288
275
  def bar
data/test/test_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'subroutine'
2
4
  require 'minitest/autorun'
3
5
  require 'minitest/unit'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subroutine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-17 00:00:00.000000000 Z
11
+ date: 2019-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel