subroutine 0.10.0.beta7 → 0.10.0.beta8

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: 27287a4d05110ba46ae806e8e3b38f4598c0bb8f69fbdb97f41a53eea025e955
4
- data.tar.gz: 22da96f1411d3887a41f42a2a7ca493587ed404aa5760da45447c7ba443dd6ef
3
+ metadata.gz: 4c5dff0a8ab49afebd76be4189b3128c27f6f79786a4745fb01a9b18b023ea44
4
+ data.tar.gz: 1329a8feaedde19122bb3afbca4eda13818dcb720b9edc0b01cd58e3422c4463
5
5
  SHA512:
6
- metadata.gz: 8cef15bcb25e9792eee2a0073f9d428784cda0370aa40c49881db5e124821b9c0036e83cdfc173233f4a4a76ea8be1ce842a0b309bdd02023f7e1333219f19a6
7
- data.tar.gz: e0797ab6a5153718d02ef4bb9d7dbeed5f793a8ef574d504627c2c109ff8147a8ed290cc555c08a5dd62cb5f226998d40faec1d8a6f14a10163d93b6974d1892
6
+ metadata.gz: 2acf6bdb0f20e14dbf24155a3e4d80db6715d7eb9ab6869d0ef2b07a7cf7efd2ef9b4287827fcf25d0877c5910e979885e8fa5fe84256d16479bc47340b7cd04
7
+ data.tar.gz: b0c826a03266eeafd1db07597c0c70c43065b73780137182129310238e0e74c04505d83a207dc1357ba20c5b00cfd1107c3d9d92152213961c7256ec4fb10fee
@@ -36,15 +36,26 @@ module Subroutine
36
36
  end
37
37
 
38
38
  def setup_outputs
39
- @outputs = {}.with_indifferent_access
39
+ @outputs = {} # don't do with_indifferent_access because it will turn provided objects into with_indifferent_access objects, which may not be the desired behavior
40
+ end
41
+
42
+ def output_provided?(name)
43
+ name = name.to_sym
44
+
45
+ unless output_configurations.key?(name)
46
+ raise ::Subroutine::Outputs::UnknownOutputError, name
47
+ end
48
+
49
+ outputs.key?(name)
40
50
  end
41
51
 
42
52
  def output(name, value)
43
- unless output_configurations.key?(name.to_sym)
53
+ name = name.to_sym
54
+ unless output_configurations.key?(name)
44
55
  raise ::Subroutine::Outputs::UnknownOutputError, name
45
56
  end
46
57
 
47
- outputs[name.to_sym] = value
58
+ outputs[name] = value
48
59
  end
49
60
 
50
61
  def get_output(name)
@@ -56,7 +67,7 @@ module Subroutine
56
67
 
57
68
  def validate_outputs!
58
69
  output_configurations.each_pair do |name, config|
59
- if config.required? && !outputs.key?(name)
70
+ if config.required? && !output_provided?(name)
60
71
  raise ::Subroutine::Outputs::OutputNotSetError, name
61
72
  end
62
73
  end
@@ -5,7 +5,7 @@ module Subroutine
5
5
  MAJOR = 0
6
6
  MINOR = 10
7
7
  PATCH = 0
8
- PRE = "beta7"
8
+ PRE = "beta8"
9
9
 
10
10
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
 
@@ -228,6 +228,16 @@ module Subroutine
228
228
  assert_equal "foo@bar.com", u.email_address
229
229
  end
230
230
 
231
+ # Hash#with_indifferent_access was changing output objects
232
+ def test_outputs_are_not_mutated
233
+ out = { "foo" => "bar" }
234
+ op = ::SignupOp.new
235
+ op.send :output, :perform_called, out
236
+ value = op.perform_called
237
+ assert_equal out, value
238
+ assert_equal Hash, value.class
239
+ end
240
+
231
241
  def test_it_raises_an_error_if_an_output_is_not_defined_but_is_set
232
242
  op = ::MissingOutputOp.new
233
243
  assert_raises ::Subroutine::Outputs::UnknownOutputError do
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.10.0.beta7
4
+ version: 0.10.0.beta8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-25 00:00:00.000000000 Z
11
+ date: 2020-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel