cuke_modeler 0.0.1

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.
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,72 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Background') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Background, Integration' do
6
+
7
+ it 'properly sets its child elements' do
8
+ source = [' Background: Test background',
9
+ ' * a step']
10
+ source = source.join("\n")
11
+
12
+ background = CukeModeler::Background.new(source)
13
+ step = background.steps.first
14
+
15
+ step.parent_element.should equal background
16
+ end
17
+
18
+ context 'getting stuff' do
19
+
20
+ before(:each) do
21
+ source = ['Feature: Test feature',
22
+ '',
23
+ ' Background: Test background',
24
+ ' * a step:']
25
+ source = source.join("\n")
26
+
27
+ file_path = "#{@default_file_directory}/background_test_file.feature"
28
+ File.open(file_path, 'w') { |file| file.write(source) }
29
+
30
+ @directory = CukeModeler::Directory.new(@default_file_directory)
31
+ @background = @directory.feature_files.first.features.first.background
32
+ end
33
+
34
+
35
+ it 'can get its directory' do
36
+ directory = @background.get_ancestor(:directory)
37
+
38
+ directory.should equal @directory
39
+ end
40
+
41
+ it 'can get its feature file' do
42
+ feature_file = @background.get_ancestor(:feature_file)
43
+
44
+ feature_file.should equal @directory.feature_files.first
45
+ end
46
+
47
+ it 'can get its feature' do
48
+ feature = @background.get_ancestor(:feature)
49
+
50
+ feature.should equal @directory.feature_files.first.features.first
51
+ end
52
+
53
+ it 'returns nil if it does not have the requested type of ancestor' do
54
+ example = @background.get_ancestor(:example)
55
+
56
+ example.should be_nil
57
+ end
58
+
59
+ end
60
+
61
+ context 'background output edge cases' do
62
+
63
+ it 'can output a background that has only steps' do
64
+ background = CukeModeler::Background.new
65
+ background.steps = [CukeModeler::Step.new]
66
+
67
+ expect { background.to_s }.to_not raise_error
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Directory') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Directory, Integration' do
6
+
7
+ it 'properly sets its child elements' do
8
+ nested_directory = "#{@default_file_directory}/nested_directory"
9
+ file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
10
+
11
+ FileUtils.mkdir(nested_directory)
12
+ File.open(file_path, "w") { |file|
13
+ file.puts('Feature: Test feature')
14
+ }
15
+
16
+ directory = CukeModeler::Directory.new(@default_file_directory)
17
+ nested_directory = directory.directories.first
18
+ file = directory.feature_files.first
19
+
20
+ nested_directory.parent_element.should equal directory
21
+ file.parent_element.should equal directory
22
+ end
23
+
24
+ context 'getting stuff' do
25
+
26
+ before(:each) do
27
+ nested_directory = "#{@default_file_directory}/nested_directory"
28
+ FileUtils.mkdir(nested_directory)
29
+
30
+ @directory = CukeModeler::Directory.new(@default_file_directory)
31
+ @nested_directory = @directory.directories.first
32
+ end
33
+
34
+
35
+ it 'can get its directory' do
36
+ directory = @nested_directory.get_ancestor(:directory)
37
+
38
+ directory.should equal @directory
39
+ end
40
+
41
+ it 'returns nil if it does not have the requested type of ancestor' do
42
+ example = @nested_directory.get_ancestor(:example)
43
+
44
+ example.should be_nil
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('DocString') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'DocString, 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 big step:',
14
+ ' """',
15
+ ' a',
16
+ ' doc',
17
+ ' string',
18
+ ' """']
19
+ source = source.join("\n")
20
+
21
+ file_path = "#{@default_file_directory}/doc_string_test_file.feature"
22
+ File.open(file_path, 'w') { |file| file.write(source) }
23
+
24
+ @directory = CukeModeler::Directory.new(@default_file_directory)
25
+ @doc_string = @directory.feature_files.first.features.first.tests.first.steps.first.block
26
+ end
27
+
28
+
29
+ it 'can get its directory' do
30
+ directory = @doc_string.get_ancestor(:directory)
31
+
32
+ directory.should equal @directory
33
+ end
34
+
35
+ it 'can get its feature file' do
36
+ feature_file = @doc_string.get_ancestor(:feature_file)
37
+
38
+ feature_file.should equal @directory.feature_files.first
39
+ end
40
+
41
+ it 'can get its feature' do
42
+ feature = @doc_string.get_ancestor(:feature)
43
+
44
+ feature.should equal @directory.feature_files.first.features.first
45
+ end
46
+
47
+ it 'can get its test' do
48
+ test = @doc_string.get_ancestor(:test)
49
+
50
+ test.should equal @directory.feature_files.first.features.first.tests.first
51
+ end
52
+
53
+ it 'can get its step' do
54
+ step = @doc_string.get_ancestor(:step)
55
+
56
+ step.should equal @directory.feature_files.first.features.first.tests.first.steps.first
57
+ end
58
+
59
+ it 'returns nil if it does not have the requested type of ancestor' do
60
+ example = @doc_string.get_ancestor(:example)
61
+
62
+ example.should be_nil
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Example') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Example, Integration' do
6
+
7
+ it 'properly sets its child elements' do
8
+ source = ['@a_tag',
9
+ 'Examples:',
10
+ ' | param |',
11
+ ' | value 1 |']
12
+ source = source.join("\n")
13
+
14
+ example = CukeModeler::Example.new(source)
15
+ rows = example.row_elements
16
+ tag = example.tag_elements.first
17
+
18
+ rows[0].parent_element.should equal example
19
+ rows[1].parent_element.should equal example
20
+ tag.parent_element.should equal example
21
+ end
22
+
23
+ context 'getting stuff' do
24
+
25
+ before(:each) do
26
+ source = ['Feature: Test feature',
27
+ '',
28
+ ' Scenario Outline: Test test',
29
+ ' * a step',
30
+ ' Examples: Test example',
31
+ ' | a param |']
32
+ source = source.join("\n")
33
+
34
+ file_path = "#{@default_file_directory}/example_test_file.feature"
35
+ File.open(file_path, 'w') { |file| file.write(source) }
36
+
37
+ @directory = CukeModeler::Directory.new(@default_file_directory)
38
+ @example = @directory.feature_files.first.features.first.tests.first.examples.first
39
+ end
40
+
41
+
42
+ it 'can get its directory' do
43
+ directory = @example.get_ancestor(:directory)
44
+
45
+ directory.should equal @directory
46
+ end
47
+
48
+ it 'can get its feature file' do
49
+ feature_file = @example.get_ancestor(:feature_file)
50
+
51
+ feature_file.should equal @directory.feature_files.first
52
+ end
53
+
54
+ it 'can get its feature' do
55
+ feature = @example.get_ancestor(:feature)
56
+
57
+ feature.should equal @directory.feature_files.first.features.first
58
+ end
59
+
60
+ it 'can get its test' do
61
+ test = @example.get_ancestor(:test)
62
+
63
+ test.should equal @directory.feature_files.first.features.first.tests.first
64
+ end
65
+
66
+ it 'returns nil if it does not have the requested type of ancestor' do
67
+ example = @example.get_ancestor(:example)
68
+
69
+ example.should be_nil
70
+ end
71
+
72
+ end
73
+
74
+ context 'example output edge cases' do
75
+
76
+ before(:each) do
77
+ @example = CukeModeler::Example.new
78
+ end
79
+
80
+ it 'can output an example that has only a tag elements' do
81
+ @example.tag_elements = [CukeModeler::Tag.new]
82
+
83
+ expect { @example.to_s }.to_not raise_error
84
+ end
85
+
86
+ #todo - remove once Hash rows are no longer supported
87
+ it 'can output an example that has only row elements' do
88
+ @example.row_elements = [CukeModeler::Row.new]
89
+
90
+ expect { @example.to_s }.to_not raise_error
91
+ end
92
+
93
+ end
94
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('FeatureFile') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'FeatureFile, Integration' do
6
+
7
+ it 'properly sets its child elements' do
8
+ file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
9
+
10
+ File.open(file_path, "w") { |file|
11
+ file.puts('Feature: Test feature')
12
+ }
13
+
14
+ file = CukeModeler::FeatureFile.new(file_path)
15
+ feature = file.feature
16
+
17
+ feature.parent_element.should equal file
18
+ end
19
+
20
+ context 'getting stuff' do
21
+
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') }
25
+
26
+ @directory = CukeModeler::Directory.new(@default_file_directory)
27
+ @feature_file = @directory.feature_files.first
28
+ end
29
+
30
+
31
+ it 'can get its directory' do
32
+ directory = @feature_file.get_ancestor(:directory)
33
+
34
+ directory.should equal @directory
35
+ end
36
+
37
+ it 'returns nil if it does not have the requested type of ancestor' do
38
+ example = @feature_file.get_ancestor(:example)
39
+
40
+ example.should be_nil
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,152 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Feature') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Feature, Integration' do
6
+
7
+ clazz = CukeModeler::Feature
8
+
9
+ before(:each) do
10
+ @feature = clazz.new
11
+ end
12
+
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
+ source = source.join("\n")
20
+
21
+
22
+ feature = CukeModeler::Feature.new(source)
23
+ background = feature.background
24
+ scenario = feature.tests[0]
25
+ outline = feature.tests[1]
26
+ tag = feature.tag_elements[0]
27
+
28
+
29
+ outline.parent_element.should equal feature
30
+ scenario.parent_element.should equal feature
31
+ background.parent_element.should equal feature
32
+ tag.parent_element.should equal feature
33
+ end
34
+
35
+ it 'can distinguish scenarios from outlines - #scenarios, #outlines' do
36
+ scenarios = [CukeModeler::Scenario.new('Scenario: 1'), CukeModeler::Scenario.new('Scenario: 2')]
37
+ outlines = [CukeModeler::Outline.new('Scenario Outline: 1'), CukeModeler::Outline.new('Scenario Outline: 2')]
38
+
39
+ @feature.tests = scenarios + outlines
40
+
41
+ @feature.scenarios.should =~ scenarios
42
+ @feature.outlines.should =~ outlines
43
+ end
44
+
45
+ it 'knows how many scenarios it has - #scenario_count' do
46
+ scenarios = [CukeModeler::Scenario.new('Scenario: 1'), CukeModeler::Scenario.new('Scenario: 2')]
47
+ outlines = [CukeModeler::Outline.new('Scenario Outline: 1')]
48
+
49
+ @feature.tests = []
50
+ @feature.scenario_count.should == 0
51
+
52
+ @feature.tests = scenarios + outlines
53
+ @feature.scenario_count.should == 2
54
+ end
55
+
56
+ it 'knows how many outlines it has - #outline_count' do
57
+ scenarios = [CukeModeler::Scenario.new('Scenario: 1')]
58
+ outlines = [CukeModeler::Outline.new('Scenario Outline: 1'), CukeModeler::Outline.new('Scenario Outline: 2')]
59
+
60
+ @feature.tests = []
61
+ @feature.outline_count.should == 0
62
+
63
+ @feature.tests = scenarios + outlines
64
+ @feature.outline_count.should == 2
65
+ end
66
+
67
+ it 'knows how many test cases it has - #test_case_count' do
68
+ source_1 = ['Feature: Test feature']
69
+ source_1 = source_1.join("\n")
70
+
71
+ source_2 = ['Feature: Test feature',
72
+ ' Scenario: Test scenario',
73
+ ' Scenario Outline: Test outline',
74
+ ' * a step',
75
+ ' Examples: Test examples',
76
+ ' |param|',
77
+ ' |value_1|',
78
+ ' |value_2|']
79
+ source_2 = source_2.join("\n")
80
+
81
+ feature_1 = CukeModeler::Feature.new(source_1)
82
+ feature_2 = CukeModeler::Feature.new(source_2)
83
+
84
+
85
+ feature_1.test_case_count.should == 0
86
+ feature_2.test_case_count.should == 3
87
+ end
88
+
89
+
90
+ context 'getting stuff' do
91
+
92
+ before(:each) do
93
+ source = ['Feature: Test feature']
94
+ source = source.join("\n")
95
+
96
+ file_path = "#{@default_file_directory}/feature_test_file.feature"
97
+ File.open(file_path, 'w') { |file| file.write(source) }
98
+
99
+ @directory = CukeModeler::Directory.new(@default_file_directory)
100
+ @feature = @directory.feature_files.first.features.first
101
+ end
102
+
103
+
104
+ it 'can get its directory' do
105
+ directory = @feature.get_ancestor(:directory)
106
+
107
+ directory.should equal @directory
108
+ end
109
+
110
+ it 'can get its feature file' do
111
+ feature_file = @feature.get_ancestor(:feature_file)
112
+
113
+ feature_file.should equal @directory.feature_files.first
114
+ end
115
+
116
+ it 'returns nil if it does not have the requested type of ancestor' do
117
+ test = @feature.get_ancestor(:test)
118
+
119
+ test.should be_nil
120
+ end
121
+
122
+ end
123
+
124
+ context 'feature output edge cases' do
125
+
126
+ it 'can output a feature that has only a tag elements' do
127
+ @feature.tag_elements = [CukeModeler::Tag.new]
128
+
129
+ expect { @feature.to_s }.to_not raise_error
130
+ end
131
+
132
+ it 'can output a feature that has only a background' do
133
+ @feature.background = [CukeModeler::Background.new]
134
+
135
+ expect { @feature.to_s }.to_not raise_error
136
+ end
137
+
138
+ it 'can output a feature that has only scenarios' do
139
+ @feature.tests = [CukeModeler::Scenario.new]
140
+
141
+ expect { @feature.to_s }.to_not raise_error
142
+ end
143
+
144
+ it 'can output a feature that has only outlines' do
145
+ @feature.tests = [CukeModeler::Outline.new]
146
+
147
+ expect { @feature.to_s }.to_not raise_error
148
+ end
149
+
150
+ end
151
+
152
+ end