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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +8 -0
  3. data/features/step_definitions/feature_steps.rb +1 -1
  4. data/features/step_definitions/test_steps.rb +6 -2
  5. data/lib/cuke_modeler/directory.rb +7 -10
  6. data/lib/cuke_modeler/version.rb +1 -1
  7. data/spec/integration/background_integration_spec.rb +53 -40
  8. data/spec/integration/directory_integration_spec.rb +39 -26
  9. data/spec/integration/doc_string_integration_spec.rb +51 -43
  10. data/spec/integration/example_integration_spec.rb +71 -60
  11. data/spec/integration/feature_file_integration_spec.rb +36 -22
  12. data/spec/integration/feature_integration_spec.rb +113 -104
  13. data/spec/integration/outline_integration_spec.rb +71 -56
  14. data/spec/integration/row_integration_spec.rb +72 -0
  15. data/spec/integration/scenario_integration_spec.rb +61 -46
  16. data/spec/integration/step_integration_spec.rb +126 -117
  17. data/spec/integration/table_integration_spec.rb +67 -52
  18. data/spec/integration/table_row_integration_spec.rb +48 -40
  19. data/spec/integration/tag_integration_spec.rb +53 -45
  20. data/spec/integration/world_integration_spec.rb +2 -1
  21. data/spec/spec_helper.rb +15 -12
  22. data/spec/unit/background_unit_spec.rb +65 -50
  23. data/spec/unit/bare_bones_unit_specs.rb +2 -3
  24. data/spec/unit/containing_element_unit_specs.rb +6 -7
  25. data/spec/unit/directory_unit_spec.rb +103 -64
  26. data/spec/unit/doc_string_unit_spec.rb +113 -95
  27. data/spec/unit/example_unit_spec.rb +235 -219
  28. data/spec/unit/feature_element_unit_spec.rb +6 -6
  29. data/spec/unit/feature_element_unit_specs.rb +28 -24
  30. data/spec/unit/feature_file_unit_spec.rb +73 -63
  31. data/spec/unit/feature_unit_spec.rb +145 -111
  32. data/spec/unit/nested_element_unit_specs.rb +14 -13
  33. data/spec/unit/nested_unit_spec.rb +24 -21
  34. data/spec/unit/outline_unit_spec.rb +92 -78
  35. data/spec/unit/parsing_unit_spec.rb +55 -51
  36. data/spec/unit/prepopulated_unit_specs.rb +2 -3
  37. data/spec/unit/raw_element_unit_specs.rb +12 -11
  38. data/spec/unit/raw_unit_spec.rb +15 -12
  39. data/spec/unit/row_unit_spec.rb +68 -52
  40. data/spec/unit/scenario_unit_spec.rb +76 -62
  41. data/spec/unit/sourceable_unit_spec.rb +8 -6
  42. data/spec/unit/sourced_element_unit_specs.rb +4 -6
  43. data/spec/unit/step_unit_spec.rb +231 -203
  44. data/spec/unit/table_row_unit_spec.rb +68 -52
  45. data/spec/unit/table_unit_spec.rb +100 -82
  46. data/spec/unit/tag_unit_spec.rb +62 -48
  47. data/spec/unit/taggable_unit_spec.rb +58 -51
  48. data/spec/unit/tagged_element_unit_specs.rb +28 -26
  49. data/spec/unit/test_element_unit_spec.rb +33 -27
  50. data/spec/unit/test_element_unit_specs.rb +15 -14
  51. data/spec/unit/world_unit_spec.rb +94 -84
  52. 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
- it 'properly sets its child elements' do
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
- context 'getting stuff' do
10
+ describe 'unique behavior' do
23
11
 
24
- before(:each) do
25
- source = ['Feature: Test feature',
26
- '',
27
- ' Scenario: Test test',
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
- file_path = "#{@default_file_directory}/scenario_test_file.feature"
32
- File.open(file_path, 'w') { |file| file.write(source) }
18
+ scenario = clazz.new(source)
19
+ step = scenario.steps.first
20
+ tag = scenario.tag_elements.first
33
21
 
34
- @directory = CukeModeler::Directory.new(@default_file_directory)
35
- @scenario = @directory.feature_files.first.features.first.tests.first
22
+ step.parent_element.should equal scenario
23
+ tag.parent_element.should equal scenario
36
24
  end
37
25
 
38
26
 
39
- it 'can get its directory' do
40
- directory = @scenario.get_ancestor(:directory)
27
+ describe 'getting ancestors' do
41
28
 
42
- directory.should equal @directory
43
- end
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
- it 'can get its feature file' do
46
- feature_file = @scenario.get_ancestor(:feature_file)
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
- feature_file.should equal @directory.feature_files.first
49
- end
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
- feature.should equal @directory.feature_files.first.features.first
55
- end
44
+ it 'can get its directory' do
45
+ ancestor = scenario.get_ancestor(:directory)
56
46
 
57
- it 'returns nil if it does not have the requested type of ancestor' do
58
- test = @scenario.get_ancestor(:test)
47
+ ancestor.should equal directory
48
+ end
59
49
 
60
- test.should be_nil
61
- end
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
- context 'scenario output edge cases' do
59
+ ancestor.should equal directory.feature_files.first.features.first
60
+ end
64
61
 
65
- it 'can output a scenario that has only a tag elements' do
66
- @scenario.tag_elements = [CukeModeler::Tag.new]
62
+ it 'returns nil if it does not have the requested type of ancestor' do
63
+ ancestor = scenario.get_ancestor(:test)
67
64
 
68
- expect { @scenario.to_s }.to_not raise_error
65
+ ancestor.should be_nil
69
66
  end
70
67
 
71
- it 'can output a scenario that has only steps' do
72
- @scenario.steps = [CukeModeler::Step.new]
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
- it 'properly sets its child elements' do
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
- doc_string = step_1.block
20
- table = step_2.block
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
- doc_string.parent_element.should equal step_1
23
- table.parent_element.should equal step_2
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
- step = CukeModeler::Step.new
32
- step.right_delimiter = nil
33
- step.left_delimiter = nil
24
+ doc_string = step_1.block
25
+ table = step_2.block
34
26
 
35
- step.right_delimiter.should == '"'
36
- step.left_delimiter.should == '"'
37
- end
27
+ doc_string.parent_element.should equal step_1
28
+ table.parent_element.should equal step_2
29
+ end
38
30
 
39
- it 'attempts to determine its arguments during creation' do
40
- source = 'Given a test step with *parameter 1* and "parameter 2" and *parameter 3*'
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
- world = CukeModeler::World
43
- world.left_delimiter = '"'
44
- world.right_delimiter = '"'
36
+ step = clazz.new
37
+ step.right_delimiter = nil
38
+ step.left_delimiter = nil
45
39
 
46
- step = CukeModeler::Step.new(source)
40
+ step.right_delimiter.should == '"'
41
+ step.left_delimiter.should == '"'
42
+ end
47
43
 
48
- step.arguments.should == ['parameter 2']
49
- end
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
- it 'finds nothing when no regular expression or delimiters are available' do
52
- world = CukeModeler::World
53
- world.left_delimiter = nil
54
- world.right_delimiter = nil
47
+ world = CukeModeler::World
48
+ world.left_delimiter = '"'
49
+ world.right_delimiter = '"'
55
50
 
56
- source = 'Given a test step with *parameter 1* and "parameter 2" and *parameter 3*'
57
- step = CukeModeler::Step.new(source)
51
+ step = clazz.new(source)
58
52
 
59
- step.scan_arguments
53
+ step.arguments.should == ['parameter 2']
54
+ end
60
55
 
61
- step.arguments.should == []
62
- end
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
- it 'can determine its equality with another Step' do
65
- source_1 = "Given a test step with *parameter 1* and *parameter 2*\n|a block|"
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
- step_1 = CukeModeler::Step.new(source_1)
70
- step_2 = CukeModeler::Step.new(source_2)
71
- step_3 = CukeModeler::Step.new(source_3)
64
+ step.scan_arguments
72
65
 
73
- step_1.delimiter = '*'
74
- step_2.delimiter = '*'
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
- (step_1 == step_2).should be_true
79
- (step_1 == step_3).should be_false
80
- end
74
+ step_1 = clazz.new(source_1)
75
+ step_2 = clazz.new(source_2)
76
+ step_3 = clazz.new(source_3)
81
77
 
82
- context '#step_text ' do
78
+ step_1.delimiter = '*'
79
+ step_2.delimiter = '*'
80
+ step_3.delimiter = '*'
83
81
 
84
- before(:each) do
85
- source = "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|"
86
- @step = CukeModeler::Step.new(source)
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
- it 'returns the step\'s entire text by default' do
91
- source = "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|"
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
- step_with_block.step_text.should == expected_output
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
- source = 'Given a test step with -parameter 1- ^and@ *parameter 2!!'
100
- step_without_block = CukeModeler::Step.new(source)
97
+ expected_output = ['Given a test step with -parameter 1- ^and@ *parameter 2!!',
98
+ '|a block|']
101
99
 
102
- expected_output = ['Given a test step with -parameter 1- ^and@ *parameter 2!!']
100
+ step_with_block.step_text.should == expected_output
103
101
 
104
- step_without_block.step_text.should == expected_output
105
- end
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
- it 'can provide the step\'s text without the keyword' do
108
- expected_output = ['a test step with -parameter 1- ^and@ *parameter 2!!',
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
- end
119
+ describe 'getting ancestors' do
115
120
 
116
- context 'getting stuff' do
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
- before(:each) do
119
- source = ['Feature: Test feature',
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
- file_path = "#{@default_file_directory}/step_test_file.feature"
126
- File.open(file_path, 'w') { |file| file.write(source) }
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
- it 'can get its directory' do
134
- directory = @step.get_ancestor(:directory)
139
+ ancestor.should equal directory
140
+ end
135
141
 
136
- directory.should equal @directory
137
- end
142
+ it 'can get its feature file' do
143
+ ancestor = step.get_ancestor(:feature_file)
138
144
 
139
- it 'can get its feature file' do
140
- feature_file = @step.get_ancestor(:feature_file)
145
+ ancestor.should equal directory.feature_files.first
146
+ end
141
147
 
142
- feature_file.should equal @directory.feature_files.first
143
- end
148
+ it 'can get its feature' do
149
+ ancestor = step.get_ancestor(:feature)
144
150
 
145
- it 'can get its feature' do
146
- feature = @step.get_ancestor(:feature)
151
+ ancestor.should equal directory.feature_files.first.features.first
152
+ end
147
153
 
148
- feature.should equal @directory.feature_files.first.features.first
149
- end
154
+ it 'can get its test' do
155
+ ancestor = step.get_ancestor(:test)
150
156
 
151
- it 'can get its test' do
152
- test = @step.get_ancestor(:test)
157
+ ancestor.should equal directory.feature_files.first.features.first.tests.first
158
+ end
153
159
 
154
- test.should equal @directory.feature_files.first.features.first.tests.first
155
- end
160
+ it 'returns nil if it does not have the requested type of ancestor' do
161
+ ancestor = step.get_ancestor(:example)
156
162
 
157
- it 'returns nil if it does not have the requested type of ancestor' do
158
- example = @step.get_ancestor(:example)
163
+ ancestor.should be_nil
164
+ end
159
165
 
160
- example.should be_nil
161
166
  end
162
167
 
163
- end
168
+ describe 'step output edge cases' do
164
169
 
165
- context 'step output edge cases' do
170
+ context 'a new step object' do
166
171
 
167
- before(:each) do
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
- expect { @step.to_s }.to_not raise_error
175
- end
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
- it 'can output a step that has only a doc string' do
178
- @step.block = CukeModeler::DocString.new
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