smartdown 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/smartdown/model/scenarios/scenario.rb +1 -1
- data/lib/smartdown/parser/scenario_set_interpreter.rb +29 -15
- data/lib/smartdown/version.rb +1 -1
- data/spec/fixtures/acceptance/animal-example-simple/scenarios/tigers_and_cats.txt +2 -1
- data/spec/parser/scenario_set_interpreter_spec.rb +6 -4
- data/spec/parser/scenario_sets_interpreter_spec.rb +2 -1
- metadata +18 -18
@@ -15,7 +15,8 @@ module Smartdown
|
|
15
15
|
description,
|
16
16
|
question_groups,
|
17
17
|
outcome,
|
18
|
-
markers
|
18
|
+
markers,
|
19
|
+
exact_markers
|
19
20
|
)
|
20
21
|
end
|
21
22
|
|
@@ -30,31 +31,44 @@ module Smartdown
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def question_groups
|
33
|
-
|
34
|
-
if has_markers?
|
35
|
-
question_pages = group_questions_by_page(lines[0..-3])
|
36
|
-
else
|
37
|
-
question_pages = group_questions_by_page(lines[0..-2])
|
38
|
-
end
|
34
|
+
question_pages = group_questions_by_page(@scenario_lines[first_question..last_question])
|
39
35
|
question_groups = question_pages.map { |question_page| interpret_question_page(question_page) }
|
40
36
|
end
|
41
37
|
|
38
|
+
def last_question
|
39
|
+
@scenario_lines.rindex { |line| line.match(/(\s\s\S*:)|(- \S*:)/) }
|
40
|
+
end
|
41
|
+
|
42
|
+
def first_question
|
43
|
+
@scenario_lines.index { |line| line.match(/(\s\s\S*:)|(- \S*:)/) }
|
44
|
+
end
|
45
|
+
|
42
46
|
def outcome
|
43
|
-
|
44
|
-
@scenario_lines[@scenario_lines.size - 2]
|
45
|
-
else
|
46
|
-
@scenario_lines.last
|
47
|
-
end
|
47
|
+
@scenario_lines[last_question + 1]
|
48
48
|
end
|
49
49
|
|
50
50
|
def has_markers?
|
51
|
-
@scenario_lines.
|
51
|
+
@scenario_lines.any? { |line| line.match(/(has markers:|has marker:)/) }
|
52
|
+
end
|
53
|
+
|
54
|
+
def has_exact_markers?
|
55
|
+
@scenario_lines.any? { |line| line.match(/(exact markers:|exact marker:)/) }
|
52
56
|
end
|
53
57
|
|
54
58
|
def markers
|
55
59
|
if has_markers?
|
56
|
-
|
57
|
-
comma_sperated_markers =
|
60
|
+
marker_line = @scenario_lines.find { |line| line.match(/(has markers:|has marker:)/) }
|
61
|
+
comma_sperated_markers = marker_line.slice(marker_line.index(":") + 1, marker_line.size)
|
62
|
+
comma_sperated_markers.split(',').map(&:strip)
|
63
|
+
else
|
64
|
+
[]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def exact_markers
|
69
|
+
if has_exact_markers?
|
70
|
+
marker_line = @scenario_lines.find { |line| line.match(/(exact markers:|exact marker:)/) }
|
71
|
+
comma_sperated_markers = marker_line.slice(marker_line.index(":") + 1, marker_line.size)
|
58
72
|
comma_sperated_markers.split(',').map(&:strip)
|
59
73
|
else
|
60
74
|
[]
|
data/lib/smartdown/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'smartdown/parser/scenario_set_interpreter'
|
2
2
|
|
3
3
|
describe Smartdown::Parser::ScenarioSetInterpreter do
|
4
|
-
let(:
|
5
|
-
subject { described_class.new(
|
4
|
+
let(:scenario) { File.open(File.dirname(__FILE__) + "/../fixtures/acceptance/animal-example-simple/scenarios/tigers_and_cats.txt", "rb").read }
|
5
|
+
subject { described_class.new(scenario) }
|
6
6
|
|
7
7
|
describe "#description" do
|
8
8
|
it { expect(subject.description).to eq("User has a cat;And cats are amazing") }
|
@@ -17,8 +17,10 @@ describe Smartdown::Parser::ScenarioSetInterpreter do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#markers" do
|
20
|
-
it { expect(subject.markers).to eq(["is_a_safe_pet"
|
20
|
+
it { expect(subject.markers).to eq(["is_a_safe_pet"]) }
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
describe "#exact_markers" do
|
24
|
+
it { expect(subject.exact_markers).to eq(["is_a_safe_pet", "safe_pets_are_cool"]) }
|
25
|
+
end
|
24
26
|
end
|
@@ -25,7 +25,8 @@ describe Smartdown::Parser::ScenarioSetsInterpreter do
|
|
25
25
|
expect(tigers_and_cats_scenario_set.scenarios.first.description).to eq("User has a cat;And cats are amazing")
|
26
26
|
expect(tigers_and_cats_scenario_set.scenarios.first.question_groups.size).to eq(1)
|
27
27
|
expect(tigers_and_cats_scenario_set.scenarios.first.outcome).to eq("outcome_safe_pet")
|
28
|
-
expect(tigers_and_cats_scenario_set.scenarios.first.markers).to eq(['is_a_safe_pet'
|
28
|
+
expect(tigers_and_cats_scenario_set.scenarios.first.markers).to eq(['is_a_safe_pet'])
|
29
|
+
expect(tigers_and_cats_scenario_set.scenarios.first.exact_markers).to eq(['is_a_safe_pet', 'safe_pets_are_cool'])
|
29
30
|
end
|
30
31
|
|
31
32
|
it "has scenario questions with name and answer" do
|
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.
|
4
|
+
version: 0.15.0
|
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-
|
12
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parslet
|
16
|
-
requirement: &
|
16
|
+
requirement: &9427800 !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: *
|
24
|
+
version_requirements: *9427800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: uk_postcode
|
27
|
-
requirement: &
|
27
|
+
requirement: &9427020 !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: *
|
35
|
+
version_requirements: *9427020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &9453240 !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: *
|
46
|
+
version_requirements: *9453240
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &9452780 !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: *
|
57
|
+
version_requirements: *9452780
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: pry
|
60
|
-
requirement: &
|
60
|
+
requirement: &9452180 !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: *
|
68
|
+
version_requirements: *9452180
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: gem_publisher
|
71
|
-
requirement: &
|
71
|
+
requirement: &9451440 !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: *
|
79
|
+
version_requirements: *9451440
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: timecop
|
82
|
-
requirement: &
|
82
|
+
requirement: &9450080 !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: *
|
90
|
+
version_requirements: *9450080
|
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:
|
318
|
+
hash: 4167639428547367493
|
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:
|
327
|
+
hash: 4167639428547367493
|
328
328
|
requirements: []
|
329
329
|
rubyforge_project:
|
330
330
|
rubygems_version: 1.8.11
|