smartdown 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/smartdown/engine.rb +1 -1
- data/lib/smartdown/model/answer/base.rb +2 -2
- data/lib/smartdown/version.rb +1 -1
- data/spec/engine/interpolator_spec.rb +3 -2
- data/spec/model/answer/base_spec.rb +1 -1
- data/spec/model/answer/date_spec.rb +14 -14
- data/spec/model/answer/money_spec.rb +1 -1
- data/spec/model/answer/salary_spec.rb +14 -14
- metadata +11 -11
data/lib/smartdown/engine.rb
CHANGED
@@ -35,7 +35,7 @@ module Smartdown
|
|
35
35
|
transition = Transition.new(state, current_node, unprocessed_responses.shift(1))
|
36
36
|
else
|
37
37
|
answers = current_node.questions.map do |question|
|
38
|
-
question.answer_type.new(
|
38
|
+
question.answer_type.new(unprocessed_responses.shift, question)
|
39
39
|
end
|
40
40
|
|
41
41
|
transition = Transition.new(state, current_node, answers)
|
data/lib/smartdown/version.rb
CHANGED
@@ -4,6 +4,7 @@ require 'smartdown/model/answer/money'
|
|
4
4
|
require 'smartdown/engine/interpolator'
|
5
5
|
require 'smartdown/engine/state'
|
6
6
|
require 'parslet'
|
7
|
+
require 'date'
|
7
8
|
|
8
9
|
describe Smartdown::Engine::Interpolator do
|
9
10
|
subject(:interpolator) { described_class.new }
|
@@ -116,7 +117,7 @@ describe Smartdown::Engine::Interpolator do
|
|
116
117
|
let(:state) {
|
117
118
|
Smartdown::Engine::State.new(
|
118
119
|
current_node: node.name,
|
119
|
-
date_answer: Smartdown::Model::Answer::Date.new("
|
120
|
+
date_answer: Smartdown::Model::Answer::Date.new("2014-1-1")
|
120
121
|
)
|
121
122
|
}
|
122
123
|
it "interpolates the result of the function call" do
|
@@ -129,7 +130,7 @@ describe Smartdown::Engine::Interpolator do
|
|
129
130
|
let(:state) {
|
130
131
|
Smartdown::Engine::State.new(
|
131
132
|
current_node: node.name,
|
132
|
-
money_answer: Smartdown::Model::Answer::Money.new(
|
133
|
+
money_answer: Smartdown::Model::Answer::Money.new(12.32523)
|
133
134
|
)
|
134
135
|
}
|
135
136
|
it "interpolates the result of the function call" do
|
@@ -4,7 +4,7 @@ describe Smartdown::Model::Answer::Base do
|
|
4
4
|
let(:question) { :a_question }
|
5
5
|
let(:value) { 'a value' }
|
6
6
|
|
7
|
-
subject(:instance) {Smartdown::Model::Answer::Base.new(
|
7
|
+
subject(:instance) {Smartdown::Model::Answer::Base.new(value, question)}
|
8
8
|
|
9
9
|
specify { expect(instance.question).to eql question }
|
10
10
|
|
@@ -4,7 +4,7 @@ require 'smartdown/model/element/question/date'
|
|
4
4
|
describe Smartdown::Model::Answer::Date do
|
5
5
|
let(:date_string) { "2014-9-4" }
|
6
6
|
let(:question) { Smartdown::Model::Element::Question::Date.new("a_date") }
|
7
|
-
subject(:instance) { described_class.new(
|
7
|
+
subject(:instance) { described_class.new(date_string, question) }
|
8
8
|
|
9
9
|
specify { expect(instance.value).to eql Date.new(2014, 9, 4) }
|
10
10
|
specify { expect(instance.to_s).to eql "2014-9-4" }
|
@@ -59,23 +59,23 @@ describe Smartdown::Model::Answer::Date do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
context "comparing against Answer::Dates" do
|
62
|
-
specify { expect(instance == described_class.new(
|
62
|
+
specify { expect(instance == described_class.new("2000-1-10")).to eql true }
|
63
63
|
|
64
|
-
specify { expect(instance < described_class.new(
|
65
|
-
specify { expect(instance < described_class.new(
|
66
|
-
specify { expect(instance < described_class.new(
|
64
|
+
specify { expect(instance < described_class.new("2000-1-11")).to eql true }
|
65
|
+
specify { expect(instance < described_class.new("2000-1-10")).to eql false }
|
66
|
+
specify { expect(instance < described_class.new("2000-1-9")).to eql false }
|
67
67
|
|
68
|
-
specify { expect(instance > described_class.new(
|
69
|
-
specify { expect(instance > described_class.new(
|
70
|
-
specify { expect(instance > described_class.new(
|
68
|
+
specify { expect(instance > described_class.new("2000-1-11")).to eql false }
|
69
|
+
specify { expect(instance > described_class.new("2000-1-10")).to eql false }
|
70
|
+
specify { expect(instance > described_class.new("2000-1-9")).to eql true }
|
71
71
|
|
72
|
-
specify { expect(instance <= described_class.new(
|
73
|
-
specify { expect(instance <= described_class.new(
|
74
|
-
specify { expect(instance <= described_class.new(
|
72
|
+
specify { expect(instance <= described_class.new("2000-1-11")).to eql true }
|
73
|
+
specify { expect(instance <= described_class.new("2000-1-10")).to eql true }
|
74
|
+
specify { expect(instance <= described_class.new("2000-1-9")).to eql false }
|
75
75
|
|
76
|
-
specify { expect(instance >= described_class.new(
|
77
|
-
specify { expect(instance >= described_class.new(
|
78
|
-
specify { expect(instance >= described_class.new(
|
76
|
+
specify { expect(instance >= described_class.new("2000-1-11")).to eql false }
|
77
|
+
specify { expect(instance >= described_class.new("2000-1-10")).to eql true }
|
78
|
+
specify { expect(instance >= described_class.new("2000-1-9")).to eql true }
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -4,7 +4,7 @@ require 'smartdown/model/answer/money'
|
|
4
4
|
describe Smartdown::Model::Answer::Money do
|
5
5
|
|
6
6
|
let(:money_float) { 523.42 }
|
7
|
-
subject(:instance) { described_class.new(
|
7
|
+
subject(:instance) { described_class.new(money_float) }
|
8
8
|
|
9
9
|
describe "#humanize" do
|
10
10
|
it "specifies money in the correct format" do
|
@@ -4,7 +4,7 @@ require 'smartdown/model/element/question/date'
|
|
4
4
|
describe Smartdown::Model::Answer::Salary do
|
5
5
|
let(:salary_string) { "500-week" }
|
6
6
|
let(:question) { Smartdown::Model::Element::Question::Date.new("a_date") }
|
7
|
-
subject(:instance) { described_class.new(
|
7
|
+
subject(:instance) { described_class.new(salary_string, question) }
|
8
8
|
|
9
9
|
specify { expect(instance.period).to eql('week') }
|
10
10
|
specify { expect(instance.amount_per_period).to eql(500.00) }
|
@@ -76,23 +76,23 @@ describe Smartdown::Model::Answer::Salary do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
context "comparing against Answer::Salaries" do
|
79
|
-
specify { expect(instance == described_class.new(
|
79
|
+
specify { expect(instance == described_class.new("1200-week")).to eql true }
|
80
80
|
|
81
|
-
specify { expect(instance < described_class.new(
|
82
|
-
specify { expect(instance < described_class.new(
|
83
|
-
specify { expect(instance < described_class.new(
|
81
|
+
specify { expect(instance < described_class.new("1200.1-week")).to eql true }
|
82
|
+
specify { expect(instance < described_class.new("1200.0-week")).to eql false }
|
83
|
+
specify { expect(instance < described_class.new("1199.9-week")).to eql false }
|
84
84
|
|
85
|
-
specify { expect(instance > described_class.new(
|
86
|
-
specify { expect(instance > described_class.new(
|
87
|
-
specify { expect(instance > described_class.new(
|
85
|
+
specify { expect(instance > described_class.new("1200.1-week")).to eql false }
|
86
|
+
specify { expect(instance > described_class.new("1200.0-week")).to eql false }
|
87
|
+
specify { expect(instance > described_class.new("1199.9-week")).to eql true }
|
88
88
|
|
89
|
-
specify { expect(instance <= described_class.new(
|
90
|
-
specify { expect(instance <= described_class.new(
|
91
|
-
specify { expect(instance <= described_class.new(
|
89
|
+
specify { expect(instance <= described_class.new("1200.1-week")).to eql true }
|
90
|
+
specify { expect(instance <= described_class.new("1200.0-week")).to eql true }
|
91
|
+
specify { expect(instance <= described_class.new("1199.9-week")).to eql false }
|
92
92
|
|
93
|
-
specify { expect(instance >= described_class.new(
|
94
|
-
specify { expect(instance >= described_class.new(
|
95
|
-
specify { expect(instance >= described_class.new(
|
93
|
+
specify { expect(instance >= described_class.new("1200.1-week")).to eql false }
|
94
|
+
specify { expect(instance >= described_class.new("1200.0-week")).to eql true }
|
95
|
+
specify { expect(instance >= described_class.new("1199.9-week")).to eql true }
|
96
96
|
end
|
97
97
|
end
|
98
98
|
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.5.
|
4
|
+
version: 0.5.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2014-07-09 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parslet
|
16
|
-
requirement: &
|
16
|
+
requirement: &10346540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.6.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10346540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &10344500 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *10344500
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &10342380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *10342380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: gem_publisher
|
49
|
-
requirement: &
|
49
|
+
requirement: &10366360 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *10366360
|
58
58
|
description:
|
59
59
|
email: david.heath@digital.cabinet-office.gov.uk
|
60
60
|
executables:
|
@@ -212,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
212
|
version: '0'
|
213
213
|
segments:
|
214
214
|
- 0
|
215
|
-
hash:
|
215
|
+
hash: 1694965112533004237
|
216
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
217
|
none: false
|
218
218
|
requirements:
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
segments:
|
223
223
|
- 0
|
224
|
-
hash:
|
224
|
+
hash: 1694965112533004237
|
225
225
|
requirements: []
|
226
226
|
rubyforge_project:
|
227
227
|
rubygems_version: 1.8.11
|