cuke_modeler 2.1.0 → 3.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.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +53 -1
  3. data/README.md +14 -16
  4. data/cuke_modeler.gemspec +33 -21
  5. data/lib/cuke_modeler.rb +2 -1
  6. data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +13 -0
  7. data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +13 -0
  8. data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +13 -0
  9. data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +13 -0
  10. data/lib/cuke_modeler/adapters/gherkin_14_adapter.rb +13 -0
  11. data/lib/cuke_modeler/adapters/gherkin_15_adapter.rb +13 -0
  12. data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +356 -4
  13. data/lib/cuke_modeler/containing.rb +41 -89
  14. data/lib/cuke_modeler/described.rb +40 -1
  15. data/lib/cuke_modeler/models/background.rb +12 -12
  16. data/lib/cuke_modeler/models/cell.rb +14 -8
  17. data/lib/cuke_modeler/models/comment.rb +6 -6
  18. data/lib/cuke_modeler/models/directory.rb +14 -18
  19. data/lib/cuke_modeler/models/doc_string.rb +11 -8
  20. data/lib/cuke_modeler/models/example.rb +64 -46
  21. data/lib/cuke_modeler/models/feature.rb +38 -20
  22. data/lib/cuke_modeler/models/feature_file.rb +6 -8
  23. data/lib/cuke_modeler/models/model.rb +2 -1
  24. data/lib/cuke_modeler/models/outline.rb +20 -15
  25. data/lib/cuke_modeler/models/row.rb +11 -8
  26. data/lib/cuke_modeler/models/rule.rb +101 -0
  27. data/lib/cuke_modeler/models/scenario.rb +18 -13
  28. data/lib/cuke_modeler/models/step.rb +41 -19
  29. data/lib/cuke_modeler/models/table.rb +10 -7
  30. data/lib/cuke_modeler/models/tag.rb +10 -6
  31. data/lib/cuke_modeler/named.rb +5 -1
  32. data/lib/cuke_modeler/nested.rb +22 -18
  33. data/lib/cuke_modeler/parsed.rb +8 -0
  34. data/lib/cuke_modeler/parsing.rb +55 -74
  35. data/lib/cuke_modeler/sourceable.rb +8 -0
  36. data/lib/cuke_modeler/stepped.rb +8 -0
  37. data/lib/cuke_modeler/taggable.rb +9 -1
  38. data/lib/cuke_modeler/version.rb +1 -1
  39. data/testing/cucumber/features/modeling/feature_modeling.feature +28 -7
  40. data/testing/cucumber/features/modeling/feature_output.feature +45 -23
  41. data/testing/cucumber/features/modeling/rule_modeling.feature +108 -0
  42. data/testing/cucumber/features/modeling/rule_output.feature +111 -0
  43. metadata +68 -161
  44. data/.gitignore +0 -18
  45. data/.simplecov +0 -7
  46. data/.travis.yml +0 -81
  47. data/Gemfile +0 -44
  48. data/Rakefile +0 -73
  49. data/appveyor.yml +0 -88
  50. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -274
  51. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -297
  52. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -309
  53. data/lib/cuke_modeler/adapters/gherkin_5_adapter.rb +0 -12
  54. data/lib/cuke_modeler/adapters/gherkin_6_adapter.rb +0 -310
  55. data/lib/cuke_modeler/adapters/gherkin_7_adapter.rb +0 -307
  56. data/lib/cuke_modeler/adapters/gherkin_8_adapter.rb +0 -12
  57. data/testing/cucumber/step_definitions/action_steps.rb +0 -13
  58. data/testing/cucumber/step_definitions/background_steps.rb +0 -1
  59. data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
  60. data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
  61. data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
  62. data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
  63. data/testing/cucumber/step_definitions/modeling_steps.rb +0 -49
  64. data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
  65. data/testing/cucumber/step_definitions/step_steps.rb +0 -3
  66. data/testing/cucumber/step_definitions/table_steps.rb +0 -1
  67. data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
  68. data/testing/cucumber/step_definitions/verification_steps.rb +0 -181
  69. data/testing/cucumber/support/env.rb +0 -30
  70. data/testing/dialect_helper.rb +0 -48
  71. data/testing/file_helper.rb +0 -47
  72. data/testing/gemfiles/gherkin2.gemfile +0 -33
  73. data/testing/gemfiles/gherkin3.gemfile +0 -26
  74. data/testing/gemfiles/gherkin4.gemfile +0 -27
  75. data/testing/gemfiles/gherkin5.gemfile +0 -27
  76. data/testing/gemfiles/gherkin6.gemfile +0 -10
  77. data/testing/gemfiles/gherkin7.gemfile +0 -9
  78. data/testing/gemfiles/gherkin8.gemfile +0 -9
  79. data/testing/gemfiles/gherkin9.gemfile +0 -9
  80. data/testing/helper_methods.rb +0 -23
  81. data/testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb +0 -166
  82. data/testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb +0 -166
  83. data/testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb +0 -165
  84. data/testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb +0 -165
  85. data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +0 -159
  86. data/testing/rspec/spec/integration/adapters/gherkin_7_adapter_spec.rb +0 -162
  87. data/testing/rspec/spec/integration/adapters/gherkin_8_adapter_spec.rb +0 -162
  88. data/testing/rspec/spec/integration/adapters/gherkin_9_adapter_spec.rb +0 -162
  89. data/testing/rspec/spec/integration/models/background_integration_spec.rb +0 -438
  90. data/testing/rspec/spec/integration/models/cell_integration_spec.rb +0 -338
  91. data/testing/rspec/spec/integration/models/comment_integration_spec.rb +0 -180
  92. data/testing/rspec/spec/integration/models/directory_integration_spec.rb +0 -218
  93. data/testing/rspec/spec/integration/models/doc_string_integration_spec.rb +0 -398
  94. data/testing/rspec/spec/integration/models/example_integration_spec.rb +0 -753
  95. data/testing/rspec/spec/integration/models/feature_file_integration_spec.rb +0 -276
  96. data/testing/rspec/spec/integration/models/feature_integration_spec.rb +0 -655
  97. data/testing/rspec/spec/integration/models/model_integration_spec.rb +0 -15
  98. data/testing/rspec/spec/integration/models/outline_integration_spec.rb +0 -619
  99. data/testing/rspec/spec/integration/models/row_integration_spec.rb +0 -303
  100. data/testing/rspec/spec/integration/models/scenario_integration_spec.rb +0 -475
  101. data/testing/rspec/spec/integration/models/step_integration_spec.rb +0 -573
  102. data/testing/rspec/spec/integration/models/table_integration_spec.rb +0 -333
  103. data/testing/rspec/spec/integration/models/tag_integration_spec.rb +0 -271
  104. data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
  105. data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -143
  106. data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
  107. data/testing/rspec/spec/spec_helper.rb +0 -129
  108. data/testing/rspec/spec/unit/cuke_modeler_unit_spec.rb +0 -25
  109. data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
  110. data/testing/rspec/spec/unit/models/background_unit_spec.rb +0 -83
  111. data/testing/rspec/spec/unit/models/cell_unit_spec.rb +0 -68
  112. data/testing/rspec/spec/unit/models/comment_unit_spec.rb +0 -68
  113. data/testing/rspec/spec/unit/models/directory_unit_spec.rb +0 -127
  114. data/testing/rspec/spec/unit/models/doc_string_unit_spec.rb +0 -100
  115. data/testing/rspec/spec/unit/models/example_unit_spec.rb +0 -133
  116. data/testing/rspec/spec/unit/models/feature_file_unit_spec.rb +0 -125
  117. data/testing/rspec/spec/unit/models/feature_unit_spec.rb +0 -157
  118. data/testing/rspec/spec/unit/models/model_unit_spec.rb +0 -15
  119. data/testing/rspec/spec/unit/models/outline_unit_spec.rb +0 -117
  120. data/testing/rspec/spec/unit/models/row_unit_spec.rb +0 -68
  121. data/testing/rspec/spec/unit/models/scenario_unit_spec.rb +0 -86
  122. data/testing/rspec/spec/unit/models/step_unit_spec.rb +0 -109
  123. data/testing/rspec/spec/unit/models/table_unit_spec.rb +0 -77
  124. data/testing/rspec/spec/unit/models/tag_unit_spec.rb +0 -68
  125. data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
  126. data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
  127. data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
  128. data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
  129. data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
  130. data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -127
  131. data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
  132. data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
  133. data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
  134. data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
  135. data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
  136. data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
  137. data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
  138. data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
  139. data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
  140. data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
  141. data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
  142. data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
  143. data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
  144. data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
  145. data/testing/test_languages.json +0 -45
  146. data/todo.txt +0 -25
@@ -1,12 +0,0 @@
1
- require_relative 'gherkin_7_adapter'
2
-
3
- module CukeModeler
4
-
5
- # NOT A PART OF THE PUBLIC API
6
- # An adapter that can convert the output of version 8.x of the *gherkin* gem into input that is consumable by this gem.
7
-
8
- class Gherkin8Adapter < Gherkin7Adapter
9
-
10
- end
11
-
12
- end
@@ -1,13 +0,0 @@
1
- When(/^it is outputted$/) do
2
- @output = @model.to_s
3
- end
4
-
5
- When(/^the models are compared$/) do
6
- @results = []
7
-
8
- (@models.count - 1).times do |index|
9
- @results << (@models[index] == @models[index + 1])
10
- end
11
-
12
- @results << (@models.first == @models.last)
13
- end
@@ -1 +0,0 @@
1
- # No steps specific to this type of model
@@ -1,6 +0,0 @@
1
- Given(/^a directory model based on "([^"]*)"$/) do |directory_name|
2
- directory_path = "#{@root_test_directory}/#{directory_name}"
3
- FileUtils.mkdir(directory_path) unless File.exists?(directory_path)
4
-
5
- @model = CukeModeler::Directory.new(directory_path)
6
- end
@@ -1 +0,0 @@
1
- # No steps specific to this type of model
@@ -1,16 +0,0 @@
1
- Given(/^a feature file model based on "([^"]*)"$/) do |file_name|
2
- file_path = "#{@root_test_directory}/#{file_name}"
3
- File.open(file_path, 'w') { |file| file.puts "Feature:" } unless File.exists?(file_path)
4
-
5
- @model = CukeModeler::FeatureFile.new(file_path)
6
- end
7
-
8
- And(/^a feature file model based on that file$/) do |code_text|
9
- code_text = code_text.gsub('<file_path>', "'#{@file_path}'")
10
-
11
- eval(code_text)
12
- end
13
-
14
- And(/^the comment model of that feature file model$/) do |code_text|
15
- eval(code_text)
16
- end
@@ -1,7 +0,0 @@
1
- And(/^the \w+ model of that feature model$/) do |code_text|
2
- eval(code_text)
3
- end
4
-
5
- And(/^the \w+(?: \w+)? model inside of that feature model$/) do |code_text|
6
- eval(code_text)
7
- end
@@ -1,49 +0,0 @@
1
- Given(/^the models provided by CukeModeler/) do
2
- @available_model_classes = Array.new.tap do |classes|
3
- CukeModeler.constants.each do |constant|
4
- if CukeModeler.const_get(constant).is_a?(Class)
5
- classes << CukeModeler.const_get(constant) if CukeModeler.const_get(constant).ancestors.include?(CukeModeler::Model)
6
- end
7
- end
8
- end
9
- end
10
-
11
- When(/^the model is output as a string$/) do |code_text|
12
- @output = eval(code_text)
13
- end
14
-
15
- And(/^a(?:n)? \w+(?: \w+)? model based on that gherkin$/) do |code_text|
16
- code_text = code_text.gsub('<source_text>', "'#{@source_text}'")
17
-
18
- eval(code_text)
19
- end
20
-
21
- Given(/^(?:a|the) (?:directory|feature file) is modeled$/) do |code_text|
22
- code_text = code_text.gsub('<path_to>', @root_test_directory)
23
-
24
- eval(code_text)
25
- end
26
-
27
- When(/^the \w+(?: \w+)?'s \w+(?: \w+)? (?:is|are) requested$/) do |code_text|
28
- @result = eval(code_text)
29
- end
30
-
31
- Given(/^a model for the following background:$/) do |gherkin_text|
32
- @models ||= []
33
- @models << CukeModeler::Background.new(gherkin_text)
34
- end
35
-
36
- Given(/^a model for the following scenario:$/) do |gherkin_text|
37
- @models ||= []
38
- @models << CukeModeler::Scenario.new(gherkin_text)
39
- end
40
-
41
- Given(/^a model for the following outline:$/) do |gherkin_text|
42
- @models ||= []
43
- @models << CukeModeler::Outline.new(gherkin_text)
44
- end
45
-
46
- Given(/^a model for the following step:$/) do |gherkin_text|
47
- @models ||= []
48
- @models << CukeModeler::Step.new(gherkin_text)
49
- end
@@ -1,32 +0,0 @@
1
- Given /^(?:a|the) directory "([^"]*)"$/ do |directory_name|
2
- @test_directory = "#{@root_test_directory}/#{directory_name}"
3
-
4
- FileUtils.mkdir(@test_directory) unless File.exists?(@test_directory)
5
- end
6
-
7
- And(/^(?:a|the) file "([^"]*)"$/) do |file_name|
8
- file_path = "#{@root_test_directory}/#{file_name}"
9
-
10
- # Some versions of Gherkin require feature content to be present in feature files
11
- if file_name =~ /\.feature/
12
- File.open(file_path, 'w') { |file|
13
- file.write('Feature:')
14
- }
15
- else
16
- FileUtils.touch(file_path)
17
- end
18
- end
19
-
20
- And(/^the file "([^"]*)":$/) do |file_name, file_text|
21
- file_path = "#{@root_test_directory}/#{file_name}"
22
-
23
- File.open(file_path, 'w') { |file| file.write(file_text) }
24
- end
25
-
26
- Given(/^the following gherkin:$/) do |text|
27
- @source_text = text
28
- end
29
-
30
- Given(/^a feature file with the following gherkin:$/) do |file_text|
31
- @file_path = CukeModeler::FileHelper.create_feature_file(:text => file_text)
32
- end
@@ -1,3 +0,0 @@
1
- Given(/^a step model based on the following gherkin:$/) do |source_text|
2
- @model = CukeModeler::Step.new(source_text)
3
- end
@@ -1 +0,0 @@
1
- # No steps specific to this type of model
@@ -1,3 +0,0 @@
1
- When(/^all of the \w+'s tags are requested$/) do |code_text|
2
- @result = eval(code_text)
3
- end
@@ -1,181 +0,0 @@
1
- Then(/^all of them can be output as text appropriate to the model type$/) do |code_text|
2
- original_text = code_text
3
-
4
- @available_model_classes.each do |clazz|
5
- code_text = original_text.gsub('<model_class>', clazz.to_s)
6
-
7
- expect(clazz.instance_method(:to_s).owner).to equal(clazz), "#{clazz} does not override #to_s"
8
-
9
- # Make sure that the example code is valid
10
- expect { eval(code_text) }.to_not raise_error
11
- end
12
- end
13
-
14
- Then(/^the following text is provided:$/) do |expected_text|
15
- expected_text = expected_text.sub('<path_to>', @root_test_directory)
16
-
17
- expect(@output).to eq(expected_text)
18
- end
19
-
20
- Then(/^all of them can be contained inside of another model$/) do |code_text|
21
- original_text = code_text
22
-
23
- @available_model_classes.each do |clazz|
24
- code_text = original_text.gsub('<model_class>', clazz.to_s)
25
-
26
- expect(clazz.new).to respond_to(:parent_model)
27
-
28
- # Make sure that the example code is valid
29
- expect { eval(code_text) }.to_not raise_error
30
- end
31
- end
32
-
33
- And(/^all of them can contain other models$/) do |code_text|
34
- original_text = code_text
35
-
36
- @available_model_classes.each do |clazz|
37
- code_text = original_text.gsub('<model_class>', clazz.to_s)
38
-
39
- expect(clazz.new).to respond_to(:children)
40
-
41
- # Make sure that the example code is valid
42
- expect { eval(code_text) }.to_not raise_error
43
- end
44
- end
45
-
46
- Then(/^all of them can be created without further context$/) do |code_text|
47
- original_text = code_text
48
-
49
- @available_model_classes.each do |clazz|
50
- code_text = original_text.gsub('<model_class>', clazz.to_s)
51
-
52
- expect { clazz.new }.to_not raise_error
53
-
54
- # Make sure that the example code is valid
55
- expect { eval(code_text) }.to_not raise_error
56
- end
57
- end
58
-
59
- Then(/^the model returns "([^"]*)"$/) do |value|
60
- value.gsub!('path_to', @root_test_directory) if value.is_a?(String)
61
- value = value.to_i if value =~ /^\d+$/
62
-
63
- expect(@result).to eq(value)
64
- end
65
-
66
- Then(/^the model returns$/) do |value|
67
- value = value.gsub('path_to', @root_test_directory) if value.is_a?(String)
68
-
69
- expect(@result).to eq(value)
70
- end
71
-
72
- Then(/^the model returns models for the following feature files:$/) do |file_names|
73
- file_names = file_names.raw.flatten
74
-
75
- expect(@result.collect { |file_model| file_model.name }).to match_array(file_names)
76
- end
77
-
78
- Then(/^the model returns models for the following directories:$/) do |directory_names|
79
- directory_names = directory_names.raw.flatten
80
-
81
- expect(@result.collect { |directory_model| directory_model.name }).to match_array(directory_names)
82
- end
83
-
84
- And(/^the output can be used to make an equivalent model$/) do |code_text|
85
- clazz = @model.class
86
-
87
- base_output = @model.to_s
88
- remodeled_output = clazz.new(base_output).to_s
89
-
90
- expect(remodeled_output).to eq(base_output)
91
-
92
- # Make sure that the example code is valid
93
- expect { eval(code_text) }.to_not raise_error
94
- end
95
-
96
- Then(/^all of them provide access to the parsing data that was used to create them$/) do |code_text|
97
- original_text = code_text
98
- unparsed_models = [CukeModeler::Model, CukeModeler::Directory]
99
-
100
- @available_model_classes.each do |clazz|
101
- next if unparsed_models.include?(clazz)
102
-
103
- expect(clazz.new).to respond_to(:parsing_data)
104
-
105
- # Make sure that the example code is valid
106
- code_text = original_text.gsub('<model_class>', clazz.to_s)
107
- code_text.gsub!('<source_text>', '')
108
-
109
- expect { eval(code_text) }.to_not raise_error
110
- end
111
- end
112
-
113
- Then(/^the model returns models for the following steps:$/) do |step_names|
114
- step_names = step_names.raw.flatten
115
-
116
- expect(@result.collect { |step_model| step_model.text }).to eq(step_names)
117
- end
118
-
119
- Then(/^the model returns models for the following rows:$/) do |rows|
120
- rows = rows.raw
121
-
122
- expect(@result.collect { |row_model| row_model.cells.collect { |cell| cell.value } }).to eq(rows)
123
- end
124
-
125
- Then(/^the model returns a model for the following feature:$/) do |feature_name|
126
- feature_name = feature_name.raw.flatten.first
127
-
128
- expect(@result.name).to eq(feature_name)
129
- end
130
-
131
- Then(/^the model returns a model for the following table:$/) do |table_rows|
132
- table_rows = table_rows.raw
133
-
134
- expect(@result.rows.collect { |row| row.cells.collect { |cell| cell.value } }).to eq(table_rows)
135
- end
136
-
137
- Then(/^the model returns a model for the following doc string:$/) do |string_text|
138
- expect(@result.content).to eq(string_text)
139
- end
140
-
141
- Then(/^the model returns a model for the background "([^"]*)"$/) do |background_name|
142
- expect(@result.name).to eq(background_name)
143
- end
144
-
145
- Then(/^the model returns models for the following (?:scenario|outline|tag|example)s:$/) do |model_names|
146
- model_names = model_names.raw.flatten
147
-
148
- expect(@result.collect { |model| model.name }).to eq(model_names)
149
- end
150
-
151
- Then(/^the model returns models for the following cells:$/) do |model_values|
152
- model_values = model_values.raw.flatten
153
-
154
- expect(@result.collect { |model| model.value }).to eq(model_values)
155
- end
156
-
157
- Then(/^all of them are equivalent$/) do
158
- expect(@results).to_not include(false)
159
- end
160
-
161
- But(/^none of the models are equivalent with a model for the following scenario:$/) do |gherkin_text|
162
- model = CukeModeler::Scenario.new(gherkin_text)
163
-
164
- @models.each do |other_model|
165
- expect(model == other_model).to_not be true
166
- end
167
- end
168
-
169
- But(/^none of the models are equivalent with a model for the following step:$/) do |gherkin_text|
170
- model = CukeModeler::Step.new(gherkin_text)
171
-
172
- @models.each do |other_model|
173
- expect(model == other_model).to_not be true
174
- end
175
- end
176
-
177
- Then(/^the model returns models for the following comments:$/) do |model_values|
178
- model_values = model_values.raw.flatten
179
-
180
- expect(@result.collect { |model| model.text }).to eq(model_values)
181
- end
@@ -1,30 +0,0 @@
1
- unless RUBY_VERSION.to_s < '1.9.0'
2
- require 'simplecov'
3
- SimpleCov.command_name('cucumber_tests')
4
- end
5
-
6
- require 'test/unit/assertions'
7
- include Test::Unit::Assertions
8
-
9
- this_dir = File.dirname(__FILE__)
10
-
11
- require "#{this_dir}/../../../lib/cuke_modeler"
12
-
13
- require "#{this_dir}/../../file_helper"
14
-
15
-
16
- Before do
17
- begin
18
- @root_test_directory = CukeModeler::FileHelper.create_directory
19
- rescue => e
20
- $stdout.puts 'Problem caught in Before hook!'
21
- $stdout.puts "Type: #{e.class}"
22
- $stdout.puts "Message: #{e.message}"
23
- end
24
- end
25
-
26
- at_exit {
27
- CukeModeler::FileHelper.created_directories.each do |dir_path|
28
- FileUtils.remove_entry(dir_path, true)
29
- end
30
- }
@@ -1,48 +0,0 @@
1
- module CukeModeler
2
- module DialectHelper
3
-
4
- def self.set_dialect(dialect)
5
- @dialect = dialect
6
- end
7
-
8
- def self.feature_keyword
9
- get_word(@dialect['feature'])
10
- end
11
-
12
- def self.background_keyword
13
- get_word(@dialect['background'])
14
- end
15
-
16
- def self.scenario_keyword
17
- get_word(@dialect['scenario'])
18
- end
19
-
20
- def self.outline_keyword
21
- get_word(@dialect['scenarioOutline'] || @dialect['scenario_outline'])
22
- end
23
-
24
- def self.example_keyword
25
- get_word(@dialect['examples'])
26
- end
27
-
28
- def self.step_keyword
29
- get_word(@dialect['given']).strip
30
- end
31
-
32
- def self.given_keyword
33
- get_word(@dialect['given']).strip
34
- end
35
-
36
- def self.then_keyword
37
- get_word(@dialect['then']).strip
38
- end
39
-
40
- def self.get_word(word_set)
41
- word_set.is_a?(Array) ? word_set.first : word_set.split('|').first
42
- end
43
-
44
-
45
- private_class_method :get_word
46
-
47
- end
48
- end
@@ -1,47 +0,0 @@
1
- require 'tmpdir'
2
-
3
-
4
- module CukeModeler
5
- module FileHelper
6
-
7
- class << self
8
-
9
- def create_feature_file(options = {})
10
- options[:text] ||= 'Feature:'
11
- options[:name] ||= 'test_file'
12
-
13
- create_file(:text => options[:text], :name => options[:name], :extension => '.feature', :directory => options[:directory])
14
- end
15
-
16
- def create_file(options = {})
17
- options[:text] ||= ''
18
- options[:name] ||= 'test_file'
19
- options[:extension] ||= '.txt'
20
- options[:directory] ||= create_directory
21
-
22
- file_path = "#{options[:directory]}/#{options[:name]}#{options[:extension]}"
23
- File.open(file_path, 'w') { |file| file.write(options[:text]) }
24
-
25
- file_path
26
- end
27
-
28
- def created_directories
29
- @created_directories ||= []
30
- end
31
-
32
- def create_directory(options = {})
33
- options[:name] ||= 'test_directory'
34
- options[:directory] ||= Dir.mktmpdir
35
-
36
- path = "#{options[:directory]}/#{options[:name]}"
37
-
38
- Dir::mkdir(path)
39
- created_directories << options[:directory]
40
-
41
- path
42
- end
43
-
44
- end
45
-
46
- end
47
- end