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
@@ -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
- it 'properly sets its child elements' do
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
- file = CukeModeler::FeatureFile.new(file_path)
15
- feature = file.feature
10
+ describe 'unique behavior' do
16
11
 
17
- feature.parent_element.should equal file
18
- end
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
- context 'getting stuff' do
18
+ it 'properly sets its child elements' do
19
+ file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
21
20
 
22
- before(:each) do
23
- file_path = "#{@default_file_directory}/feature_file_test_file.feature"
24
- File.open(file_path, 'w') { |file| file.write('Feature: Test feature') }
21
+ File.open(file_path, "w") { |file|
22
+ file.puts('Feature: Test feature')
23
+ }
25
24
 
26
- @directory = CukeModeler::Directory.new(@default_file_directory)
27
- @feature_file = @directory.feature_files.first
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
- it 'can get its directory' do
32
- directory = @feature_file.get_ancestor(:directory)
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.should equal @directory
35
- end
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
- example.should be_nil
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 = CukeModeler::Feature
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
- 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")
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
- it 'can distinguish scenarios from outlines - #scenarios, #outlines' do
39
- scenarios = [CukeModeler::Scenario.new('Scenario: 1'), CukeModeler::Scenario.new('Scenario: 2')]
40
- outlines = [CukeModeler::Outline.new("Scenario Outline: 1\nExamples:\n|param|\n|value|"), CukeModeler::Outline.new("Scenario Outline: 2\nExamples:\n|param|\n|value|")]
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
- @feature.scenarios.should =~ scenarios
45
- @feature.outlines.should =~ outlines
46
- end
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
- @feature.tests = []
53
- @feature.scenario_count.should == 0
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
- @feature.tests = scenarios + outlines
56
- @feature.scenario_count.should == 2
57
- end
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
- it 'knows how many outlines it has - #outline_count' do
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
- @feature.tests = []
64
- @feature.outline_count.should == 0
44
+ expect(feature.scenarios).to match_array(scenarios)
45
+ expect(feature.outlines).to match_array(outlines)
46
+ end
65
47
 
66
- @feature.tests = scenarios + outlines
67
- @feature.outline_count.should == 2
68
- end
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
- it 'knows how many test cases it has - #test_case_count' do
71
- source_1 = ['Feature: Test feature']
72
- source_1 = source_1.join("\n")
52
+ feature.tests = []
53
+ expect(feature.scenario_count).to eq(0)
73
54
 
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")
55
+ feature.tests = scenarios + outlines
56
+ expect(feature.scenario_count).to eq(2)
57
+ end
83
58
 
84
- feature_1 = CukeModeler::Feature.new(source_1)
85
- feature_2 = CukeModeler::Feature.new(source_2)
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
- feature_1.test_case_count.should == 0
89
- feature_2.test_case_count.should == 3
90
- end
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
- context 'getting stuff' do
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
- before(:each) do
96
- source = ['Feature: Test feature']
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
- @directory = CukeModeler::Directory.new(@default_file_directory)
103
- @feature = @directory.feature_files.first.features.first
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
- it 'can get its directory' do
108
- directory = @feature.get_ancestor(:directory)
93
+ describe 'getting ancestors' do
109
94
 
110
- directory.should equal @directory
111
- end
95
+ before(:each) do
96
+ source = ['Feature: Test feature']
97
+ source = source.join("\n")
112
98
 
113
- it 'can get its feature file' do
114
- feature_file = @feature.get_ancestor(:feature_file)
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
- feature_file.should equal @directory.feature_files.first
117
- end
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
- test.should be_nil
123
- end
107
+ it 'can get its directory' do
108
+ ancestor = feature.get_ancestor(:directory)
124
109
 
125
- end
110
+ expect(ancestor).to equal(directory)
111
+ end
126
112
 
127
- context 'feature output edge cases' do
113
+ it 'can get its feature file' do
114
+ ancestor = feature.get_ancestor(:feature_file)
128
115
 
129
- it 'can output a feature that has only a tag elements' do
130
- @feature.tag_elements = [CukeModeler::Tag.new]
116
+ expect(ancestor).to equal(directory.feature_files.first)
117
+ end
131
118
 
132
- expect { @feature.to_s }.to_not raise_error
133
- end
119
+ it 'returns nil if it does not have the requested type of ancestor' do
120
+ ancestor = feature.get_ancestor(:test)
134
121
 
135
- it 'can output a feature that has only a background' do
136
- @feature.background = [CukeModeler::Background.new]
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
- it 'can output a feature that has only scenarios' do
142
- @feature.tests = [CukeModeler::Scenario.new]
127
+ describe 'feature output edge cases' do
143
128
 
144
- expect { @feature.to_s }.to_not raise_error
145
- end
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
- it 'can output a feature that has only outlines' do
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
- it 'properly sets its child elements' do
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
- context 'getting stuff' do
10
+ describe 'unique behavior' do
28
11
 
29
- before(:each) do
30
- source = ['Feature: Test feature',
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: Test example',
35
- ' | a param |',
36
- ' | a value |']
16
+ ' Examples:',
17
+ ' | param |',
18
+ ' | value |']
37
19
  source = source.join("\n")
38
20
 
39
- file_path = "#{@default_file_directory}/outline_test_file.feature"
40
- File.open(file_path, 'w') { |file| file.write(source) }
21
+ outline = clazz.new(source)
22
+ example = outline.examples.first
23
+ step = outline.steps.first
24
+ tag = outline.tag_elements.first
41
25
 
42
- @directory = CukeModeler::Directory.new(@default_file_directory)
43
- @outline = @directory.feature_files.first.features.first.tests.first
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
- it 'can get its directory' do
48
- directory = @outline.get_ancestor(:directory)
32
+ describe 'getting ancestors' do
49
33
 
50
- directory.should equal @directory
51
- end
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
- it 'can get its feature file' do
54
- feature_file = @outline.get_ancestor(:feature_file)
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
- feature_file.should equal @directory.feature_files.first
57
- end
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
- feature.should equal @directory.feature_files.first.features.first
63
- end
52
+ it 'can get its directory' do
53
+ ancestor = outline.get_ancestor(:directory)
64
54
 
65
- it 'returns nil if it does not have the requested type of ancestor' do
66
- test = @outline.get_ancestor(:test)
55
+ expect(ancestor).to equal(directory)
56
+ end
67
57
 
68
- test.should be_nil
69
- end
58
+ it 'can get its feature file' do
59
+ ancestor = outline.get_ancestor(:feature_file)
70
60
 
71
- context 'outline output edge cases' do
61
+ expect(ancestor).to equal(directory.feature_files.first)
62
+ end
72
63
 
73
- it 'can output an outline that has only a tag elements' do
74
- @outline.tag_elements = [CukeModeler::Tag.new]
64
+ it 'can get its feature' do
65
+ ancestor = outline.get_ancestor(:feature)
75
66
 
76
- expect { @outline.to_s }.to_not raise_error
67
+ expect(ancestor).to equal(directory.feature_files.first.features.first)
77
68
  end
78
69
 
79
- it 'can output an outline that has only steps' do
80
- @outline.steps = [CukeModeler::Step.new]
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 { @outline.to_s }.to_not raise_error
73
+ expect(ancestor).to be_nil
83
74
  end
84
75
 
85
- it 'can output an outline that has only examples' do
86
- @outline.examples = [CukeModeler::Example.new]
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