cuke_modeler 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +8 -0
- data/features/step_definitions/feature_steps.rb +1 -1
- data/features/step_definitions/test_steps.rb +6 -2
- data/lib/cuke_modeler/directory.rb +7 -10
- data/lib/cuke_modeler/version.rb +1 -1
- data/spec/integration/background_integration_spec.rb +53 -40
- data/spec/integration/directory_integration_spec.rb +39 -26
- data/spec/integration/doc_string_integration_spec.rb +51 -43
- data/spec/integration/example_integration_spec.rb +71 -60
- data/spec/integration/feature_file_integration_spec.rb +36 -22
- data/spec/integration/feature_integration_spec.rb +113 -104
- data/spec/integration/outline_integration_spec.rb +71 -56
- data/spec/integration/row_integration_spec.rb +72 -0
- data/spec/integration/scenario_integration_spec.rb +61 -46
- data/spec/integration/step_integration_spec.rb +126 -117
- data/spec/integration/table_integration_spec.rb +67 -52
- data/spec/integration/table_row_integration_spec.rb +48 -40
- data/spec/integration/tag_integration_spec.rb +53 -45
- data/spec/integration/world_integration_spec.rb +2 -1
- data/spec/spec_helper.rb +15 -12
- data/spec/unit/background_unit_spec.rb +65 -50
- data/spec/unit/bare_bones_unit_specs.rb +2 -3
- data/spec/unit/containing_element_unit_specs.rb +6 -7
- data/spec/unit/directory_unit_spec.rb +103 -64
- data/spec/unit/doc_string_unit_spec.rb +113 -95
- data/spec/unit/example_unit_spec.rb +235 -219
- data/spec/unit/feature_element_unit_spec.rb +6 -6
- data/spec/unit/feature_element_unit_specs.rb +28 -24
- data/spec/unit/feature_file_unit_spec.rb +73 -63
- data/spec/unit/feature_unit_spec.rb +145 -111
- data/spec/unit/nested_element_unit_specs.rb +14 -13
- data/spec/unit/nested_unit_spec.rb +24 -21
- data/spec/unit/outline_unit_spec.rb +92 -78
- data/spec/unit/parsing_unit_spec.rb +55 -51
- data/spec/unit/prepopulated_unit_specs.rb +2 -3
- data/spec/unit/raw_element_unit_specs.rb +12 -11
- data/spec/unit/raw_unit_spec.rb +15 -12
- data/spec/unit/row_unit_spec.rb +68 -52
- data/spec/unit/scenario_unit_spec.rb +76 -62
- data/spec/unit/sourceable_unit_spec.rb +8 -6
- data/spec/unit/sourced_element_unit_specs.rb +4 -6
- data/spec/unit/step_unit_spec.rb +231 -203
- data/spec/unit/table_row_unit_spec.rb +68 -52
- data/spec/unit/table_unit_spec.rb +100 -82
- data/spec/unit/tag_unit_spec.rb +62 -48
- data/spec/unit/taggable_unit_spec.rb +58 -51
- data/spec/unit/tagged_element_unit_specs.rb +28 -26
- data/spec/unit/test_element_unit_spec.rb +33 -27
- data/spec/unit/test_element_unit_specs.rb +15 -14
- data/spec/unit/world_unit_spec.rb +94 -84
- metadata +4 -2
@@ -4,41 +4,55 @@ SimpleCov.command_name('FeatureFile') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
4
|
|
5
5
|
describe 'FeatureFile, Integration' do
|
6
6
|
|
7
|
-
|
8
|
-
file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
7
|
+
let(:clazz) { CukeModeler::FeatureFile }
|
9
8
|
|
10
|
-
File.open(file_path, "w") { |file|
|
11
|
-
file.puts('Feature: Test feature')
|
12
|
-
}
|
13
9
|
|
14
|
-
|
15
|
-
feature = file.feature
|
10
|
+
describe 'unique behavior' do
|
16
11
|
|
17
|
-
feature
|
18
|
-
|
12
|
+
it 'cannot model a non-existent feature file' do
|
13
|
+
path = "#{@default_file_directory}/missing_file.txt"
|
14
|
+
|
15
|
+
expect { clazz.new(path) }.to raise_error(ArgumentError)
|
16
|
+
end
|
19
17
|
|
20
|
-
|
18
|
+
it 'properly sets its child elements' do
|
19
|
+
file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
File.open(file_path, "w") { |file|
|
22
|
+
file.puts('Feature: Test feature')
|
23
|
+
}
|
25
24
|
|
26
|
-
|
27
|
-
|
25
|
+
file = clazz.new(file_path)
|
26
|
+
feature = file.feature
|
27
|
+
|
28
|
+
expect(feature.parent_element).to equal(file)
|
28
29
|
end
|
29
30
|
|
31
|
+
describe 'getting ancestors' do
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
before(:each) do
|
34
|
+
file_path = "#{@default_file_directory}/feature_file_test_file.feature"
|
35
|
+
File.open(file_path, 'w') { |file| file.write('Feature: Test feature') }
|
36
|
+
end
|
33
37
|
|
34
|
-
directory
|
35
|
-
|
38
|
+
let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
|
39
|
+
let(:feature_file) { directory.feature_files.first }
|
36
40
|
|
37
|
-
it 'returns nil if it does not have the requested type of ancestor' do
|
38
|
-
example = @feature_file.get_ancestor(:example)
|
39
41
|
|
40
|
-
|
42
|
+
it 'can get its directory' do
|
43
|
+
ancestor = feature_file.get_ancestor(:directory)
|
44
|
+
|
45
|
+
expect(ancestor).to equal(directory)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'returns nil if it does not have the requested type of ancestor' do
|
49
|
+
ancestor = feature_file.get_ancestor(:example)
|
50
|
+
|
51
|
+
expect(ancestor).to be_nil
|
52
|
+
end
|
53
|
+
|
41
54
|
end
|
42
55
|
|
43
56
|
end
|
57
|
+
|
44
58
|
end
|
@@ -4,150 +4,159 @@ SimpleCov.command_name('Feature') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
4
|
|
5
5
|
describe 'Feature, Integration' do
|
6
6
|
|
7
|
-
clazz
|
7
|
+
let(:clazz) { CukeModeler::Feature }
|
8
|
+
let(:feature) { clazz.new }
|
8
9
|
|
9
|
-
before(:each) do
|
10
|
-
@feature = clazz.new
|
11
|
-
end
|
12
10
|
|
13
|
-
|
14
|
-
source = ['@a_tag',
|
15
|
-
'Feature: Test feature',
|
16
|
-
' Background: Test background',
|
17
|
-
' Scenario: Test scenario',
|
18
|
-
' Scenario Outline: Test outline',
|
19
|
-
' Examples: Test Examples',
|
20
|
-
' | param |',
|
21
|
-
' | value |']
|
22
|
-
source = source.join("\n")
|
23
|
-
|
24
|
-
|
25
|
-
feature = CukeModeler::Feature.new(source)
|
26
|
-
background = feature.background
|
27
|
-
scenario = feature.tests[0]
|
28
|
-
outline = feature.tests[1]
|
29
|
-
tag = feature.tag_elements[0]
|
30
|
-
|
31
|
-
|
32
|
-
outline.parent_element.should equal feature
|
33
|
-
scenario.parent_element.should equal feature
|
34
|
-
background.parent_element.should equal feature
|
35
|
-
tag.parent_element.should equal feature
|
36
|
-
end
|
11
|
+
describe 'unique behavior' do
|
37
12
|
|
38
|
-
|
39
|
-
|
40
|
-
|
13
|
+
it 'properly sets its child elements' do
|
14
|
+
source = ['@a_tag',
|
15
|
+
'Feature: Test feature',
|
16
|
+
' Background: Test background',
|
17
|
+
' Scenario: Test scenario',
|
18
|
+
' Scenario Outline: Test outline',
|
19
|
+
' Examples: Test Examples',
|
20
|
+
' | param |',
|
21
|
+
' | value |']
|
22
|
+
source = source.join("\n")
|
41
23
|
|
42
|
-
@feature.tests = scenarios + outlines
|
43
24
|
|
44
|
-
|
45
|
-
|
46
|
-
|
25
|
+
feature = clazz.new(source)
|
26
|
+
background = feature.background
|
27
|
+
scenario = feature.tests[0]
|
28
|
+
outline = feature.tests[1]
|
29
|
+
tag = feature.tag_elements[0]
|
47
30
|
|
48
|
-
it 'knows how many scenarios it has - #scenario_count' do
|
49
|
-
scenarios = [CukeModeler::Scenario.new('Scenario: 1'), CukeModeler::Scenario.new('Scenario: 2')]
|
50
|
-
outlines = [CukeModeler::Outline.new("Scenario Outline: 1\nExamples:\n|param|\n|value|")]
|
51
31
|
|
52
|
-
|
53
|
-
|
32
|
+
expect(outline.parent_element).to equal(feature)
|
33
|
+
expect(scenario.parent_element).to equal(feature)
|
34
|
+
expect(background.parent_element).to equal(feature)
|
35
|
+
expect(tag.parent_element).to equal(feature)
|
36
|
+
end
|
54
37
|
|
55
|
-
|
56
|
-
|
57
|
-
|
38
|
+
it 'can selectively access its scenarios and outlines' do
|
39
|
+
scenarios = [CukeModeler::Scenario.new, CukeModeler::Scenario.new]
|
40
|
+
outlines = [CukeModeler::Outline.new, CukeModeler::Outline.new]
|
58
41
|
|
59
|
-
|
60
|
-
scenarios = [CukeModeler::Scenario.new('Scenario: 1')]
|
61
|
-
outlines = [CukeModeler::Outline.new("Scenario Outline: 1\nExamples:\n|param|\n|value|"), CukeModeler::Outline.new("Scenario Outline: 2\nExamples:\n|param|\n|value|")]
|
42
|
+
feature.tests = scenarios + outlines
|
62
43
|
|
63
|
-
|
64
|
-
|
44
|
+
expect(feature.scenarios).to match_array(scenarios)
|
45
|
+
expect(feature.outlines).to match_array(outlines)
|
46
|
+
end
|
65
47
|
|
66
|
-
|
67
|
-
|
68
|
-
|
48
|
+
it 'knows how many scenarios it has' do
|
49
|
+
scenarios = [CukeModeler::Scenario.new, CukeModeler::Scenario.new]
|
50
|
+
outlines = [CukeModeler::Outline.new]
|
69
51
|
|
70
|
-
|
71
|
-
|
72
|
-
source_1 = source_1.join("\n")
|
52
|
+
feature.tests = []
|
53
|
+
expect(feature.scenario_count).to eq(0)
|
73
54
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
' * a step',
|
78
|
-
' Examples: Test examples',
|
79
|
-
' |param|',
|
80
|
-
' |value_1|',
|
81
|
-
' |value_2|']
|
82
|
-
source_2 = source_2.join("\n")
|
55
|
+
feature.tests = scenarios + outlines
|
56
|
+
expect(feature.scenario_count).to eq(2)
|
57
|
+
end
|
83
58
|
|
84
|
-
|
85
|
-
|
59
|
+
it 'knows how many outlines it has' do
|
60
|
+
scenarios = [CukeModeler::Scenario.new]
|
61
|
+
outlines = [CukeModeler::Outline.new, CukeModeler::Outline.new]
|
86
62
|
|
63
|
+
feature.tests = []
|
64
|
+
expect(feature.outline_count).to eq(0)
|
87
65
|
|
88
|
-
|
89
|
-
|
90
|
-
|
66
|
+
feature.tests = scenarios + outlines
|
67
|
+
expect(feature.outline_count).to eq(2)
|
68
|
+
end
|
91
69
|
|
70
|
+
it 'knows how many test cases it has' do
|
71
|
+
source_1 = ['Feature: Test feature']
|
72
|
+
source_1 = source_1.join("\n")
|
92
73
|
|
93
|
-
|
74
|
+
source_2 = ['Feature: Test feature',
|
75
|
+
' Scenario: Test scenario',
|
76
|
+
' Scenario Outline: Test outline',
|
77
|
+
' * a step',
|
78
|
+
' Examples: Test examples',
|
79
|
+
' |param|',
|
80
|
+
' |value_1|',
|
81
|
+
' |value_2|']
|
82
|
+
source_2 = source_2.join("\n")
|
94
83
|
|
95
|
-
|
96
|
-
|
97
|
-
source = source.join("\n")
|
84
|
+
feature_1 = clazz.new(source_1)
|
85
|
+
feature_2 = clazz.new(source_2)
|
98
86
|
|
99
|
-
file_path = "#{@default_file_directory}/feature_test_file.feature"
|
100
|
-
File.open(file_path, 'w') { |file| file.write(source) }
|
101
87
|
|
102
|
-
|
103
|
-
|
88
|
+
expect(feature_1.test_case_count).to eq(0)
|
89
|
+
expect(feature_2.test_case_count).to eq(3)
|
104
90
|
end
|
105
91
|
|
106
92
|
|
107
|
-
|
108
|
-
directory = @feature.get_ancestor(:directory)
|
93
|
+
describe 'getting ancestors' do
|
109
94
|
|
110
|
-
|
111
|
-
|
95
|
+
before(:each) do
|
96
|
+
source = ['Feature: Test feature']
|
97
|
+
source = source.join("\n")
|
112
98
|
|
113
|
-
|
114
|
-
|
99
|
+
file_path = "#{@default_file_directory}/feature_test_file.feature"
|
100
|
+
File.open(file_path, 'w') { |file| file.write(source) }
|
101
|
+
end
|
115
102
|
|
116
|
-
|
117
|
-
|
103
|
+
let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
|
104
|
+
let(:feature) { directory.feature_files.first.features.first }
|
118
105
|
|
119
|
-
it 'returns nil if it does not have the requested type of ancestor' do
|
120
|
-
test = @feature.get_ancestor(:test)
|
121
106
|
|
122
|
-
|
123
|
-
|
107
|
+
it 'can get its directory' do
|
108
|
+
ancestor = feature.get_ancestor(:directory)
|
124
109
|
|
125
|
-
|
110
|
+
expect(ancestor).to equal(directory)
|
111
|
+
end
|
126
112
|
|
127
|
-
|
113
|
+
it 'can get its feature file' do
|
114
|
+
ancestor = feature.get_ancestor(:feature_file)
|
128
115
|
|
129
|
-
|
130
|
-
|
116
|
+
expect(ancestor).to equal(directory.feature_files.first)
|
117
|
+
end
|
131
118
|
|
132
|
-
|
133
|
-
|
119
|
+
it 'returns nil if it does not have the requested type of ancestor' do
|
120
|
+
ancestor = feature.get_ancestor(:test)
|
134
121
|
|
135
|
-
|
136
|
-
|
122
|
+
expect(ancestor).to be_nil
|
123
|
+
end
|
137
124
|
|
138
|
-
expect { @feature.to_s }.to_not raise_error
|
139
125
|
end
|
140
126
|
|
141
|
-
|
142
|
-
@feature.tests = [CukeModeler::Scenario.new]
|
127
|
+
describe 'feature output edge cases' do
|
143
128
|
|
144
|
-
|
145
|
-
|
129
|
+
context 'a new feature object' do
|
130
|
+
|
131
|
+
let(:feature) { clazz.new }
|
132
|
+
|
133
|
+
|
134
|
+
it 'can output a feature that has only tag elements' do
|
135
|
+
feature.tag_elements = [CukeModeler::Tag.new]
|
136
|
+
|
137
|
+
expect { feature.to_s }.to_not raise_error
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'can output a feature that has only a background' do
|
141
|
+
feature.background = [CukeModeler::Background.new]
|
142
|
+
|
143
|
+
expect { feature.to_s }.to_not raise_error
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'can output a feature that has only scenarios' do
|
147
|
+
feature.tests = [CukeModeler::Scenario.new]
|
148
|
+
|
149
|
+
expect { feature.to_s }.to_not raise_error
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'can output a feature that has only outlines' do
|
153
|
+
feature.tests = [CukeModeler::Outline.new]
|
154
|
+
|
155
|
+
expect { feature.to_s }.to_not raise_error
|
156
|
+
end
|
146
157
|
|
147
|
-
|
148
|
-
@feature.tests = [CukeModeler::Outline.new]
|
158
|
+
end
|
149
159
|
|
150
|
-
expect { @feature.to_s }.to_not raise_error
|
151
160
|
end
|
152
161
|
|
153
162
|
end
|
@@ -4,91 +4,106 @@ SimpleCov.command_name('Outline') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
4
|
|
5
5
|
describe 'Outline, Integration' do
|
6
6
|
|
7
|
-
|
8
|
-
source = ['@a_tag',
|
9
|
-
' Scenario Outline:',
|
10
|
-
' * a step',
|
11
|
-
' Examples:',
|
12
|
-
' | param |',
|
13
|
-
' | value |']
|
14
|
-
source = source.join("\n")
|
15
|
-
|
16
|
-
outline = CukeModeler::Outline.new(source)
|
17
|
-
example = outline.examples.first
|
18
|
-
step = outline.steps.first
|
19
|
-
tag = outline.tag_elements.first
|
20
|
-
|
21
|
-
example.parent_element.should equal outline
|
22
|
-
step.parent_element.should equal outline
|
23
|
-
tag.parent_element.should equal outline
|
24
|
-
end
|
7
|
+
let(:clazz) { CukeModeler::Outline }
|
25
8
|
|
26
9
|
|
27
|
-
|
10
|
+
describe 'unique behavior' do
|
28
11
|
|
29
|
-
|
30
|
-
source = ['
|
31
|
-
'',
|
32
|
-
' Scenario Outline: Test test',
|
12
|
+
it 'properly sets its child elements' do
|
13
|
+
source = ['@a_tag',
|
14
|
+
' Scenario Outline:',
|
33
15
|
' * a step',
|
34
|
-
' Examples:
|
35
|
-
' |
|
36
|
-
' |
|
16
|
+
' Examples:',
|
17
|
+
' | param |',
|
18
|
+
' | value |']
|
37
19
|
source = source.join("\n")
|
38
20
|
|
39
|
-
|
40
|
-
|
21
|
+
outline = clazz.new(source)
|
22
|
+
example = outline.examples.first
|
23
|
+
step = outline.steps.first
|
24
|
+
tag = outline.tag_elements.first
|
41
25
|
|
42
|
-
|
43
|
-
|
26
|
+
expect(example.parent_element).to equal(outline)
|
27
|
+
expect(step.parent_element).to equal(outline)
|
28
|
+
expect(tag.parent_element).to equal(outline)
|
44
29
|
end
|
45
30
|
|
46
31
|
|
47
|
-
|
48
|
-
directory = @outline.get_ancestor(:directory)
|
32
|
+
describe 'getting ancestors' do
|
49
33
|
|
50
|
-
|
51
|
-
|
34
|
+
before(:each) do
|
35
|
+
source = ['Feature: Test feature',
|
36
|
+
'',
|
37
|
+
' Scenario Outline: Test test',
|
38
|
+
' * a step',
|
39
|
+
' Examples: Test example',
|
40
|
+
' | a param |',
|
41
|
+
' | a value |']
|
42
|
+
source = source.join("\n")
|
52
43
|
|
53
|
-
|
54
|
-
|
44
|
+
file_path = "#{@default_file_directory}/outline_test_file.feature"
|
45
|
+
File.open(file_path, 'w') { |file| file.write(source) }
|
46
|
+
end
|
55
47
|
|
56
|
-
|
57
|
-
|
48
|
+
let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
|
49
|
+
let(:outline) { directory.feature_files.first.features.first.tests.first }
|
58
50
|
|
59
|
-
it 'can get its feature' do
|
60
|
-
feature = @outline.get_ancestor(:feature)
|
61
51
|
|
62
|
-
|
63
|
-
|
52
|
+
it 'can get its directory' do
|
53
|
+
ancestor = outline.get_ancestor(:directory)
|
64
54
|
|
65
|
-
|
66
|
-
|
55
|
+
expect(ancestor).to equal(directory)
|
56
|
+
end
|
67
57
|
|
68
|
-
|
69
|
-
|
58
|
+
it 'can get its feature file' do
|
59
|
+
ancestor = outline.get_ancestor(:feature_file)
|
70
60
|
|
71
|
-
|
61
|
+
expect(ancestor).to equal(directory.feature_files.first)
|
62
|
+
end
|
72
63
|
|
73
|
-
it 'can
|
74
|
-
|
64
|
+
it 'can get its feature' do
|
65
|
+
ancestor = outline.get_ancestor(:feature)
|
75
66
|
|
76
|
-
expect
|
67
|
+
expect(ancestor).to equal(directory.feature_files.first.features.first)
|
77
68
|
end
|
78
69
|
|
79
|
-
it '
|
80
|
-
|
70
|
+
it 'returns nil if it does not have the requested type of ancestor' do
|
71
|
+
ancestor = outline.get_ancestor(:test)
|
81
72
|
|
82
|
-
expect
|
73
|
+
expect(ancestor).to be_nil
|
83
74
|
end
|
84
75
|
|
85
|
-
|
86
|
-
|
76
|
+
describe 'outline output edge cases' do
|
77
|
+
|
78
|
+
context 'a new outline object' do
|
79
|
+
|
80
|
+
let(:outline) { clazz.new }
|
81
|
+
|
82
|
+
|
83
|
+
it 'can output an outline that has only tag elements' do
|
84
|
+
outline.tag_elements = [CukeModeler::Tag.new]
|
85
|
+
|
86
|
+
expect { outline.to_s }.to_not raise_error
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'can output an outline that has only steps' do
|
90
|
+
outline.steps = [CukeModeler::Step.new]
|
91
|
+
|
92
|
+
expect { outline.to_s }.to_not raise_error
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'can output an outline that has only examples' do
|
96
|
+
outline.examples = [CukeModeler::Example.new]
|
97
|
+
|
98
|
+
expect { outline.to_s }.to_not raise_error
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
87
102
|
|
88
|
-
expect { @outline.to_s }.to_not raise_error
|
89
103
|
end
|
90
104
|
|
91
105
|
end
|
92
106
|
|
93
107
|
end
|
108
|
+
|
94
109
|
end
|