cuke_modeler 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.simplecov +8 -0
  4. data/Gemfile +4 -0
  5. data/History.rdoc +3 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +73 -0
  8. data/Rakefile +38 -0
  9. data/cuke_modeler.gemspec +29 -0
  10. data/features/analysis/test_comparison.feature +123 -0
  11. data/features/analysis/test_manipulation.feature +37 -0
  12. data/features/modeling/background_modeling.feature +75 -0
  13. data/features/modeling/background_output.feature +130 -0
  14. data/features/modeling/directory_modeling.feature +120 -0
  15. data/features/modeling/directory_output.feature +13 -0
  16. data/features/modeling/doc_string_modeling.feature +63 -0
  17. data/features/modeling/doc_string_output.feature +71 -0
  18. data/features/modeling/example_modeling.feature +111 -0
  19. data/features/modeling/example_output.feature +192 -0
  20. data/features/modeling/feature_file_modeling.feature +64 -0
  21. data/features/modeling/feature_file_output.feature +13 -0
  22. data/features/modeling/feature_modeling.feature +164 -0
  23. data/features/modeling/feature_output.feature +244 -0
  24. data/features/modeling/outline_modeling.feature +100 -0
  25. data/features/modeling/outline_output.feature +197 -0
  26. data/features/modeling/row_modeling.feature +77 -0
  27. data/features/modeling/row_output.feature +27 -0
  28. data/features/modeling/scenario_modeling.feature +89 -0
  29. data/features/modeling/scenario_output.feature +147 -0
  30. data/features/modeling/step_modeling.feature +85 -0
  31. data/features/modeling/step_output.feature +52 -0
  32. data/features/modeling/table_modeling.feature +52 -0
  33. data/features/modeling/table_output.feature +42 -0
  34. data/features/modeling/table_row_modeling.feature +67 -0
  35. data/features/modeling/table_row_output.feature +27 -0
  36. data/features/modeling/tag_modeling.feature +58 -0
  37. data/features/modeling/tag_output.feature +16 -0
  38. data/features/step_definitions/action_steps.rb +3 -0
  39. data/features/step_definitions/background_steps.rb +81 -0
  40. data/features/step_definitions/directory_steps.rb +52 -0
  41. data/features/step_definitions/doc_string_steps.rb +63 -0
  42. data/features/step_definitions/feature_file_steps.rb +41 -0
  43. data/features/step_definitions/feature_steps.rb +96 -0
  44. data/features/step_definitions/outline_steps.rb +252 -0
  45. data/features/step_definitions/setup_steps.rb +50 -0
  46. data/features/step_definitions/spec_steps.rb +18 -0
  47. data/features/step_definitions/step_steps.rb +159 -0
  48. data/features/step_definitions/table_steps.rb +54 -0
  49. data/features/step_definitions/tag_steps.rb +61 -0
  50. data/features/step_definitions/test_steps.rb +114 -0
  51. data/features/step_definitions/verification_steps.rb +9 -0
  52. data/features/support/env.rb +27 -0
  53. data/features/support/transforms.rb +3 -0
  54. data/lib/cuke_modeler.rb +29 -0
  55. data/lib/cuke_modeler/background.rb +38 -0
  56. data/lib/cuke_modeler/containing.rb +18 -0
  57. data/lib/cuke_modeler/directory.rb +86 -0
  58. data/lib/cuke_modeler/doc_string.rb +87 -0
  59. data/lib/cuke_modeler/example.rb +184 -0
  60. data/lib/cuke_modeler/feature.rb +147 -0
  61. data/lib/cuke_modeler/feature_element.rb +73 -0
  62. data/lib/cuke_modeler/feature_file.rb +77 -0
  63. data/lib/cuke_modeler/nested.rb +34 -0
  64. data/lib/cuke_modeler/outline.rb +68 -0
  65. data/lib/cuke_modeler/parsing.rb +32 -0
  66. data/lib/cuke_modeler/raw.rb +20 -0
  67. data/lib/cuke_modeler/row.rb +64 -0
  68. data/lib/cuke_modeler/scenario.rb +45 -0
  69. data/lib/cuke_modeler/sourceable.rb +20 -0
  70. data/lib/cuke_modeler/step.rb +214 -0
  71. data/lib/cuke_modeler/table.rb +90 -0
  72. data/lib/cuke_modeler/table_row.rb +64 -0
  73. data/lib/cuke_modeler/tag.rb +62 -0
  74. data/lib/cuke_modeler/taggable.rb +54 -0
  75. data/lib/cuke_modeler/test_element.rb +77 -0
  76. data/lib/cuke_modeler/version.rb +3 -0
  77. data/lib/cuke_modeler/world.rb +113 -0
  78. data/spec/integration/background_integration_spec.rb +72 -0
  79. data/spec/integration/directory_integration_spec.rb +48 -0
  80. data/spec/integration/doc_string_integration_spec.rb +66 -0
  81. data/spec/integration/example_integration_spec.rb +94 -0
  82. data/spec/integration/feature_file_integration_spec.rb +44 -0
  83. data/spec/integration/feature_integration_spec.rb +152 -0
  84. data/spec/integration/outline_integration_spec.rb +92 -0
  85. data/spec/integration/scenario_integration_spec.rb +80 -0
  86. data/spec/integration/step_integration_spec.rb +184 -0
  87. data/spec/integration/table_integration_spec.rb +86 -0
  88. data/spec/integration/table_row_integration_spec.rb +68 -0
  89. data/spec/integration/tag_integration_spec.rb +67 -0
  90. data/spec/integration/world_integration_spec.rb +13 -0
  91. data/spec/spec_helper.rb +30 -0
  92. data/spec/unit/background_unit_spec.rb +55 -0
  93. data/spec/unit/bare_bones_unit_specs.rb +13 -0
  94. data/spec/unit/containing_element_unit_specs.rb +17 -0
  95. data/spec/unit/directory_unit_spec.rb +103 -0
  96. data/spec/unit/doc_string_unit_spec.rb +109 -0
  97. data/spec/unit/example_unit_spec.rb +251 -0
  98. data/spec/unit/feature_element_unit_spec.rb +19 -0
  99. data/spec/unit/feature_element_unit_specs.rb +46 -0
  100. data/spec/unit/feature_file_unit_spec.rb +94 -0
  101. data/spec/unit/feature_unit_spec.rb +135 -0
  102. data/spec/unit/nested_element_unit_specs.rb +36 -0
  103. data/spec/unit/nested_unit_spec.rb +37 -0
  104. data/spec/unit/outline_unit_spec.rb +91 -0
  105. data/spec/unit/parsing_unit_spec.rb +21 -0
  106. data/spec/unit/prepopulated_unit_specs.rb +13 -0
  107. data/spec/unit/raw_element_unit_specs.rb +24 -0
  108. data/spec/unit/raw_unit_spec.rb +25 -0
  109. data/spec/unit/row_unit_spec.rb +55 -0
  110. data/spec/unit/scenario_unit_spec.rb +71 -0
  111. data/spec/unit/sourceable_unit_spec.rb +17 -0
  112. data/spec/unit/sourced_element_unit_specs.rb +18 -0
  113. data/spec/unit/step_unit_spec.rb +259 -0
  114. data/spec/unit/table_row_unit_spec.rb +55 -0
  115. data/spec/unit/table_unit_spec.rb +96 -0
  116. data/spec/unit/tag_unit_spec.rb +51 -0
  117. data/spec/unit/taggable_unit_spec.rb +78 -0
  118. data/spec/unit/tagged_element_unit_specs.rb +63 -0
  119. data/spec/unit/test_element_unit_spec.rb +40 -0
  120. data/spec/unit/test_element_unit_specs.rb +31 -0
  121. data/spec/unit/world_unit_spec.rb +130 -0
  122. metadata +364 -0
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Outline') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Outline, Integration' do
6
+
7
+ it 'properly sets its child elements' do
8
+ source = ['@a_tag',
9
+ ' Scenario Outline:',
10
+ ' * a step',
11
+ ' Examples:',
12
+ ' | param |']
13
+ source = source.join("\n")
14
+
15
+ outline = CukeModeler::Outline.new(source)
16
+ example = outline.examples.first
17
+ step = outline.steps.first
18
+ tag = outline.tag_elements.first
19
+
20
+ example.parent_element.should equal outline
21
+ step.parent_element.should equal outline
22
+ tag.parent_element.should equal outline
23
+ end
24
+
25
+
26
+ context 'getting stuff' do
27
+
28
+ before(:each) do
29
+ source = ['Feature: Test feature',
30
+ '',
31
+ ' Scenario Outline: Test test',
32
+ ' * a step',
33
+ ' Examples: Test example',
34
+ ' | a param |']
35
+ source = source.join("\n")
36
+
37
+ file_path = "#{@default_file_directory}/outline_test_file.feature"
38
+ File.open(file_path, 'w') { |file| file.write(source) }
39
+
40
+ @directory = CukeModeler::Directory.new(@default_file_directory)
41
+ @outline = @directory.feature_files.first.features.first.tests.first
42
+ end
43
+
44
+
45
+ it 'can get its directory' do
46
+ directory = @outline.get_ancestor(:directory)
47
+
48
+ directory.should equal @directory
49
+ end
50
+
51
+ it 'can get its feature file' do
52
+ feature_file = @outline.get_ancestor(:feature_file)
53
+
54
+ feature_file.should equal @directory.feature_files.first
55
+ end
56
+
57
+ it 'can get its feature' do
58
+ feature = @outline.get_ancestor(:feature)
59
+
60
+ feature.should equal @directory.feature_files.first.features.first
61
+ end
62
+
63
+ it 'returns nil if it does not have the requested type of ancestor' do
64
+ test = @outline.get_ancestor(:test)
65
+
66
+ test.should be_nil
67
+ end
68
+
69
+ context 'outline output edge cases' do
70
+
71
+ it 'can output an outline that has only a tag elements' do
72
+ @outline.tag_elements = [CukeModeler::Tag.new]
73
+
74
+ expect { @outline.to_s }.to_not raise_error
75
+ end
76
+
77
+ it 'can output an outline that has only steps' do
78
+ @outline.steps = [CukeModeler::Step.new]
79
+
80
+ expect { @outline.to_s }.to_not raise_error
81
+ end
82
+
83
+ it 'can output an outline that has only examples' do
84
+ @outline.examples = [CukeModeler::Example.new]
85
+
86
+ expect { @outline.to_s }.to_not raise_error
87
+ end
88
+
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Scenario') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Scenario, Integration' do
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
20
+
21
+
22
+ context 'getting stuff' do
23
+
24
+ before(:each) do
25
+ source = ['Feature: Test feature',
26
+ '',
27
+ ' Scenario: Test test',
28
+ ' * a step']
29
+ source = source.join("\n")
30
+
31
+ file_path = "#{@default_file_directory}/scenario_test_file.feature"
32
+ File.open(file_path, 'w') { |file| file.write(source) }
33
+
34
+ @directory = CukeModeler::Directory.new(@default_file_directory)
35
+ @scenario = @directory.feature_files.first.features.first.tests.first
36
+ end
37
+
38
+
39
+ it 'can get its directory' do
40
+ directory = @scenario.get_ancestor(:directory)
41
+
42
+ directory.should equal @directory
43
+ end
44
+
45
+ it 'can get its feature file' do
46
+ feature_file = @scenario.get_ancestor(:feature_file)
47
+
48
+ feature_file.should equal @directory.feature_files.first
49
+ end
50
+
51
+ it 'can get its feature' do
52
+ feature = @scenario.get_ancestor(:feature)
53
+
54
+ feature.should equal @directory.feature_files.first.features.first
55
+ end
56
+
57
+ it 'returns nil if it does not have the requested type of ancestor' do
58
+ test = @scenario.get_ancestor(:test)
59
+
60
+ test.should be_nil
61
+ end
62
+
63
+ context 'scenario output edge cases' do
64
+
65
+ it 'can output a scenario that has only a tag elements' do
66
+ @scenario.tag_elements = [CukeModeler::Tag.new]
67
+
68
+ expect { @scenario.to_s }.to_not raise_error
69
+ end
70
+
71
+ it 'can output a scenario that has only steps' do
72
+ @scenario.steps = [CukeModeler::Step.new]
73
+
74
+ expect { @scenario.to_s }.to_not raise_error
75
+ end
76
+
77
+ end
78
+
79
+ end
80
+ end
@@ -0,0 +1,184 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Step') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Step, Integration' do
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|']
14
+
15
+ step_1 = CukeModeler::Step.new(source_1.join("\n"))
16
+ step_2 = CukeModeler::Step.new(source_2.join("\n"))
17
+
18
+
19
+ doc_string = step_1.block
20
+ table = step_2.block
21
+
22
+ doc_string.parent_element.should equal step_1
23
+ table.parent_element.should equal step_2
24
+ end
25
+
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
+
31
+ step = CukeModeler::Step.new
32
+ step.right_delimiter = nil
33
+ step.left_delimiter = nil
34
+
35
+ step.right_delimiter.should == '"'
36
+ step.left_delimiter.should == '"'
37
+ end
38
+
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*'
41
+
42
+ world = CukeModeler::World
43
+ world.left_delimiter = '"'
44
+ world.right_delimiter = '"'
45
+
46
+ step = CukeModeler::Step.new(source)
47
+
48
+ step.arguments.should == ['parameter 2']
49
+ end
50
+
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
55
+
56
+ source = 'Given a test step with *parameter 1* and "parameter 2" and *parameter 3*'
57
+ step = CukeModeler::Step.new(source)
58
+
59
+ step.scan_arguments
60
+
61
+ step.arguments.should == []
62
+ end
63
+
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'
68
+
69
+ step_1 = CukeModeler::Step.new(source_1)
70
+ step_2 = CukeModeler::Step.new(source_2)
71
+ step_3 = CukeModeler::Step.new(source_3)
72
+
73
+ step_1.delimiter = '*'
74
+ step_2.delimiter = '*'
75
+ step_3.delimiter = '*'
76
+
77
+
78
+ (step_1 == step_2).should be_true
79
+ (step_1 == step_3).should be_false
80
+ end
81
+
82
+ context '#step_text ' do
83
+
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)
87
+ end
88
+
89
+
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)
93
+
94
+ expected_output = ['Given a test step with -parameter 1- ^and@ *parameter 2!!',
95
+ '|a block|']
96
+
97
+ step_with_block.step_text.should == expected_output
98
+
99
+ source = 'Given a test step with -parameter 1- ^and@ *parameter 2!!'
100
+ step_without_block = CukeModeler::Step.new(source)
101
+
102
+ expected_output = ['Given a test step with -parameter 1- ^and@ *parameter 2!!']
103
+
104
+ step_without_block.step_text.should == expected_output
105
+ end
106
+
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|']
110
+
111
+ @step.step_text(:with_keywords => false).should == expected_output
112
+ end
113
+
114
+ end
115
+
116
+ context 'getting stuff' do
117
+
118
+ before(:each) do
119
+ source = ['Feature: Test feature',
120
+ '',
121
+ ' Scenario: Test test',
122
+ ' * a step:']
123
+ source = source.join("\n")
124
+
125
+ file_path = "#{@default_file_directory}/step_test_file.feature"
126
+ File.open(file_path, 'w') { |file| file.write(source) }
127
+
128
+ @directory = CukeModeler::Directory.new(@default_file_directory)
129
+ @step = @directory.feature_files.first.features.first.tests.first.steps.first
130
+ end
131
+
132
+
133
+ it 'can get its directory' do
134
+ directory = @step.get_ancestor(:directory)
135
+
136
+ directory.should equal @directory
137
+ end
138
+
139
+ it 'can get its feature file' do
140
+ feature_file = @step.get_ancestor(:feature_file)
141
+
142
+ feature_file.should equal @directory.feature_files.first
143
+ end
144
+
145
+ it 'can get its feature' do
146
+ feature = @step.get_ancestor(:feature)
147
+
148
+ feature.should equal @directory.feature_files.first.features.first
149
+ end
150
+
151
+ it 'can get its test' do
152
+ test = @step.get_ancestor(:test)
153
+
154
+ test.should equal @directory.feature_files.first.features.first.tests.first
155
+ end
156
+
157
+ it 'returns nil if it does not have the requested type of ancestor' do
158
+ example = @step.get_ancestor(:example)
159
+
160
+ example.should be_nil
161
+ end
162
+
163
+ end
164
+
165
+ context 'step output edge cases' do
166
+
167
+ before(:each) do
168
+ @step = CukeModeler::Step.new
169
+ end
170
+
171
+ it 'can output a step that has only a table' do
172
+ @step.block = CukeModeler::Table.new
173
+
174
+ expect { @step.to_s }.to_not raise_error
175
+ end
176
+
177
+ it 'can output a step that has only a doc string' do
178
+ @step.block = CukeModeler::DocString.new
179
+
180
+ expect { @step.to_s }.to_not raise_error
181
+ end
182
+
183
+ end
184
+ end
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Table') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Table, Integration' do
6
+
7
+ it 'properly sets its child elements' do
8
+ source = ['| cell 1 |',
9
+ '| cell 2 |']
10
+ source = source.join("\n")
11
+
12
+ table = CukeModeler::Table.new(source)
13
+ row_1 = table.row_elements[0]
14
+ row_2 = table.row_elements[1]
15
+
16
+ row_1.parent_element.should equal table
17
+ row_2.parent_element.should equal table
18
+ end
19
+
20
+ context 'getting stuff' do
21
+
22
+ before(:each) do
23
+ source = ['Feature: Test feature',
24
+ '',
25
+ ' Scenario: Test test',
26
+ ' * a step:',
27
+ ' | a | table |']
28
+ source = source.join("\n")
29
+
30
+ file_path = "#{@default_file_directory}/table_row_test_file.feature"
31
+ File.open(file_path, 'w') { |file| file.write(source) }
32
+
33
+ @directory = CukeModeler::Directory.new(@default_file_directory)
34
+ @table = @directory.feature_files.first.features.first.tests.first.steps.first.block
35
+ end
36
+
37
+
38
+ it 'can get its directory' do
39
+ directory = @table.get_ancestor(:directory)
40
+
41
+ directory.should equal @directory
42
+ end
43
+
44
+ it 'can get its feature file' do
45
+ feature_file = @table.get_ancestor(:feature_file)
46
+
47
+ feature_file.should equal @directory.feature_files.first
48
+ end
49
+
50
+ it 'can get its feature' do
51
+ feature = @table.get_ancestor(:feature)
52
+
53
+ feature.should equal @directory.feature_files.first.features.first
54
+ end
55
+
56
+ it 'can get its test' do
57
+ test = @table.get_ancestor(:test)
58
+
59
+ test.should equal @directory.feature_files.first.features.first.tests.first
60
+ end
61
+
62
+ it 'can get its step' do
63
+ step = @table.get_ancestor(:step)
64
+
65
+ step.should equal @directory.feature_files.first.features.first.tests.first.steps.first
66
+ end
67
+
68
+ it 'returns nil if it does not have the requested type of ancestor' do
69
+ example = @table.get_ancestor(:example)
70
+
71
+ example.should be_nil
72
+ end
73
+
74
+ end
75
+
76
+ context 'table output edge cases' do
77
+ # todo - remove once #contents is no longer supported
78
+ it 'can output a table that only has row elements' do
79
+ table = CukeModeler::Table.new
80
+ table.row_elements = [CukeModeler::TableRow.new]
81
+
82
+ expect { table.to_s }.to_not raise_error
83
+ end
84
+
85
+ end
86
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('TableRow') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'TableRow, Integration' do
6
+
7
+ context 'getting stuff' do
8
+
9
+ before(:each) do
10
+ source = ['Feature: Test feature',
11
+ '',
12
+ ' Scenario: Test test',
13
+ ' * a step:',
14
+ ' | a | table |']
15
+ source = source.join("\n")
16
+
17
+ file_path = "#{@default_file_directory}/table_row_test_file.feature"
18
+ File.open(file_path, 'w') { |file| file.write(source) }
19
+
20
+ @directory = CukeModeler::Directory.new(@default_file_directory)
21
+ @table_row = @directory.feature_files.first.features.first.tests.first.steps.first.block.row_elements.first
22
+ end
23
+
24
+
25
+ it 'can get its directory' do
26
+ directory = @table_row.get_ancestor(:directory)
27
+
28
+ directory.should equal @directory
29
+ end
30
+
31
+ it 'can get its feature file' do
32
+ feature_file = @table_row.get_ancestor(:feature_file)
33
+
34
+ feature_file.should equal @directory.feature_files.first
35
+ end
36
+
37
+ it 'can get its feature' do
38
+ feature = @table_row.get_ancestor(:feature)
39
+
40
+ feature.should equal @directory.feature_files.first.features.first
41
+ end
42
+
43
+ it 'can get its test' do
44
+ test = @table_row.get_ancestor(:test)
45
+
46
+ test.should equal @directory.feature_files.first.features.first.tests.first
47
+ end
48
+
49
+ it 'can get its step' do
50
+ step = @table_row.get_ancestor(:step)
51
+
52
+ step.should equal @directory.feature_files.first.features.first.tests.first.steps.first
53
+ end
54
+
55
+ it 'can get its table' do
56
+ table = @table_row.get_ancestor(:table)
57
+
58
+ table.should equal @directory.feature_files.first.features.first.tests.first.steps.first.block
59
+ end
60
+
61
+ it 'returns nil if it does not have the requested type of ancestor' do
62
+ example = @table_row.get_ancestor(:example)
63
+
64
+ example.should be_nil
65
+ end
66
+
67
+ end
68
+ end