statham 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0858a527824a0058bae1c6b44e67eeb3242eb01d
4
- data.tar.gz: f782ead23433ca05f647efb9b73474ce86c70601
3
+ metadata.gz: aef8aa709c796632d5b92994731e8c7092348677
4
+ data.tar.gz: e28d72d717b65d853741dfae79d20d01ed6de219
5
5
  SHA512:
6
- metadata.gz: af7ce15f2feba5632cf804368b6545d1a4909729bb48620e84805ab38b8dddee349ee22e3bc21203e303c45eb5646cd64b9d4b23f8c8faa8563b5da7d383950b
7
- data.tar.gz: 9e55a1b77458bbdb52759a24490c8c4b491d5f126e3bce9549d829386986a5bba2632b37e9cda9fc6cf8059c0bf0b4dc7d0d130f379e09af49634704e510dadb
6
+ metadata.gz: ef75a534a2ffbdda01cdd045e23ad21148698270ac7213b7fbbd846f6533086902478737249128bc966ca8cd11bf6b6f8bf4e74a452b91b0f2b9ddd34ac23293
7
+ data.tar.gz: 57d4cd682c96c8434952f846a0d8924c7aef8e54bf984d08ea59cc36f93c3c6b9151ba5c28e983036489b1895f7e140370009d8ee671cf5e4c126268b0b0dc41
@@ -59,6 +59,8 @@ module Statham
59
59
  value.to_a
60
60
  when :hash
61
61
  value.to_h
62
+ when :float
63
+ value.to_f
62
64
  else
63
65
  value.to_s
64
66
  end
@@ -1,3 +1,3 @@
1
1
  module Statham
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
@@ -31,6 +31,19 @@ describe Statham::Attribute do
31
31
  it { expect { attribute.serialize([1, 2, 3]) }.to raise_error }
32
32
  end
33
33
 
34
+ context 'when type is float' do
35
+ let(:attribute) { Statham::Attribute.new(type: :float) }
36
+
37
+ it { expect(attribute.serialize(nil)).to be_nil }
38
+ it { expect { attribute.serialize(true) }.to raise_error }
39
+ it { expect { attribute.serialize({ foo: :bar }) }.to raise_error }
40
+ it { expect { attribute.serialize('string') }.not_to raise_error }
41
+ it { expect(attribute.serialize('string')).to eq(0) }
42
+ it { expect { attribute.serialize([1, 2, 3]) }.to raise_error }
43
+ it { expect { attribute.serialize(1) }.not_to raise_error }
44
+ it { expect(attribute.serialize(1)).to eq(1.to_f) }
45
+ end
46
+
34
47
  context 'when default value is set' do
35
48
  let(:default) { 'hello' }
36
49
  let(:value) { 'world' }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statham
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inbeom Hwang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-12 00:00:00.000000000 Z
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport