cuke_modeler 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
SimpleCov.command_name('Row') unless RUBY_VERSION.to_s < '1.9.0'
|
4
|
+
|
5
|
+
describe 'Row, Integration' do
|
6
|
+
|
7
|
+
let(:clazz) { CukeModeler::Row }
|
8
|
+
|
9
|
+
|
10
|
+
describe 'unique behavior' do
|
11
|
+
|
12
|
+
describe 'getting ancestors' do
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
source = ['Feature: Test feature',
|
16
|
+
'',
|
17
|
+
' Scenario Outline: Test test',
|
18
|
+
' * a step',
|
19
|
+
' Examples: Test example',
|
20
|
+
' | a param |',
|
21
|
+
' | a value |']
|
22
|
+
source = source.join("\n")
|
23
|
+
|
24
|
+
file_path = "#{@default_file_directory}/row_test_file.feature"
|
25
|
+
File.open(file_path, 'w') { |file| file.write(source) }
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
|
29
|
+
let(:row) { directory.feature_files.first.features.first.tests.first.examples.first.row_elements.first }
|
30
|
+
|
31
|
+
|
32
|
+
it 'can get its directory' do
|
33
|
+
ancestor = row.get_ancestor(:directory)
|
34
|
+
|
35
|
+
ancestor.should equal directory
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'can get its feature file' do
|
39
|
+
ancestor = row.get_ancestor(:feature_file)
|
40
|
+
|
41
|
+
ancestor.should equal directory.feature_files.first
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'can get its feature' do
|
45
|
+
ancestor = row.get_ancestor(:feature)
|
46
|
+
|
47
|
+
ancestor.should equal directory.feature_files.first.features.first
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'can get its test' do
|
51
|
+
ancestor = row.get_ancestor(:test)
|
52
|
+
|
53
|
+
ancestor.should equal directory.feature_files.first.features.first.tests.first
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'can get its example' do
|
57
|
+
ancestor = row.get_ancestor(:example)
|
58
|
+
|
59
|
+
ancestor.should equal directory.feature_files.first.features.first.tests.first.examples.first
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'returns nil if it does not have the requested type of ancestor' do
|
63
|
+
ancestor = row.get_ancestor(:table)
|
64
|
+
|
65
|
+
ancestor.should be_nil
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -4,77 +4,92 @@ SimpleCov.command_name('Scenario') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
4
|
|
5
5
|
describe 'Scenario, Integration' do
|
6
6
|
|
7
|
-
|
8
|
-
source = ['@a_tag',
|
9
|
-
'Scenario: Test scenario',
|
10
|
-
' * a step']
|
11
|
-
source = source.join("\n")
|
12
|
-
|
13
|
-
scenario = CukeModeler::Scenario.new(source)
|
14
|
-
step = scenario.steps.first
|
15
|
-
tag = scenario.tag_elements.first
|
16
|
-
|
17
|
-
step.parent_element.should equal scenario
|
18
|
-
tag.parent_element.should equal scenario
|
19
|
-
end
|
7
|
+
let(:clazz) { CukeModeler::Scenario }
|
20
8
|
|
21
9
|
|
22
|
-
|
10
|
+
describe 'unique behavior' do
|
23
11
|
|
24
|
-
|
25
|
-
source = ['
|
26
|
-
'',
|
27
|
-
'
|
28
|
-
' * a step']
|
12
|
+
it 'properly sets its child elements' do
|
13
|
+
source = ['@a_tag',
|
14
|
+
'Scenario: Test scenario',
|
15
|
+
' * a step']
|
29
16
|
source = source.join("\n")
|
30
17
|
|
31
|
-
|
32
|
-
|
18
|
+
scenario = clazz.new(source)
|
19
|
+
step = scenario.steps.first
|
20
|
+
tag = scenario.tag_elements.first
|
33
21
|
|
34
|
-
|
35
|
-
|
22
|
+
step.parent_element.should equal scenario
|
23
|
+
tag.parent_element.should equal scenario
|
36
24
|
end
|
37
25
|
|
38
26
|
|
39
|
-
|
40
|
-
directory = @scenario.get_ancestor(:directory)
|
27
|
+
describe 'getting ancestors' do
|
41
28
|
|
42
|
-
|
43
|
-
|
29
|
+
before(:each) do
|
30
|
+
source = ['Feature: Test feature',
|
31
|
+
'',
|
32
|
+
' Scenario: Test test',
|
33
|
+
' * a step']
|
34
|
+
source = source.join("\n")
|
44
35
|
|
45
|
-
|
46
|
-
|
36
|
+
file_path = "#{@default_file_directory}/scenario_test_file.feature"
|
37
|
+
File.open(file_path, 'w') { |file| file.write(source) }
|
38
|
+
end
|
47
39
|
|
48
|
-
|
49
|
-
|
40
|
+
let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
|
41
|
+
let(:scenario) { directory.feature_files.first.features.first.tests.first }
|
50
42
|
|
51
|
-
it 'can get its feature' do
|
52
|
-
feature = @scenario.get_ancestor(:feature)
|
53
43
|
|
54
|
-
|
55
|
-
|
44
|
+
it 'can get its directory' do
|
45
|
+
ancestor = scenario.get_ancestor(:directory)
|
56
46
|
|
57
|
-
|
58
|
-
|
47
|
+
ancestor.should equal directory
|
48
|
+
end
|
59
49
|
|
60
|
-
|
61
|
-
|
50
|
+
it 'can get its feature file' do
|
51
|
+
ancestor = scenario.get_ancestor(:feature_file)
|
52
|
+
|
53
|
+
ancestor.should equal directory.feature_files.first
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'can get its feature' do
|
57
|
+
ancestor = scenario.get_ancestor(:feature)
|
62
58
|
|
63
|
-
|
59
|
+
ancestor.should equal directory.feature_files.first.features.first
|
60
|
+
end
|
64
61
|
|
65
|
-
it '
|
66
|
-
|
62
|
+
it 'returns nil if it does not have the requested type of ancestor' do
|
63
|
+
ancestor = scenario.get_ancestor(:test)
|
67
64
|
|
68
|
-
|
65
|
+
ancestor.should be_nil
|
69
66
|
end
|
70
67
|
|
71
|
-
|
72
|
-
|
68
|
+
describe 'scenario output edge cases' do
|
69
|
+
|
70
|
+
context 'a new scenario object' do
|
71
|
+
|
72
|
+
let(:scenario) { clazz.new }
|
73
|
+
|
74
|
+
|
75
|
+
it 'can output a scenario that has only tag elements' do
|
76
|
+
scenario.tag_elements = [CukeModeler::Tag.new]
|
77
|
+
|
78
|
+
expect { scenario.to_s }.to_not raise_error
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'can output a scenario that has only steps' do
|
82
|
+
scenario.steps = [CukeModeler::Step.new]
|
83
|
+
|
84
|
+
expect { scenario.to_s }.to_not raise_error
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
73
88
|
|
74
|
-
expect { @scenario.to_s }.to_not raise_error
|
75
89
|
end
|
76
90
|
|
77
91
|
end
|
78
92
|
|
79
93
|
end
|
94
|
+
|
80
95
|
end
|
@@ -4,181 +4,190 @@ SimpleCov.command_name('Step') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
4
|
|
5
5
|
describe 'Step, Integration' do
|
6
6
|
|
7
|
-
|
8
|
-
source_1 = ['* a step',
|
9
|
-
'"""',
|
10
|
-
'a doc string',
|
11
|
-
'"""']
|
12
|
-
source_2 = ['* a step',
|
13
|
-
'| a block|']
|
7
|
+
let(:clazz) { CukeModeler::Step }
|
14
8
|
|
15
|
-
step_1 = CukeModeler::Step.new(source_1.join("\n"))
|
16
|
-
step_2 = CukeModeler::Step.new(source_2.join("\n"))
|
17
9
|
|
10
|
+
describe 'unique behavior' do
|
18
11
|
|
19
|
-
|
20
|
-
|
12
|
+
it 'properly sets its child elements' do
|
13
|
+
source_1 = ['* a step',
|
14
|
+
'"""',
|
15
|
+
'a doc string',
|
16
|
+
'"""']
|
17
|
+
source_2 = ['* a step',
|
18
|
+
'| a block|']
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
20
|
+
step_1 = clazz.new(source_1.join("\n"))
|
21
|
+
step_2 = clazz.new(source_2.join("\n"))
|
25
22
|
|
26
|
-
it 'defaults to the World delimiters if its own are not set' do
|
27
|
-
world = CukeModeler::World
|
28
|
-
world.left_delimiter = '"'
|
29
|
-
world.right_delimiter = '"'
|
30
23
|
|
31
|
-
|
32
|
-
|
33
|
-
step.left_delimiter = nil
|
24
|
+
doc_string = step_1.block
|
25
|
+
table = step_2.block
|
34
26
|
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
doc_string.parent_element.should equal step_1
|
28
|
+
table.parent_element.should equal step_2
|
29
|
+
end
|
38
30
|
|
39
|
-
|
40
|
-
|
31
|
+
it 'defaults to the World delimiters if its own are not set' do
|
32
|
+
world = CukeModeler::World
|
33
|
+
world.left_delimiter = '"'
|
34
|
+
world.right_delimiter = '"'
|
41
35
|
|
42
|
-
|
43
|
-
|
44
|
-
|
36
|
+
step = clazz.new
|
37
|
+
step.right_delimiter = nil
|
38
|
+
step.left_delimiter = nil
|
45
39
|
|
46
|
-
|
40
|
+
step.right_delimiter.should == '"'
|
41
|
+
step.left_delimiter.should == '"'
|
42
|
+
end
|
47
43
|
|
48
|
-
|
49
|
-
|
44
|
+
it 'attempts to determine its arguments during creation' do
|
45
|
+
source = 'Given a test step with *parameter 1* and "parameter 2" and *parameter 3*'
|
50
46
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
world.right_delimiter = nil
|
47
|
+
world = CukeModeler::World
|
48
|
+
world.left_delimiter = '"'
|
49
|
+
world.right_delimiter = '"'
|
55
50
|
|
56
|
-
|
57
|
-
step = CukeModeler::Step.new(source)
|
51
|
+
step = clazz.new(source)
|
58
52
|
|
59
|
-
|
53
|
+
step.arguments.should == ['parameter 2']
|
54
|
+
end
|
60
55
|
|
61
|
-
|
62
|
-
|
56
|
+
it 'finds nothing when no regular expression or delimiters are available' do
|
57
|
+
world = CukeModeler::World
|
58
|
+
world.left_delimiter = nil
|
59
|
+
world.right_delimiter = nil
|
63
60
|
|
64
|
-
|
65
|
-
|
66
|
-
source_2 = "Given a test step with *parameter 3* and *parameter 4*\n|another block|"
|
67
|
-
source_3 = 'Given a different *parameterized* step'
|
61
|
+
source = 'Given a test step with *parameter 1* and "parameter 2" and *parameter 3*'
|
62
|
+
step = clazz.new(source)
|
68
63
|
|
69
|
-
|
70
|
-
step_2 = CukeModeler::Step.new(source_2)
|
71
|
-
step_3 = CukeModeler::Step.new(source_3)
|
64
|
+
step.scan_arguments
|
72
65
|
|
73
|
-
|
74
|
-
|
75
|
-
step_3.delimiter = '*'
|
66
|
+
step.arguments.should == []
|
67
|
+
end
|
76
68
|
|
69
|
+
it 'can determine its equality with another Step' do
|
70
|
+
source_1 = "Given a test step with *parameter 1* and *parameter 2*\n|a block|"
|
71
|
+
source_2 = "Given a test step with *parameter 3* and *parameter 4*\n|another block|"
|
72
|
+
source_3 = 'Given a different *parameterized* step'
|
77
73
|
|
78
|
-
|
79
|
-
|
80
|
-
|
74
|
+
step_1 = clazz.new(source_1)
|
75
|
+
step_2 = clazz.new(source_2)
|
76
|
+
step_3 = clazz.new(source_3)
|
81
77
|
|
82
|
-
|
78
|
+
step_1.delimiter = '*'
|
79
|
+
step_2.delimiter = '*'
|
80
|
+
step_3.delimiter = '*'
|
83
81
|
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
|
83
|
+
(step_1 == step_2).should be_true
|
84
|
+
(step_1 == step_3).should be_false
|
87
85
|
end
|
88
86
|
|
87
|
+
describe '#step_text' do
|
89
88
|
|
90
|
-
|
91
|
-
|
92
|
-
step_with_block = CukeModeler::Step.new(source)
|
89
|
+
let(:source) { "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|" }
|
90
|
+
let(:step) { clazz.new(source) }
|
93
91
|
|
94
|
-
expected_output = ['Given a test step with -parameter 1- ^and@ *parameter 2!!',
|
95
|
-
'|a block|']
|
96
92
|
|
97
|
-
|
93
|
+
it 'returns the step\'s entire text by default' do
|
94
|
+
source = "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|"
|
95
|
+
step_with_block = clazz.new(source)
|
98
96
|
|
99
|
-
|
100
|
-
|
97
|
+
expected_output = ['Given a test step with -parameter 1- ^and@ *parameter 2!!',
|
98
|
+
'|a block|']
|
101
99
|
|
102
|
-
|
100
|
+
step_with_block.step_text.should == expected_output
|
103
101
|
|
104
|
-
|
105
|
-
|
102
|
+
source = 'Given a test step with -parameter 1- ^and@ *parameter 2!!'
|
103
|
+
step_without_block = clazz.new(source)
|
104
|
+
|
105
|
+
expected_output = ['Given a test step with -parameter 1- ^and@ *parameter 2!!']
|
106
|
+
|
107
|
+
step_without_block.step_text.should == expected_output
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'can provide the step\'s text without the keyword' do
|
111
|
+
expected_output = ['a test step with -parameter 1- ^and@ *parameter 2!!',
|
112
|
+
'|a block|']
|
106
113
|
|
107
|
-
|
108
|
-
|
109
|
-
'|a block|']
|
114
|
+
step.step_text(:with_keywords => false).should == expected_output
|
115
|
+
end
|
110
116
|
|
111
|
-
@step.step_text(:with_keywords => false).should == expected_output
|
112
117
|
end
|
113
118
|
|
114
|
-
|
119
|
+
describe 'getting ancestors' do
|
115
120
|
|
116
|
-
|
121
|
+
before(:each) do
|
122
|
+
source = ['Feature: Test feature',
|
123
|
+
'',
|
124
|
+
' Scenario: Test test',
|
125
|
+
' * a step:']
|
126
|
+
source = source.join("\n")
|
117
127
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
' Scenario: Test test',
|
122
|
-
' * a step:']
|
123
|
-
source = source.join("\n")
|
128
|
+
file_path = "#{@default_file_directory}/step_test_file.feature"
|
129
|
+
File.open(file_path, 'w') { |file| file.write(source) }
|
130
|
+
end
|
124
131
|
|
125
|
-
|
126
|
-
|
132
|
+
let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
|
133
|
+
let(:step) { directory.feature_files.first.features.first.tests.first.steps.first }
|
127
134
|
|
128
|
-
@directory = CukeModeler::Directory.new(@default_file_directory)
|
129
|
-
@step = @directory.feature_files.first.features.first.tests.first.steps.first
|
130
|
-
end
|
131
135
|
|
136
|
+
it 'can get its directory' do
|
137
|
+
ancestor = step.get_ancestor(:directory)
|
132
138
|
|
133
|
-
|
134
|
-
|
139
|
+
ancestor.should equal directory
|
140
|
+
end
|
135
141
|
|
136
|
-
|
137
|
-
|
142
|
+
it 'can get its feature file' do
|
143
|
+
ancestor = step.get_ancestor(:feature_file)
|
138
144
|
|
139
|
-
|
140
|
-
|
145
|
+
ancestor.should equal directory.feature_files.first
|
146
|
+
end
|
141
147
|
|
142
|
-
|
143
|
-
|
148
|
+
it 'can get its feature' do
|
149
|
+
ancestor = step.get_ancestor(:feature)
|
144
150
|
|
145
|
-
|
146
|
-
|
151
|
+
ancestor.should equal directory.feature_files.first.features.first
|
152
|
+
end
|
147
153
|
|
148
|
-
|
149
|
-
|
154
|
+
it 'can get its test' do
|
155
|
+
ancestor = step.get_ancestor(:test)
|
150
156
|
|
151
|
-
|
152
|
-
|
157
|
+
ancestor.should equal directory.feature_files.first.features.first.tests.first
|
158
|
+
end
|
153
159
|
|
154
|
-
|
155
|
-
|
160
|
+
it 'returns nil if it does not have the requested type of ancestor' do
|
161
|
+
ancestor = step.get_ancestor(:example)
|
156
162
|
|
157
|
-
|
158
|
-
|
163
|
+
ancestor.should be_nil
|
164
|
+
end
|
159
165
|
|
160
|
-
example.should be_nil
|
161
166
|
end
|
162
167
|
|
163
|
-
|
168
|
+
describe 'step output edge cases' do
|
164
169
|
|
165
|
-
|
170
|
+
context 'a new step object' do
|
166
171
|
|
167
|
-
|
168
|
-
@step = CukeModeler::Step.new
|
169
|
-
end
|
172
|
+
let(:step) { clazz.new }
|
170
173
|
|
171
|
-
it 'can output a step that has only a table' do
|
172
|
-
@step.block = CukeModeler::Table.new
|
173
174
|
|
174
|
-
|
175
|
-
|
175
|
+
it 'can output a step that has only a table' do
|
176
|
+
step.block = CukeModeler::Table.new
|
177
|
+
|
178
|
+
expect { step.to_s }.to_not raise_error
|
179
|
+
end
|
176
180
|
|
177
|
-
|
178
|
-
|
181
|
+
it 'can output a step that has only a doc string' do
|
182
|
+
step.block = CukeModeler::DocString.new
|
183
|
+
|
184
|
+
expect { step.to_s }.to_not raise_error
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
179
188
|
|
180
|
-
expect { @step.to_s }.to_not raise_error
|
181
189
|
end
|
182
190
|
|
183
191
|
end
|
192
|
+
|
184
193
|
end
|