protip 0.12.3 → 0.12.4

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
  SHA1:
3
- metadata.gz: f6d7da3d8c0fd8c530ed6d85bdf6639cef1592db
4
- data.tar.gz: 48e47ffce50e963933c0a77b0af7c75ddf510b2b
3
+ metadata.gz: 3ddcb2b4b3bd6f69e1166447dffb4dc3aa02760c
4
+ data.tar.gz: 8dedbff1aff8667b6efb681076434fd8dc0405f3
5
5
  SHA512:
6
- metadata.gz: bf99d77f89dcb13056b8b0a2a844cbe360abdc060b4ece1d5e6207664f6fa3927b24f0c4e863a8f5be6db746201545e33b12cce08abcda240c2627ec76040b50
7
- data.tar.gz: f2330e50eb7a124fd3e122816391c47c558a944e8ffba1609693b086d8afbb6cc7c80b41574cdd1c19d7428a0efff7a8b2b622dd08bae5fa65f822518a8d10f5
6
+ metadata.gz: f225ba2453ee71bb97c0546f5fb4e702b96f046c612bd85c6b3277658c417138b17bb812c6895f5c6ebace61d8bddf13d792357c11c9ac785bededf41c1426c7
7
+ data.tar.gz: 600c78b9cb83e256ff1fc9cef872bb68de7040c9a2b6b6a37e4f74c243ac5d83b8e5bf10474254767406458712238f5fd854a5838340d95a5a33c1e781c719b5
@@ -191,6 +191,8 @@ module Protip
191
191
  else
192
192
  raise ArgumentError.new "Cannot convert from Ruby object: \"#{field}\""
193
193
  end
194
+ elsif field.type == :enum
195
+ value.is_a?(Fixnum) ? value : value.to_sym
194
196
  else
195
197
  value
196
198
  end
@@ -387,6 +387,29 @@ module Protip::WrapperTest # namespace for internal constants
387
387
  wrapper.number = :NAN
388
388
  end
389
389
  end
390
+
391
+ it 'allows strings to be set for enum fields' do
392
+ wrapper.number = 'ONE'
393
+ assert_equal :ONE, wrapper.number
394
+ end
395
+
396
+ it 'allows symbols to be set for enum fields' do
397
+ wrapper.number = :ONE
398
+ assert_equal :ONE, wrapper.number
399
+ end
400
+
401
+ it 'allows numbers to be set for enum fields' do
402
+ wrapper.number = 1
403
+ assert_equal :ONE, wrapper.number
404
+ end
405
+
406
+ it 'allows symbolizable values to be set for enum fields' do
407
+ m = mock
408
+ m.stubs(:to_sym).returns(:ONE)
409
+
410
+ wrapper.number = m
411
+ assert_equal :ONE, wrapper.number
412
+ end
390
413
  end
391
414
 
392
415
  describe '#matches?' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.3
4
+ version: 0.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - AngelList
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-11 00:00:00.000000000 Z
11
+ date: 2015-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel