brock 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,11 @@ module Brock
8
8
  end
9
9
 
10
10
  def parse_param(value)
11
- Integer(value)
11
+ if value == '' || value.nil?
12
+ default
13
+ else
14
+ Integer(value)
15
+ end
12
16
  rescue ArgumentError, TypeError
13
17
  super(value)
14
18
  end
@@ -1,5 +1,5 @@
1
1
  module Brock
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -17,6 +17,10 @@ describe Brock::IntegerField do
17
17
  expect(subject.parse_param('10')).to eq(10)
18
18
  end
19
19
 
20
+ it "works with default" do
21
+ expect(subject.parse_param('')).to eq(1337)
22
+ end
23
+
20
24
  it "raises with anything else" do
21
25
  expect {
22
26
  subject.parse_param('boom')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-08 00:00:00.000000000 Z
12
+ date: 2013-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec