smartdown 0.15.0 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,7 +35,7 @@ module Smartdown
35
35
  else
36
36
  matched_value = value.strip.match FORMAT_REGEX
37
37
  if matched_value
38
- Float matched_value[1].gsub(',','')
38
+ Float matched_value[1].gsub(',','').chomp('.')
39
39
  else
40
40
  @error = 'Invalid format'
41
41
  return
@@ -1,3 +1,3 @@
1
1
  module Smartdown
2
- VERSION = "0.15.0"
2
+ VERSION = "0.15.1"
3
3
  end
@@ -20,6 +20,18 @@ describe Smartdown::Model::Answer::Money do
20
20
  specify { expect(instance.value).to eql(1523.12) }
21
21
  end
22
22
 
23
+ describe 'instantiate with £' do
24
+ let(:money_input) { '£1523.45' }
25
+
26
+ specify { expect(instance.value).to eql(1523.45) }
27
+ end
28
+
29
+ describe 'instantiate with float with a trailing dot' do
30
+ let(:money_input) { '1523.' }
31
+
32
+ specify { expect(instance.value).to eql(1523.0) }
33
+ end
34
+
23
35
  describe 'to_s' do
24
36
  it "returns value without comma delimiter" do
25
37
  expect(instance.to_s).to eql("1523.42")
@@ -49,27 +61,35 @@ describe Smartdown::Model::Answer::Money do
49
61
  expect(instance.humanize).to eql("£1,523.42")
50
62
  end
51
63
  end
64
+
52
65
  context "no pence" do
53
66
  let(:money_input) { '1523.00' }
54
67
  it "rounds down amounts of money correctly" do
55
68
  expect(instance.humanize).to eql("£1,523")
56
69
  end
57
70
  end
71
+
72
+ context "for value with a trailing dot" do
73
+ let(:money_input) { '1523.' }
74
+ it "ignores the trailing dot" do
75
+ expect(instance.humanize).to eql("£1,523")
76
+ end
77
+ end
58
78
  end
59
79
 
60
- describe "errors" do
61
- context "invalid formatting" do
80
+ describe "parsing" do
81
+ context "no digits" do
62
82
  let(:money_input) {"Loads'a'money"}
63
83
 
64
- it "Has errors" do
84
+ it "raises an error" do
65
85
  expect(instance.error).to eql("Invalid format")
66
86
  end
67
87
  end
68
88
 
69
- context "no input" do
89
+ context "empty input" do
70
90
  let(:money_input) { nil }
71
91
 
72
- it "Has errors" do
92
+ it "raises an error" do
73
93
  expect(instance.error).to eql("Please answer this question")
74
94
  end
75
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-23 00:00:00.000000000 Z
12
+ date: 2015-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parslet
16
- requirement: &9427800 !ruby/object:Gem::Requirement
16
+ requirement: &9418360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.6.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *9427800
24
+ version_requirements: *9418360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: uk_postcode
27
- requirement: &9427020 !ruby/object:Gem::Requirement
27
+ requirement: &9417520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *9427020
35
+ version_requirements: *9417520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &9453240 !ruby/object:Gem::Requirement
38
+ requirement: &9443720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 3.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *9453240
46
+ version_requirements: *9443720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &9452780 !ruby/object:Gem::Requirement
49
+ requirement: &9443260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *9452780
57
+ version_requirements: *9443260
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: pry
60
- requirement: &9452180 !ruby/object:Gem::Requirement
60
+ requirement: &9442700 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *9452180
68
+ version_requirements: *9442700
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: gem_publisher
71
- requirement: &9451440 !ruby/object:Gem::Requirement
71
+ requirement: &9442080 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *9451440
79
+ version_requirements: *9442080
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: timecop
82
- requirement: &9450080 !ruby/object:Gem::Requirement
82
+ requirement: &9440800 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *9450080
90
+ version_requirements: *9440800
91
91
  description:
92
92
  email: david.heath@digital.cabinet-office.gov.uk
93
93
  executables:
@@ -315,7 +315,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
315
315
  version: '0'
316
316
  segments:
317
317
  - 0
318
- hash: 4167639428547367493
318
+ hash: 488478183176058608
319
319
  required_rubygems_version: !ruby/object:Gem::Requirement
320
320
  none: false
321
321
  requirements:
@@ -324,7 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
324
  version: '0'
325
325
  segments:
326
326
  - 0
327
- hash: 4167639428547367493
327
+ hash: 488478183176058608
328
328
  requirements: []
329
329
  rubyforge_project:
330
330
  rubygems_version: 1.8.11