smartdown 0.12.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,9 +29,13 @@ module Smartdown
29
29
  def questions
30
30
  @questions ||= elements.slice_before do |element|
31
31
  element.is_a? Smartdown::Model::Element::MarkdownHeading
32
- end.each_with_index.map do |question_element_group, index|
32
+ end.select { |question_element_group|
33
+ question_element_group.any? {
34
+ |element| element.class.to_s.include?("Smartdown::Model::Element::Question")
35
+ }
36
+ }.each_with_index.map do |question_element_group, index|
33
37
  Smartdown::Api::PreviousQuestion.new(question_element_group, responses[index])
34
- end
38
+ end.compact
35
39
  end
36
40
 
37
41
  private
@@ -25,7 +25,7 @@ module Smartdown
25
25
  elsif question_element_group.find{|element| element.is_a? Smartdown::Model::Element::Question::Postcode}
26
26
  Smartdown::Api::PostcodeQuestion.new(question_element_group)
27
27
  end
28
- end
28
+ end.compact
29
29
  end
30
30
  end
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module Smartdown
2
- VERSION = "0.12.0"
2
+ VERSION = "0.12.1"
3
3
  end
@@ -56,6 +56,7 @@ describe Smartdown::Api::Flow do
56
56
 
57
57
  context "flow with two questions per page" do
58
58
  let(:input) { Smartdown::Parser::DirectoryInput.new(fixture("animal-example-multiple")) }
59
+
59
60
  it "has two scenario_sets" do
60
61
  expect(flow.scenario_sets.size).to eq(2)
61
62
  end
@@ -88,6 +89,8 @@ describe Smartdown::Api::Flow do
88
89
 
89
90
  context "with a valid answer given to the first question, only first answer to second page" do
90
91
  specify { expect(flow.state("y",["lion", "yes", nil]).current_node.name).to eq "question_2" }
92
+ specify { expect(flow.state("y",["lion", "yes", nil]).previous_question_pages.first.questions.count).to eq 1 }
93
+ specify { expect(flow.state("y",["lion", "yes", nil]).current_node.questions.count).to eq 2 }
91
94
  specify { expect(flow.state("y",["lion", "yes", nil]).accepted_responses).to eq ["lion"] }
92
95
  specify { expect(flow.state("y",["lion", "yes", nil]).current_answers.count).to eq 2 }
93
96
  specify { expect(flow.state("y",["lion", "yes", nil]).current_answers[0].valid?).to be true }
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.12.0
4
+ version: 0.12.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-01-08 00:00:00.000000000 Z
12
+ date: 2015-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parslet
16
- requirement: &8259380 !ruby/object:Gem::Requirement
16
+ requirement: &20811800 !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: *8259380
24
+ version_requirements: *20811800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: uk_postcode
27
- requirement: &8258580 !ruby/object:Gem::Requirement
27
+ requirement: &20810920 !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: *8258580
35
+ version_requirements: *20810920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &8257860 !ruby/object:Gem::Requirement
38
+ requirement: &20810340 !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: *8257860
46
+ version_requirements: *20810340
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &8257340 !ruby/object:Gem::Requirement
49
+ requirement: &20809660 !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: *8257340
57
+ version_requirements: *20809660
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: pry
60
- requirement: &8256560 !ruby/object:Gem::Requirement
60
+ requirement: &20808900 !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: *8256560
68
+ version_requirements: *20808900
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: gem_publisher
71
- requirement: &8255920 !ruby/object:Gem::Requirement
71
+ requirement: &20808260 !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: *8255920
79
+ version_requirements: *20808260
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: timecop
82
- requirement: &8206260 !ruby/object:Gem::Requirement
82
+ requirement: &20937900 !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: *8206260
90
+ version_requirements: *20937900
91
91
  description:
92
92
  email: david.heath@digital.cabinet-office.gov.uk
93
93
  executables:
@@ -303,7 +303,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
303
303
  version: '0'
304
304
  segments:
305
305
  - 0
306
- hash: -3641220914455318318
306
+ hash: 3149710437722645719
307
307
  required_rubygems_version: !ruby/object:Gem::Requirement
308
308
  none: false
309
309
  requirements:
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
312
  version: '0'
313
313
  segments:
314
314
  - 0
315
- hash: -3641220914455318318
315
+ hash: 3149710437722645719
316
316
  requirements: []
317
317
  rubyforge_project:
318
318
  rubygems_version: 1.8.11