active_interaction 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -1
  3. data/README.md +3 -3
  4. data/lib/active_interaction.rb +1 -1
  5. data/lib/active_interaction/base.rb +1 -1
  6. data/lib/active_interaction/errors.rb +20 -0
  7. data/lib/active_interaction/filters/hash_filter.rb +9 -4
  8. data/lib/active_interaction/locale/en.yml +1 -0
  9. data/lib/active_interaction/modules/validation.rb +16 -4
  10. data/lib/active_interaction/version.rb +1 -1
  11. data/spec/active_interaction/base_spec.rb +10 -10
  12. data/spec/active_interaction/concerns/active_modelable_spec.rb +11 -8
  13. data/spec/active_interaction/concerns/missable_spec.rb +1 -1
  14. data/spec/active_interaction/concerns/runnable_spec.rb +3 -3
  15. data/spec/active_interaction/errors_spec.rb +9 -9
  16. data/spec/active_interaction/filter_spec.rb +1 -1
  17. data/spec/active_interaction/filters/array_filter_spec.rb +4 -4
  18. data/spec/active_interaction/filters/date_filter_spec.rb +3 -3
  19. data/spec/active_interaction/filters/date_time_filter_spec.rb +3 -3
  20. data/spec/active_interaction/filters/file_filter_spec.rb +1 -1
  21. data/spec/active_interaction/filters/float_filter_spec.rb +3 -3
  22. data/spec/active_interaction/filters/hash_filter_spec.rb +26 -4
  23. data/spec/active_interaction/filters/integer_filter_spec.rb +3 -3
  24. data/spec/active_interaction/filters/model_filter_spec.rb +6 -6
  25. data/spec/active_interaction/filters/string_filter_spec.rb +3 -3
  26. data/spec/active_interaction/filters/symbol_filter_spec.rb +2 -2
  27. data/spec/active_interaction/filters/time_filter_spec.rb +3 -3
  28. data/spec/active_interaction/integration/array_interaction_spec.rb +2 -2
  29. data/spec/active_interaction/integration/hash_interaction_spec.rb +2 -2
  30. data/spec/active_interaction/integration/time_interaction_spec.rb +2 -2
  31. data/spec/active_interaction/modules/validation_spec.rb +4 -4
  32. data/spec/support/filters.rb +7 -7
  33. data/spec/support/interactions.rb +3 -3
  34. metadata +31 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97372d5791c4be395f259a22c60747a6dfcfc54d
4
- data.tar.gz: fa1052eb313ccc7ed6011ae9565475baea6e498c
3
+ metadata.gz: 57e566015dd952d744123dd2471da57d7b9ba9ea
4
+ data.tar.gz: 17d15bb89957162cbc25479595d1bb43cec54ef5
5
5
  SHA512:
6
- metadata.gz: d97ff17b686cf96e42a93c6b6780d99a1a6c9b6e7c8f080ccff7400da960eb6ecc9577836cb36eaf1a80cf9048c840b806ff4b5135838ec2734b5c2c580da3b8
7
- data.tar.gz: 7fbe1d890c31c34433e33f1cfd8f8ed22efaea8954bda90df2dedb19fb276aa75fa74bd48b45cf174066d0eca0ac443568723b8dbe811a139fccc070fb35cd67
6
+ metadata.gz: 1a93ea6f2cd2a63854ee2a4418994c9a41dc46c63d83208f4281da9e3d8f786cf23b0891d28b2a0909ffabdeaf47e0caec5957d7762127447ec97caa59867679
7
+ data.tar.gz: e6386cde98bec96a9da6564b74809a824539b400535dd7608fb446741d353d1181a6d2b3b9c39deb706e19f8cef8747a10c8e7479df5f9e32d1942591e7b8418
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # [Master][]
2
2
 
3
+ # [1.1.6][] (2014-04-29)
4
+
5
+ - Fix a bug that caused nested hash error messages to be misleading.
6
+
3
7
  # [1.1.5][] (2014-03-31)
4
8
 
5
9
  - The `transform_keys` method broke backwards compatibility because it's not available until Rails 4.0.2.
@@ -178,7 +182,8 @@
178
182
 
179
183
  - Initial release.
180
184
 
181
- [Master]: https://github.com/orgsync/active_interaction/compare/v1.1.5...master
185
+ [Master]: https://github.com/orgsync/active_interaction/compare/v1.1.6...master
186
+ [1.1.6]: https://github.com/orgsync/active_interaction/compare/v1.1.5...v1.1.6
182
187
  [1.1.5]: https://github.com/orgsync/active_interaction/compare/v1.1.4...v1.1.5
183
188
  [1.1.4]: https://github.com/orgsync/active_interaction/compare/v1.1.3...v1.1.4
184
189
  [1.1.3]: https://github.com/orgsync/active_interaction/compare/v1.1.2...v1.1.3
data/README.md CHANGED
@@ -280,15 +280,15 @@ ActiveInteraction is brought to you by [@AaronLasseigne][14] and
280
280
  work done in [Mutations][17].
281
281
 
282
282
  [0]: https://github.com/orgsync/active_interaction
283
- [1]: https://badge.fury.io/rb/active_interaction.png
283
+ [1]: https://badge.fury.io/rb/active_interaction.svg
284
284
  [2]: https://badge.fury.io/rb/active_interaction "Gem Version"
285
- [3]: https://travis-ci.org/orgsync/active_interaction.png?branch=master
285
+ [3]: https://travis-ci.org/orgsync/active_interaction.svg?branch=master
286
286
  [4]: https://travis-ci.org/orgsync/active_interaction "Build Status"
287
287
  [5]: https://coveralls.io/repos/orgsync/active_interaction/badge.png?branch=master
288
288
  [6]: https://coveralls.io/r/orgsync/active_interaction?branch=master "Coverage Status"
289
289
  [7]: https://codeclimate.com/github/orgsync/active_interaction.png
290
290
  [8]: https://codeclimate.com/github/orgsync/active_interaction "Code Climate"
291
- [9]: https://gemnasium.com/orgsync/active_interaction.png
291
+ [9]: https://gemnasium.com/orgsync/active_interaction.svg
292
292
  [10]: https://gemnasium.com/orgsync/active_interaction "Dependency Status"
293
293
  [11]: http://orgsync.github.io/active_interaction/
294
294
  [12]: http://rubydoc.info/github/orgsync/active_interaction
@@ -41,5 +41,5 @@ I18n.load_path << File.expand_path(
41
41
  #
42
42
  # @since 1.0.0
43
43
  #
44
- # @version 1.1.5
44
+ # @version 1.1.6
45
45
  module ActiveInteraction end
@@ -206,7 +206,7 @@ module ActiveInteraction
206
206
  self.class.filters.each do |name, filter|
207
207
  begin
208
208
  public_send("#{name}=", filter.clean(inputs[name]))
209
- rescue InvalidValueError, MissingValueError
209
+ rescue InvalidValueError, MissingValueError, InvalidNestedValueError
210
210
  # Validators (#input_errors) will add errors if appropriate.
211
211
  end
212
212
  end
@@ -47,6 +47,26 @@ module ActiveInteraction
47
47
  # @return [Class]
48
48
  NoDefaultError = Class.new(Error)
49
49
 
50
+ # Raised if a user-supplied value to a nested hash input is invalid.
51
+ #
52
+ # @return [Class]
53
+ class InvalidNestedValueError < Error
54
+ # @return [Symbol]
55
+ attr_reader :filter_name
56
+
57
+ # @return [Object]
58
+ attr_reader :input_value
59
+
60
+ # @param filter_name [Symbol]
61
+ # @param input_value [Object]
62
+ def initialize(filter_name, input_value)
63
+ super()
64
+
65
+ @filter_name = filter_name
66
+ @input_value = input_value
67
+ end
68
+ end
69
+
50
70
  # Used by {Runnable} to signal a failure when composing.
51
71
  #
52
72
  # @private
@@ -30,11 +30,10 @@ module ActiveInteraction
30
30
  def cast(value)
31
31
  case value
32
32
  when Hash
33
- value = symbolize_the_string_keys(value)
33
+ value = stringify_the_symbol_keys(value)
34
34
 
35
35
  filters.each_with_object(strip? ? {} : value) do |(name, filter), h|
36
- name = name.to_s
37
- h[name] = filter.clean(value[name])
36
+ clean_value(h, name.to_s, filter, value)
38
37
  end.symbolize_keys
39
38
  else
40
39
  super
@@ -53,6 +52,12 @@ module ActiveInteraction
53
52
 
54
53
  private
55
54
 
55
+ def clean_value(h, name, filter, value)
56
+ h[name] = filter.clean(value[name])
57
+ rescue InvalidValueError, MissingValueError
58
+ raise InvalidNestedValueError.new(name, value[name])
59
+ end
60
+
56
61
  def raw_default
57
62
  value = super
58
63
 
@@ -69,7 +74,7 @@ module ActiveInteraction
69
74
  end
70
75
 
71
76
  # Switch to `transform_keys` once we support only Rails 4.0.2+
72
- def symbolize_the_string_keys(hash)
77
+ def stringify_the_symbol_keys(hash)
73
78
  new_hash = {}
74
79
  hash.each_key do |key|
75
80
  new_key = key.is_a?(Symbol) ? key.to_s : key
@@ -3,6 +3,7 @@ en:
3
3
  errors:
4
4
  messages:
5
5
  invalid: is invalid
6
+ invalid_nested: has an invalid nested value (%{name} => %{value})
6
7
  invalid_type: is not a valid %{type}
7
8
  missing: is required
8
9
  types:
@@ -11,16 +11,28 @@ module ActiveInteraction
11
11
  filters.each_with_object([]) do |(name, filter), errors|
12
12
  begin
13
13
  filter.cast(inputs[name])
14
- rescue InvalidValueError
15
- errors << [name, :invalid_type, nil, type: type(filter)]
16
- rescue MissingValueError
17
- errors << [name, :missing]
14
+ rescue InvalidNestedValueError,
15
+ InvalidValueError,
16
+ MissingValueError => e
17
+ errors << error_args(filter, e)
18
18
  end
19
19
  end
20
20
  end
21
21
 
22
22
  private
23
23
 
24
+ def self.error_args(filter, error)
25
+ case error
26
+ when InvalidNestedValueError
27
+ [filter.name, :invalid_nested, nil,
28
+ name: e.filter_name.inspect, value: e.input_value.inspect]
29
+ when InvalidValueError
30
+ [filter.name, :invalid_type, nil, type: type(filter)]
31
+ when MissingValueError
32
+ [filter.name, :missing]
33
+ end
34
+ end
35
+
24
36
  # @param filter [Filter]
25
37
  def self.type(filter)
26
38
  I18n.translate("#{Base.i18n_scope}.types.#{filter.class.slug}")
@@ -5,5 +5,5 @@ module ActiveInteraction
5
5
  # The version number.
6
6
  #
7
7
  # @return [Gem::Version]
8
- VERSION = Gem::Version.new('1.1.5')
8
+ VERSION = Gem::Version.new('1.1.6')
9
9
  end
@@ -67,7 +67,7 @@ describe ActiveInteraction::Base do
67
67
  before { inputs.merge!(thing: thing) }
68
68
 
69
69
  it 'sets the attribute' do
70
- expect(interaction.thing).to eq thing
70
+ expect(interaction.thing).to eql thing
71
71
  end
72
72
 
73
73
  context 'failing validations' do
@@ -126,12 +126,12 @@ describe ActiveInteraction::Base do
126
126
  end
127
127
 
128
128
  it 'returns the description' do
129
- expect(described_class.desc(desc)).to eq desc
129
+ expect(described_class.desc(desc)).to eql desc
130
130
  end
131
131
 
132
132
  it 'saves the description' do
133
133
  described_class.desc(desc)
134
- expect(described_class.desc).to eq desc
134
+ expect(described_class.desc).to eql desc
135
135
  end
136
136
  end
137
137
 
@@ -229,11 +229,11 @@ describe ActiveInteraction::Base do
229
229
  end
230
230
 
231
231
  it 'has errors' do
232
- expect(outcome.errors.messages[:thing]).to eq %w(error error)
232
+ expect(outcome.errors.messages[:thing]).to eql %w(error error)
233
233
  end
234
234
 
235
235
  it 'has symbolic errors' do
236
- expect(outcome.errors.symbolic[:thing]).to eq [:error]
236
+ expect(outcome.errors.symbolic[:thing]).to eql [:error]
237
237
  end
238
238
  end
239
239
 
@@ -242,7 +242,7 @@ describe ActiveInteraction::Base do
242
242
  end
243
243
 
244
244
  it 'sets the result' do
245
- expect(result[:thing]).to eq thing
245
+ expect(result[:thing]).to eql thing
246
246
  end
247
247
 
248
248
  it 'calls ActiveRecord::Base.transaction' do
@@ -269,7 +269,7 @@ describe ActiveInteraction::Base do
269
269
  before { inputs.merge!(thing: thing) }
270
270
 
271
271
  it 'returns the result' do
272
- expect(result[:thing]).to eq thing
272
+ expect(result[:thing]).to eql thing
273
273
  end
274
274
  end
275
275
  end
@@ -304,7 +304,7 @@ describe ActiveInteraction::Base do
304
304
  end
305
305
 
306
306
  it 'returns the sum' do
307
- expect(result).to eq x + y
307
+ expect(result).to eql x + y
308
308
  end
309
309
  end
310
310
 
@@ -390,7 +390,7 @@ describe ActiveInteraction::Base do
390
390
  include_context 'import_filters context'
391
391
 
392
392
  it 'imports the filters' do
393
- expect(described_class.filters).to eq klass.filters
393
+ expect(described_class.filters).to eql klass.filters
394
394
  .select { |k, _| only.nil? ? true : [*only].include?(k) }
395
395
  .reject { |k, _| except.nil? ? false : [*except].include?(k) }
396
396
  end
@@ -398,7 +398,7 @@ describe ActiveInteraction::Base do
398
398
  it 'does not modify the source' do
399
399
  filters = klass.filters.dup
400
400
  described_class
401
- expect(klass.filters).to eq filters
401
+ expect(klass.filters).to eql filters
402
402
  end
403
403
 
404
404
  it 'responds to readers, writers, and predicates' do
@@ -1,16 +1,19 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
- require 'test/unit/assertions'
5
4
 
6
5
  shared_examples_for 'ActiveModel' do
7
- include ActiveModel::Lint::Tests
8
- include Test::Unit::Assertions
6
+ it 'includes ActiveModel::Conversion' do
7
+ expect(subject).to be_a_kind_of ActiveModel::Conversion
8
+ end
9
9
 
10
- let(:model) { subject }
10
+ it 'includes ActiveModel::Validations' do
11
+ expect(subject).to be_a_kind_of ActiveModel::Validations
12
+ end
11
13
 
12
- ActiveModel::Lint::Tests.public_instance_methods
13
- .grep(/\Atest/) { |m| example(m) { public_send(m) } }
14
+ it 'extends ActiveModel::Naming' do
15
+ expect(subject.class).to be_a_kind_of ActiveModel::Naming
16
+ end
14
17
  end
15
18
 
16
19
  describe ActiveInteraction::ActiveModelable do
@@ -20,13 +23,13 @@ describe ActiveInteraction::ActiveModelable do
20
23
 
21
24
  describe '.i18n_scope' do
22
25
  it 'returns the scope' do
23
- expect(klass.i18n_scope).to eq :active_interaction
26
+ expect(klass.i18n_scope).to eql :active_interaction
24
27
  end
25
28
  end
26
29
 
27
30
  describe '#i18n_scope' do
28
31
  it 'returns the scope' do
29
- expect(instance.i18n_scope).to eq :active_interaction
32
+ expect(instance.i18n_scope).to eql :active_interaction
30
33
  end
31
34
  end
32
35
 
@@ -57,7 +57,7 @@ describe ActiveInteraction::Missable do
57
57
  let(:slug) { :boolean }
58
58
 
59
59
  it 'returns self' do
60
- expect(instance.method_missing(slug)).to eq instance
60
+ expect(instance.method_missing(slug)).to eql instance
61
61
  end
62
62
 
63
63
  it 'yields' do
@@ -116,12 +116,12 @@ describe ActiveInteraction::Runnable do
116
116
  let(:result) { double }
117
117
 
118
118
  it 'returns the result' do
119
- expect(instance.result = result).to eq result
119
+ expect(instance.result = result).to eql result
120
120
  end
121
121
 
122
122
  it 'sets the result' do
123
123
  instance.result = result
124
- expect(instance.result).to eq result
124
+ expect(instance.result).to eql result
125
125
  end
126
126
 
127
127
  context 'with an error' do
@@ -138,7 +138,7 @@ describe ActiveInteraction::Runnable do
138
138
 
139
139
  it 'sets the result' do
140
140
  instance.result = result
141
- expect(instance.result).to eq result
141
+ expect(instance.result).to eql result
142
142
  end
143
143
  end
144
144
  end
@@ -20,22 +20,22 @@ describe ActiveInteraction::Errors do
20
20
  describe '#add_sym' do
21
21
  it 'defaults to :invalid' do
22
22
  errors.add_sym(:attribute)
23
- expect(errors.symbolic[:attribute]).to eq [:invalid]
23
+ expect(errors.symbolic[:attribute]).to eql [:invalid]
24
24
  end
25
25
 
26
26
  it 'adds a symbol' do
27
27
  errors.add_sym(:attribute, :symbol)
28
- expect(errors.symbolic[:attribute]).to eq [:symbol]
28
+ expect(errors.symbolic[:attribute]).to eql [:symbol]
29
29
  end
30
30
 
31
31
  it 'accepts a message' do
32
32
  errors.add_sym(:attribute, :symbol, 'message')
33
- expect(errors.symbolic[:attribute]).to eq [:symbol]
33
+ expect(errors.symbolic[:attribute]).to eql [:symbol]
34
34
  end
35
35
 
36
36
  it 'accepts a message and options' do
37
37
  errors.add_sym(:attribute, :symbol, 'message', key: :value)
38
- expect(errors.symbolic[:attribute]).to eq [:symbol]
38
+ expect(errors.symbolic[:attribute]).to eql [:symbol]
39
39
  end
40
40
 
41
41
  context 'calling #add' do
@@ -71,7 +71,7 @@ describe ActiveInteraction::Errors do
71
71
 
72
72
  describe '#initialize' do
73
73
  it 'sets symbolic to an empty hash' do
74
- expect(errors.symbolic).to eq({})
74
+ expect(errors.symbolic).to eql({})
75
75
  end
76
76
  end
77
77
 
@@ -83,7 +83,7 @@ describe ActiveInteraction::Errors do
83
83
  end
84
84
 
85
85
  it 'dups symbolic' do
86
- expect(errors_dup.symbolic).to eq errors.symbolic
86
+ expect(errors_dup.symbolic).to eql errors.symbolic
87
87
  expect(errors_dup.symbolic).to_not equal errors.symbolic
88
88
  end
89
89
  end
@@ -109,13 +109,13 @@ describe ActiveInteraction::Errors do
109
109
 
110
110
  it 'adds the error' do
111
111
  errors.merge!(other)
112
- expect(errors.messages[:attribute]).to eq ['is invalid']
112
+ expect(errors.messages[:attribute]).to eql ['is invalid']
113
113
  end
114
114
 
115
115
  it 'does not add duplicate errors' do
116
116
  other.add(:attribute)
117
117
  errors.merge!(other)
118
- expect(errors.messages[:attribute]).to eq ['is invalid']
118
+ expect(errors.messages[:attribute]).to eql ['is invalid']
119
119
  end
120
120
  end
121
121
 
@@ -126,7 +126,7 @@ describe ActiveInteraction::Errors do
126
126
 
127
127
  it 'adds the error' do
128
128
  errors.merge!(other)
129
- expect(errors.symbolic[:attribute]).to eq [:invalid]
129
+ expect(errors.symbolic[:attribute]).to eql [:invalid]
130
130
  end
131
131
  end
132
132
 
@@ -30,7 +30,7 @@ describe ActiveInteraction::Filter, :filter do
30
30
  describe '.factory' do
31
31
  it 'returns a Filter' do
32
32
  expect(described_class.factory(described_class.name.to_sym))
33
- .to eq described_class
33
+ .to eql described_class
34
34
  end
35
35
  end
36
36
 
@@ -40,7 +40,7 @@ describe ActiveInteraction::ArrayFilter, :filter do
40
40
  let(:value) { [] }
41
41
 
42
42
  it 'returns the Array' do
43
- expect(filter.cast(value)).to eq value
43
+ expect(filter.cast(value)).to eql value
44
44
  end
45
45
  end
46
46
 
@@ -48,7 +48,7 @@ describe ActiveInteraction::ArrayFilter, :filter do
48
48
  let(:value) { [[], false, 0.0, {}, 0, '', :''] }
49
49
 
50
50
  it 'returns the Array' do
51
- expect(filter.cast(value)).to eq value
51
+ expect(filter.cast(value)).to eql value
52
52
  end
53
53
  end
54
54
 
@@ -59,7 +59,7 @@ describe ActiveInteraction::ArrayFilter, :filter do
59
59
  let(:value) { [] }
60
60
 
61
61
  it 'returns the Array' do
62
- expect(filter.cast(value)).to eq value
62
+ expect(filter.cast(value)).to eql value
63
63
  end
64
64
  end
65
65
 
@@ -67,7 +67,7 @@ describe ActiveInteraction::ArrayFilter, :filter do
67
67
  let(:value) { [[]] }
68
68
 
69
69
  it 'returns the Array' do
70
- expect(filter.cast(value)).to eq value
70
+ expect(filter.cast(value)).to eql value
71
71
  end
72
72
  end
73
73
 
@@ -19,7 +19,7 @@ describe ActiveInteraction::DateFilter, :filter do
19
19
  let(:value) { Date.new }
20
20
 
21
21
  it 'returns the Date' do
22
- expect(filter.cast(value)).to eq value
22
+ expect(filter.cast(value)).to eql value
23
23
  end
24
24
  end
25
25
 
@@ -27,7 +27,7 @@ describe ActiveInteraction::DateFilter, :filter do
27
27
  let(:value) { '2011-12-13' }
28
28
 
29
29
  it 'returns a Date' do
30
- expect(filter.cast(value)).to eq Date.parse(value)
30
+ expect(filter.cast(value)).to eql Date.parse(value)
31
31
  end
32
32
 
33
33
  context 'with format' do
@@ -36,7 +36,7 @@ describe ActiveInteraction::DateFilter, :filter do
36
36
  let(:value) { '13/12/2011' }
37
37
 
38
38
  it 'returns a Date' do
39
- expect(filter.cast(value)).to eq Date.strptime(value, format)
39
+ expect(filter.cast(value)).to eql Date.strptime(value, format)
40
40
  end
41
41
  end
42
42
  end
@@ -19,7 +19,7 @@ describe ActiveInteraction::DateTimeFilter, :filter do
19
19
  let(:value) { DateTime.new }
20
20
 
21
21
  it 'returns the DateTime' do
22
- expect(filter.cast(value)).to eq value
22
+ expect(filter.cast(value)).to eql value
23
23
  end
24
24
  end
25
25
 
@@ -27,7 +27,7 @@ describe ActiveInteraction::DateTimeFilter, :filter do
27
27
  let(:value) { '2011-12-13T14:15:16+17:18' }
28
28
 
29
29
  it 'returns a DateTime' do
30
- expect(filter.cast(value)).to eq DateTime.parse(value)
30
+ expect(filter.cast(value)).to eql DateTime.parse(value)
31
31
  end
32
32
 
33
33
  context 'with format' do
@@ -36,7 +36,7 @@ describe ActiveInteraction::DateTimeFilter, :filter do
36
36
  let(:value) { '13/12/2011 14:15:16 +17:18' }
37
37
 
38
38
  it 'returns a DateTime' do
39
- expect(filter.cast(value)).to eq DateTime.strptime(value, format)
39
+ expect(filter.cast(value)).to eql DateTime.strptime(value, format)
40
40
  end
41
41
  end
42
42
  end
@@ -11,7 +11,7 @@ describe ActiveInteraction::FileFilter, :filter do
11
11
  let(:value) { File.new(__FILE__) }
12
12
 
13
13
  it 'returns the File' do
14
- expect(filter.cast(value)).to eq value
14
+ expect(filter.cast(value)).to eql value
15
15
  end
16
16
  end
17
17
 
@@ -11,7 +11,7 @@ describe ActiveInteraction::FloatFilter, :filter do
11
11
  let(:value) { rand }
12
12
 
13
13
  it 'returns the Float' do
14
- expect(filter.cast(value)).to eq value
14
+ expect(filter.cast(value)).to eql value
15
15
  end
16
16
  end
17
17
 
@@ -19,7 +19,7 @@ describe ActiveInteraction::FloatFilter, :filter do
19
19
  let(:value) { rand(1 << 16) }
20
20
 
21
21
  it 'returns a Float' do
22
- expect(filter.cast(value)).to eq value.to_f
22
+ expect(filter.cast(value)).to eql value.to_f
23
23
  end
24
24
  end
25
25
 
@@ -27,7 +27,7 @@ describe ActiveInteraction::FloatFilter, :filter do
27
27
  let(:value) { rand.to_s }
28
28
 
29
29
  it 'returns a Float' do
30
- expect(filter.cast(value)).to eq Float(value)
30
+ expect(filter.cast(value)).to eql Float(value)
31
31
  end
32
32
  end
33
33
 
@@ -19,7 +19,7 @@ describe ActiveInteraction::HashFilter, :filter do
19
19
  let(:value) { {} }
20
20
 
21
21
  it 'returns the Hash' do
22
- expect(filter.cast(value)).to eq value
22
+ expect(filter.cast(value)).to eql value
23
23
  end
24
24
  end
25
25
 
@@ -27,7 +27,7 @@ describe ActiveInteraction::HashFilter, :filter do
27
27
  let(:value) { { a: {} } }
28
28
 
29
29
  it 'returns an empty Hash' do
30
- expect(filter.cast(value)).to eq({})
30
+ expect(filter.cast(value)).to eql({})
31
31
  end
32
32
  end
33
33
 
@@ -38,7 +38,7 @@ describe ActiveInteraction::HashFilter, :filter do
38
38
  let(:value) { { a: {} } }
39
39
 
40
40
  it 'returns the Hash' do
41
- expect(filter.cast(value)).to eq value
41
+ expect(filter.cast(value)).to eql value
42
42
  end
43
43
 
44
44
  context 'with String keys' do
@@ -51,10 +51,32 @@ describe ActiveInteraction::HashFilter, :filter do
51
51
  end
52
52
  end
53
53
  end
54
+
55
+ context 'without a Hash' do
56
+ let(:k) { 'a' }
57
+ let(:v) { double }
58
+ let(:value) { { k => v } }
59
+
60
+ it 'raises an error' do
61
+ expect do
62
+ filter.cast(value)
63
+ end.to raise_error ActiveInteraction::InvalidNestedValueError
64
+ end
65
+
66
+ it 'populates the error' do
67
+ begin
68
+ filter.cast(value)
69
+ rescue ActiveInteraction::InvalidNestedValueError => e
70
+ expect(e.filter_name).to eql k
71
+ expect(e.input_value).to eql v
72
+ end
73
+ end
74
+ end
54
75
  end
55
76
 
56
77
  context 'keys are symbolized' do
57
78
  let(:value) { { 'a' => 'a', 1 => 1 } }
79
+
58
80
  before do
59
81
  options.merge!(strip: false)
60
82
  end
@@ -76,7 +98,7 @@ describe ActiveInteraction::HashFilter, :filter do
76
98
  end
77
99
 
78
100
  it 'returns the Hash' do
79
- expect(filter.default).to eq options[:default]
101
+ expect(filter.default).to eql options[:default]
80
102
  end
81
103
  end
82
104
 
@@ -11,7 +11,7 @@ describe ActiveInteraction::IntegerFilter, :filter do
11
11
  let(:value) { rand(1 << 16) }
12
12
 
13
13
  it 'returns the Integer' do
14
- expect(filter.cast(value)).to eq value
14
+ expect(filter.cast(value)).to eql value
15
15
  end
16
16
  end
17
17
 
@@ -19,7 +19,7 @@ describe ActiveInteraction::IntegerFilter, :filter do
19
19
  let(:value) { rand(1 << 16) + rand }
20
20
 
21
21
  it 'returns an Integer' do
22
- expect(filter.cast(value)).to eq value.to_i
22
+ expect(filter.cast(value)).to eql value.to_i
23
23
  end
24
24
  end
25
25
 
@@ -27,7 +27,7 @@ describe ActiveInteraction::IntegerFilter, :filter do
27
27
  let(:value) { rand(1 << 16).to_s }
28
28
 
29
29
  it 'returns an Integer' do
30
- expect(filter.cast(value)).to eq Integer(value)
30
+ expect(filter.cast(value)).to eql Integer(value)
31
31
  end
32
32
  end
33
33
 
@@ -17,17 +17,17 @@ describe ActiveInteraction::ModelFilter, :filter do
17
17
 
18
18
  context 'with class as a Class' do
19
19
  it 'returns the instance' do
20
- expect(filter.cast(value)).to eq value
20
+ expect(filter.cast(value)).to eql value
21
21
  end
22
22
 
23
23
  it 'handles reconstantizing' do
24
- expect(filter.cast(value)).to eq value
24
+ expect(filter.cast(value)).to eql value
25
25
 
26
26
  Object.send(:remove_const, :Model)
27
27
  class Model; end
28
28
  value = Model.new
29
29
 
30
- expect(filter.cast(value)).to eq value
30
+ expect(filter.cast(value)).to eql value
31
31
  end
32
32
 
33
33
  it 'handles reconstantizing subclasses' do
@@ -38,7 +38,7 @@ describe ActiveInteraction::ModelFilter, :filter do
38
38
  class Submodel < Model; end
39
39
  value = Submodel.new
40
40
 
41
- expect(filter.cast(value)).to eq value
41
+ expect(filter.cast(value)).to eql value
42
42
  end
43
43
 
44
44
  it 'does not overflow the stack' do
@@ -69,7 +69,7 @@ describe ActiveInteraction::ModelFilter, :filter do
69
69
  end
70
70
 
71
71
  it 'returns the instance' do
72
- expect(filter.cast(value)).to eq value
72
+ expect(filter.cast(value)).to eql value
73
73
  end
74
74
  end
75
75
 
@@ -79,7 +79,7 @@ describe ActiveInteraction::ModelFilter, :filter do
79
79
  end
80
80
 
81
81
  it 'returns the instance' do
82
- expect(filter.cast(value)).to eq value
82
+ expect(filter.cast(value)).to eql value
83
83
  end
84
84
  end
85
85
 
@@ -17,7 +17,7 @@ describe ActiveInteraction::StringFilter, :filter do
17
17
  let(:value) { SecureRandom.hex }
18
18
 
19
19
  it 'returns the String' do
20
- expect(filter.cast(value)).to eq value
20
+ expect(filter.cast(value)).to eql value
21
21
  end
22
22
  end
23
23
 
@@ -25,14 +25,14 @@ describe ActiveInteraction::StringFilter, :filter do
25
25
  let(:value) { " #{SecureRandom.hex} " }
26
26
 
27
27
  it 'returns the stripped string' do
28
- expect(filter.cast(value)).to eq value.strip
28
+ expect(filter.cast(value)).to eql value.strip
29
29
  end
30
30
 
31
31
  context 'without strip' do
32
32
  include_context 'without strip'
33
33
 
34
34
  it 'returns the String' do
35
- expect(filter.cast(value)).to eq value
35
+ expect(filter.cast(value)).to eql value
36
36
  end
37
37
  end
38
38
  end
@@ -11,7 +11,7 @@ describe ActiveInteraction::SymbolFilter, :filter do
11
11
  let(:value) { SecureRandom.hex.to_sym }
12
12
 
13
13
  it 'returns the Symbol' do
14
- expect(filter.cast(value)).to eq value
14
+ expect(filter.cast(value)).to eql value
15
15
  end
16
16
  end
17
17
 
@@ -19,7 +19,7 @@ describe ActiveInteraction::SymbolFilter, :filter do
19
19
  let(:value) { SecureRandom.hex }
20
20
 
21
21
  it 'returns a Symbol' do
22
- expect(filter.cast(value)).to eq value.to_sym
22
+ expect(filter.cast(value)).to eql value.to_sym
23
23
  end
24
24
  end
25
25
  end
@@ -19,7 +19,7 @@ describe ActiveInteraction::TimeFilter, :filter do
19
19
  let(:value) { Time.new }
20
20
 
21
21
  it 'returns the Time' do
22
- expect(filter.cast(value)).to eq value
22
+ expect(filter.cast(value)).to eql value
23
23
  end
24
24
  end
25
25
 
@@ -27,7 +27,7 @@ describe ActiveInteraction::TimeFilter, :filter do
27
27
  let(:value) { '2011-12-13 14:15:16 +1718' }
28
28
 
29
29
  it 'returns a Time' do
30
- expect(filter.cast(value)).to eq Time.parse(value)
30
+ expect(filter.cast(value)).to eql Time.parse(value)
31
31
  end
32
32
 
33
33
  context 'with format' do
@@ -36,7 +36,7 @@ describe ActiveInteraction::TimeFilter, :filter do
36
36
  let(:value) { '13/12/2011 14:15:16 +1718' }
37
37
 
38
38
  it 'returns a Time' do
39
- expect(filter.cast(value)).to eq Time.strptime(value, format)
39
+ expect(filter.cast(value)).to eql Time.strptime(value, format)
40
40
  end
41
41
  end
42
42
  end
@@ -21,11 +21,11 @@ describe ArrayInteraction do
21
21
  before { inputs.merge!(a: a) }
22
22
 
23
23
  it 'returns the correct value for :a' do
24
- expect(result[:a]).to eq a
24
+ expect(result[:a]).to eql a
25
25
  end
26
26
 
27
27
  it 'returns the correct value for :b' do
28
- expect(result[:b]).to eq [[]]
28
+ expect(result[:b]).to eql [[]]
29
29
  end
30
30
  end
31
31
 
@@ -21,11 +21,11 @@ describe HashInteraction do
21
21
  before { inputs.merge!(a: a) }
22
22
 
23
23
  it 'returns the correct value for :a' do
24
- expect(result[:a]).to eq a.symbolize_keys
24
+ expect(result[:a]).to eql a.symbolize_keys
25
25
  end
26
26
 
27
27
  it 'returns the correct value for :b' do
28
- expect(result[:b]).to eq(x: {})
28
+ expect(result[:b]).to eql(x: {})
29
29
  end
30
30
  end
31
31
 
@@ -70,7 +70,7 @@ describe TimeInteraction do
70
70
  let(:a) { Time.now }
71
71
 
72
72
  it 'returns the correct value' do
73
- expect(result[:a]).to eq a
73
+ expect(result[:a]).to eql a
74
74
  end
75
75
  end
76
76
 
@@ -78,7 +78,7 @@ describe TimeInteraction do
78
78
  let(:a) { TimeWithZone.new(Time.now) }
79
79
 
80
80
  it 'returns the correct value' do
81
- expect(result[:a]).to eq a
81
+ expect(result[:a]).to eql a
82
82
  end
83
83
 
84
84
  it 'handles time zone changes' do
@@ -13,7 +13,7 @@ describe ActiveInteraction::Validation do
13
13
  let(:filters) { {} }
14
14
 
15
15
  it 'returns no errors' do
16
- expect(result).to eq []
16
+ expect(result).to eql []
17
17
  end
18
18
  end
19
19
 
@@ -25,7 +25,7 @@ describe ActiveInteraction::Validation do
25
25
  end
26
26
 
27
27
  it 'returns no errors' do
28
- expect(result).to eq []
28
+ expect(result).to eql []
29
29
  end
30
30
  end
31
31
 
@@ -42,7 +42,7 @@ describe ActiveInteraction::Validation do
42
42
  type = I18n.translate(
43
43
  "#{ActiveInteraction::Base.i18n_scope}.types.#{filter.class.slug}")
44
44
 
45
- expect(result).to eq [[filter.name, :invalid_type, nil, type: type]]
45
+ expect(result).to eql [[filter.name, :invalid_type, nil, type: type]]
46
46
  end
47
47
  end
48
48
 
@@ -50,7 +50,7 @@ describe ActiveInteraction::Validation do
50
50
  let(:exception) { ActiveInteraction::MissingValueError }
51
51
 
52
52
  it 'returns an :msising error' do
53
- expect(result).to eq [[filter.name, :missing]]
53
+ expect(result).to eql [[filter.name, :missing]]
54
54
  end
55
55
  end
56
56
  end
@@ -36,7 +36,7 @@ shared_examples_for 'a filter' do
36
36
  it 'returns a Filter' do
37
37
  expect(
38
38
  described_class.factory(described_class.slug)
39
- ).to eq described_class
39
+ ).to eql described_class
40
40
  end
41
41
  end
42
42
  end
@@ -86,7 +86,7 @@ shared_examples_for 'a filter' do
86
86
  include_context 'optional'
87
87
 
88
88
  it 'returns the default' do
89
- expect(filter.clean(value)).to eq options[:default]
89
+ expect(filter.clean(value)).to eql options[:default]
90
90
  end
91
91
  end
92
92
 
@@ -128,7 +128,7 @@ shared_examples_for 'a filter' do
128
128
  include_context 'optional'
129
129
 
130
130
  it 'returns the default' do
131
- expect(filter.default).to eq options[:default]
131
+ expect(filter.default).to eql options[:default]
132
132
  end
133
133
  end
134
134
 
@@ -163,7 +163,7 @@ shared_examples_for 'a filter' do
163
163
  end
164
164
 
165
165
  it 'returns the default' do
166
- expect(filter.default).to eq options[:default].call
166
+ expect(filter.default).to eql options[:default].call
167
167
  end
168
168
  end
169
169
  end
@@ -181,7 +181,7 @@ shared_examples_for 'a filter' do
181
181
  end
182
182
 
183
183
  it 'returns the description' do
184
- expect(filter.desc).to eq desc
184
+ expect(filter.desc).to eql desc
185
185
  end
186
186
  end
187
187
  end
@@ -212,13 +212,13 @@ shared_examples_for 'a filter' do
212
212
 
213
213
  describe '#name' do
214
214
  it 'returns the name' do
215
- expect(filter.name).to eq name
215
+ expect(filter.name).to eql name
216
216
  end
217
217
  end
218
218
 
219
219
  describe '#options' do
220
220
  it 'returns the options' do
221
- expect(filter.options).to eq options
221
+ expect(filter.options).to eql options
222
222
  end
223
223
  end
224
224
  end
@@ -46,7 +46,7 @@ shared_examples_for 'an interaction' do |type, generator, filter_options = {}|
46
46
  end
47
47
 
48
48
  it 'returns the correct value for :required' do
49
- expect(result[:required]).to eq required
49
+ expect(result[:required]).to eql required
50
50
  end
51
51
 
52
52
  it 'returns nil for :optional' do
@@ -76,7 +76,7 @@ shared_examples_for 'an interaction' do |type, generator, filter_options = {}|
76
76
  before { inputs.merge!(optional: optional) }
77
77
 
78
78
  it 'returns the correct value for :optional' do
79
- expect(result[:optional]).to eq optional
79
+ expect(result[:optional]).to eql optional
80
80
  end
81
81
  end
82
82
 
@@ -86,7 +86,7 @@ shared_examples_for 'an interaction' do |type, generator, filter_options = {}|
86
86
  before { inputs.merge!(default: default) }
87
87
 
88
88
  it 'returns the correct value for :default' do
89
- expect(result[:default]).to eq default
89
+ expect(result[:default]).to eql default
90
90
  end
91
91
  end
92
92
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_interaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lasseigne
@@ -9,110 +9,110 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-31 00:00:00.000000000 Z
12
+ date: 2014-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '3'
21
- - - <
21
+ - - "<"
22
22
  - !ruby/object:Gem::Version
23
23
  version: '5'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - '>='
28
+ - - ">="
29
29
  - !ruby/object:Gem::Version
30
30
  version: '3'
31
- - - <
31
+ - - "<"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '5'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: bundler
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.5'
40
+ version: '1.6'
41
41
  type: :development
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.5'
47
+ version: '1.6'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: coveralls
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.7'
55
55
  type: :development
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.7'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: guard-rspec
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '4.2'
69
69
  type: :development
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '4.2'
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: guard-rubocop
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.0'
82
+ version: '1.1'
83
83
  type: :development
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.0'
89
+ version: '1.1'
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: rake
92
92
  requirement: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '10.1'
96
+ version: '10.3'
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '10.1'
103
+ version: '10.3'
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: rdoc
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '4.1'
111
111
  type: :development
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '4.1'
118
118
  - !ruby/object:Gem::Dependency
@@ -121,26 +121,26 @@ dependencies:
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.19.1
124
+ version: 0.21.0
125
125
  type: :development
126
126
  prerelease: false
127
127
  version_requirements: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 0.19.1
131
+ version: 0.21.0
132
132
  - !ruby/object:Gem::Dependency
133
133
  name: yard
134
134
  requirement: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.8'
139
139
  type: :development
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0.8'
146
146
  description: Manage application specific business logic.
@@ -230,17 +230,17 @@ require_paths:
230
230
  - lib
231
231
  required_ruby_version: !ruby/object:Gem::Requirement
232
232
  requirements:
233
- - - '>='
233
+ - - ">="
234
234
  - !ruby/object:Gem::Version
235
235
  version: 1.9.3
236
236
  required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  requirements:
238
- - - '>='
238
+ - - ">="
239
239
  - !ruby/object:Gem::Version
240
240
  version: '0'
241
241
  requirements: []
242
242
  rubyforge_project:
243
- rubygems_version: 2.2.0
243
+ rubygems_version: 2.2.2
244
244
  signing_key:
245
245
  specification_version: 4
246
246
  summary: Manage application specific business logic.