cuke_modeler 1.5.0 → 3.1.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 (129) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +341 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +22 -15
  5. data/cuke_modeler.gemspec +15 -9
  6. data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +12 -0
  7. data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +12 -0
  8. data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +12 -0
  9. data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +12 -0
  10. data/lib/cuke_modeler/adapters/gherkin_14_adapter.rb +12 -0
  11. data/lib/cuke_modeler/adapters/{gherkin_6_adapter.rb → gherkin_9_adapter.rb} +75 -64
  12. data/lib/cuke_modeler/containing.rb +3 -0
  13. data/lib/cuke_modeler/described.rb +1 -0
  14. data/lib/cuke_modeler/models/background.rb +1 -1
  15. data/lib/cuke_modeler/models/cell.rb +1 -1
  16. data/lib/cuke_modeler/models/comment.rb +1 -1
  17. data/lib/cuke_modeler/models/directory.rb +2 -2
  18. data/lib/cuke_modeler/models/doc_string.rb +1 -1
  19. data/lib/cuke_modeler/models/example.rb +1 -1
  20. data/lib/cuke_modeler/models/feature.rb +1 -1
  21. data/lib/cuke_modeler/models/feature_file.rb +2 -2
  22. data/lib/cuke_modeler/models/outline.rb +1 -1
  23. data/lib/cuke_modeler/models/row.rb +1 -1
  24. data/lib/cuke_modeler/models/scenario.rb +1 -1
  25. data/lib/cuke_modeler/models/step.rb +32 -3
  26. data/lib/cuke_modeler/models/table.rb +1 -1
  27. data/lib/cuke_modeler/models/tag.rb +1 -1
  28. data/lib/cuke_modeler/named.rb +1 -0
  29. data/lib/cuke_modeler/nested.rb +1 -0
  30. data/lib/cuke_modeler/parsed.rb +1 -0
  31. data/lib/cuke_modeler/parsing.rb +89 -94
  32. data/lib/cuke_modeler/sourceable.rb +1 -0
  33. data/lib/cuke_modeler/stepped.rb +1 -0
  34. data/lib/cuke_modeler/taggable.rb +1 -0
  35. data/lib/cuke_modeler/version.rb +1 -1
  36. data/testing/cucumber/features/analysis/step_comparison.feature +25 -0
  37. data/testing/cucumber/features/analysis/test_comparison.feature +1 -1
  38. metadata +56 -142
  39. data/.gitignore +0 -18
  40. data/.simplecov +0 -7
  41. data/.travis.yml +0 -60
  42. data/Gemfile +0 -36
  43. data/History.md +0 -196
  44. data/Rakefile +0 -63
  45. data/appveyor.yml +0 -61
  46. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -273
  47. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -296
  48. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -308
  49. data/testing/cucumber/step_definitions/action_steps.rb +0 -13
  50. data/testing/cucumber/step_definitions/background_steps.rb +0 -1
  51. data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
  52. data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
  53. data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
  54. data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
  55. data/testing/cucumber/step_definitions/modeling_steps.rb +0 -44
  56. data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
  57. data/testing/cucumber/step_definitions/step_steps.rb +0 -3
  58. data/testing/cucumber/step_definitions/table_steps.rb +0 -1
  59. data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
  60. data/testing/cucumber/step_definitions/verification_steps.rb +0 -173
  61. data/testing/cucumber/support/env.rb +0 -30
  62. data/testing/dialect_helper.rb +0 -48
  63. data/testing/file_helper.rb +0 -47
  64. data/testing/gemfiles/gherkin2.gemfile +0 -32
  65. data/testing/gemfiles/gherkin3.gemfile +0 -26
  66. data/testing/gemfiles/gherkin4.gemfile +0 -27
  67. data/testing/gemfiles/gherkin5.gemfile +0 -27
  68. data/testing/gemfiles/gherkin6.gemfile +0 -10
  69. data/testing/rspec/spec/integration/background_integration_spec.rb +0 -442
  70. data/testing/rspec/spec/integration/cell_integration_spec.rb +0 -335
  71. data/testing/rspec/spec/integration/comment_integration_spec.rb +0 -177
  72. data/testing/rspec/spec/integration/directory_integration_spec.rb +0 -218
  73. data/testing/rspec/spec/integration/doc_string_integration_spec.rb +0 -402
  74. data/testing/rspec/spec/integration/example_integration_spec.rb +0 -741
  75. data/testing/rspec/spec/integration/feature_file_integration_spec.rb +0 -272
  76. data/testing/rspec/spec/integration/feature_integration_spec.rb +0 -650
  77. data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +0 -166
  78. data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +0 -166
  79. data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +0 -165
  80. data/testing/rspec/spec/integration/gherkin_6_adapter_spec.rb +0 -166
  81. data/testing/rspec/spec/integration/model_integration_spec.rb +0 -15
  82. data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
  83. data/testing/rspec/spec/integration/outline_integration_spec.rb +0 -624
  84. data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -122
  85. data/testing/rspec/spec/integration/row_integration_spec.rb +0 -291
  86. data/testing/rspec/spec/integration/scenario_integration_spec.rb +0 -479
  87. data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
  88. data/testing/rspec/spec/integration/step_integration_spec.rb +0 -475
  89. data/testing/rspec/spec/integration/table_integration_spec.rb +0 -337
  90. data/testing/rspec/spec/integration/tag_integration_spec.rb +0 -259
  91. data/testing/rspec/spec/spec_helper.rb +0 -122
  92. data/testing/rspec/spec/unit/background_unit_spec.rb +0 -83
  93. data/testing/rspec/spec/unit/cell_unit_spec.rb +0 -68
  94. data/testing/rspec/spec/unit/comment_unit_spec.rb +0 -68
  95. data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
  96. data/testing/rspec/spec/unit/directory_unit_spec.rb +0 -127
  97. data/testing/rspec/spec/unit/doc_string_unit_spec.rb +0 -100
  98. data/testing/rspec/spec/unit/example_unit_spec.rb +0 -133
  99. data/testing/rspec/spec/unit/feature_file_unit_spec.rb +0 -125
  100. data/testing/rspec/spec/unit/feature_unit_spec.rb +0 -157
  101. data/testing/rspec/spec/unit/model_unit_spec.rb +0 -15
  102. data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
  103. data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
  104. data/testing/rspec/spec/unit/outline_unit_spec.rb +0 -117
  105. data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
  106. data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
  107. data/testing/rspec/spec/unit/row_unit_spec.rb +0 -68
  108. data/testing/rspec/spec/unit/scenario_unit_spec.rb +0 -86
  109. data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
  110. data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -127
  111. data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
  112. data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
  113. data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
  114. data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
  115. data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
  116. data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
  117. data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
  118. data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
  119. data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
  120. data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
  121. data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
  122. data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
  123. data/testing/rspec/spec/unit/step_unit_spec.rb +0 -109
  124. data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
  125. data/testing/rspec/spec/unit/table_unit_spec.rb +0 -77
  126. data/testing/rspec/spec/unit/tag_unit_spec.rb +0 -68
  127. data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
  128. data/testing/test_languages.json +0 -45
  129. data/todo.txt +0 -24
@@ -1,218 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../spec_helper"
2
-
3
-
4
- describe 'Directory, Integration' do
5
-
6
- let(:clazz) { CukeModeler::Directory }
7
-
8
-
9
- describe 'common behavior' do
10
-
11
- it_should_behave_like 'a model, integration'
12
-
13
- end
14
-
15
-
16
- describe 'unique behavior' do
17
-
18
-
19
- describe 'modeling directories' do
20
-
21
-
22
- context 'with an existing directory' do
23
-
24
- let(:root_test_path) { CukeModeler::FileHelper.create_directory }
25
-
26
- let(:directory_path) { CukeModeler::FileHelper.create_directory(:name => 'nested_directory', :directory => root_test_path) }
27
- let(:directory_model) { clazz.new(directory_path) }
28
-
29
-
30
- it 'models the path of the directory' do
31
- expect(directory_model.path).to eq(directory_path)
32
- end
33
-
34
- it 'models the name of the directory' do
35
- name = File.basename(directory_path)
36
-
37
- expect(directory_model.name).to eq(name)
38
- end
39
-
40
-
41
- context 'with both files and feature files' do
42
-
43
- let(:feature_files) { ['test_file_1', 'test_file_2'] }
44
- let(:non_feature_files) { ['test_file_3'] }
45
-
46
- before(:each) do
47
- feature_files.each do |file_name|
48
- # Some versions of Gherkin require feature content to be present in feature files
49
- CukeModeler::FileHelper.create_feature_file(:text => "#{FEATURE_KEYWORD}: Test feature", :name => file_name, :directory => directory_path)
50
- end
51
-
52
- non_feature_files.each do |file_name|
53
- CukeModeler::FileHelper.create_file(:text => '', :name => file_name, :extension => '.file', :directory => directory_path)
54
- end
55
- end
56
-
57
-
58
- it 'models the feature files contained in the directory' do
59
- modeled_files = directory_model.feature_files.collect { |file| file.name[/test_file_\d/] }
60
-
61
- expect(modeled_files).to match_array(feature_files)
62
- end
63
-
64
- it 'does not model non-feature files contained in the directory' do
65
- modeled_files = directory_model.feature_files.collect { |file| file.name[/test_file_\d/] }
66
-
67
- non_feature_files.all? do |file|
68
- expect(modeled_files).to_not include(file)
69
- end
70
- end
71
-
72
- end
73
-
74
-
75
- context 'with no feature files' do
76
-
77
- let(:directory_path) { CukeModeler::FileHelper.create_directory(:name => 'empty_directory', :directory => root_test_path) }
78
- let(:directory_model) { clazz.new(directory_path) }
79
-
80
-
81
- it 'models the feature files contained in the directory' do
82
- modeled_files = directory_model.feature_files.collect { |file| file.name }
83
-
84
- expect(modeled_files).to eq([])
85
- end
86
-
87
- end
88
-
89
-
90
- context 'with a nested directory' do
91
-
92
- let(:directory_path) { CukeModeler::FileHelper.create_directory(:name => 'test_directory', :directory => root_test_path) }
93
- let(:directory_model) { clazz.new(directory_path) }
94
-
95
- let(:nested_directories) { ['nested_directory_1', 'nested_directory_2'] }
96
-
97
- before(:each) do
98
- nested_directories.each do |nested_directory|
99
- CukeModeler::FileHelper.create_directory(:name => nested_directory, :directory => directory_path)
100
- end
101
- end
102
-
103
-
104
- it 'models the directories in the directory' do
105
- modeled_directories = directory_model.directories.collect { |nested_directory| nested_directory.name[/nested_directory_\d/] }
106
-
107
- expect(modeled_directories).to match_array(nested_directories)
108
- end
109
-
110
- end
111
-
112
-
113
- context 'with no directories' do
114
-
115
- let(:directory_path) { CukeModeler::FileHelper.create_directory(:name => 'empty_directory', :directory => root_test_path) }
116
- let(:directory_model) { clazz.new(directory_path) }
117
-
118
-
119
- it 'models the directories contained in the directory' do
120
- modeled_directories = directory_model.directories.collect { |nested_directory| nested_directory.name }
121
-
122
- expect(modeled_directories).to eq([])
123
- end
124
-
125
- end
126
-
127
- end
128
-
129
-
130
- context 'with a non-existing directory' do
131
-
132
- let(:root_test_path) { CukeModeler::FileHelper.create_directory }
133
- let(:directory_path) { "#{root_test_path}/this_directory_should_not_exist" }
134
-
135
-
136
- it 'cannot model a non-existent directory' do
137
- expect { clazz.new(directory_path) }.to raise_error(ArgumentError)
138
- end
139
-
140
- end
141
-
142
- end
143
-
144
-
145
- it 'properly sets its child models' do
146
- directory_path = CukeModeler::FileHelper.create_directory
147
- _nested_directory_path = CukeModeler::FileHelper.create_directory(:name => 'nested_directory', :directory => directory_path)
148
-
149
- CukeModeler::FileHelper.create_feature_file(:text => "#{FEATURE_KEYWORD}: Test feature", :name => 'test_file', :directory => directory_path)
150
-
151
-
152
- directory_model = clazz.new(directory_path)
153
- nested_directory_model = directory_model.directories.first
154
- file_model = directory_model.feature_files.first
155
-
156
- expect(nested_directory_model.parent_model).to equal(directory_model)
157
- expect(file_model.parent_model).to equal(directory_model)
158
- end
159
-
160
-
161
- describe 'getting ancestors' do
162
-
163
- before(:each) do
164
- CukeModeler::FileHelper.create_directory(:name => 'nested_directory', :directory => test_directory)
165
- end
166
-
167
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
168
-
169
- let(:directory_model) { clazz.new(test_directory) }
170
- let(:nested_directory_model) { directory_model.directories.first }
171
-
172
-
173
- it 'can get its directory' do
174
- ancestor = nested_directory_model.get_ancestor(:directory)
175
-
176
- expect(ancestor).to equal(directory_model)
177
- end
178
-
179
- it 'returns nil if it does not have the requested type of ancestor' do
180
- ancestor = nested_directory_model.get_ancestor(:example)
181
-
182
- expect(ancestor).to be_nil
183
- end
184
-
185
- end
186
-
187
-
188
- describe 'directory output' do
189
-
190
- context 'from source text' do
191
-
192
- let(:directory_path) { CukeModeler::FileHelper.create_directory }
193
- let(:directory_model) { clazz.new(directory_path) }
194
-
195
-
196
- it 'can output a directory' do
197
- directory_output = directory_model.to_s
198
-
199
- expect(directory_output).to eq(directory_path)
200
- end
201
-
202
- end
203
-
204
- it 'can be remade from its own output' do
205
- source = CukeModeler::FileHelper.create_directory
206
- directory = clazz.new(source)
207
-
208
- directory_output = directory.to_s
209
- remade_directory_output = clazz.new(directory_output).to_s
210
-
211
- expect(remade_directory_output).to eq(directory_output)
212
- end
213
-
214
- end
215
-
216
- end
217
-
218
- end
@@ -1,402 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../spec_helper"
2
-
3
-
4
- describe 'DocString, Integration' do
5
-
6
- let(:clazz) { CukeModeler::DocString }
7
-
8
-
9
- describe 'common behavior' do
10
-
11
- it_should_behave_like 'a model, integration'
12
-
13
- end
14
-
15
- describe 'unique behavior' do
16
-
17
- it 'can be instantiated with the minimum viable Gherkin' do
18
- source = "\"\"\"\n\"\"\""
19
-
20
- expect { clazz.new(source) }.to_not raise_error
21
- end
22
-
23
- it 'can parse text that uses a non-default dialect' do
24
- original_dialect = CukeModeler::Parsing.dialect
25
- CukeModeler::Parsing.dialect = 'en-au'
26
-
27
- begin
28
- source_text = "\"\"\"\ntext foo\n\"\"\""
29
-
30
- expect { @model = clazz.new(source_text) }.to_not raise_error
31
-
32
- # Sanity check in case modeling failed in a non-explosive manner
33
- expect(@model.content).to eq('text foo')
34
- ensure
35
- # Making sure that our changes don't escape a test and ruin the rest of the suite
36
- CukeModeler::Parsing.dialect = original_dialect
37
- end
38
- end
39
-
40
- it 'provides a descriptive filename when being parsed from stand alone text' do
41
- source = 'bad doc string text'
42
-
43
- expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_doc_string\.feature'/)
44
- end
45
-
46
- it 'stores the original data generated by the parsing adapter', :gherkin6 => true do
47
- doc_string = clazz.new("\"\"\" content type\nsome doc string\n\"\"\"")
48
- data = doc_string.parsing_data
49
-
50
- expect(data.keys).to match_array([:location, :content, :content_type, :delimiter])
51
- expect(data[:content]).to eq('some doc string')
52
- end
53
-
54
- it 'stores the original data generated by the parsing adapter', :gherkin4_5 => true do
55
- doc_string = clazz.new("\"\"\" content type\nsome doc string\n\"\"\"")
56
- data = doc_string.parsing_data
57
-
58
- expect(data.keys).to match_array([:type, :location, :content, :contentType])
59
- expect(data[:type]).to eq(:DocString)
60
- end
61
-
62
- it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
63
- doc_string = clazz.new("\"\"\" content type\nsome doc string\n\"\"\"")
64
- data = doc_string.parsing_data
65
-
66
- expect(data.keys).to match_array([:type, :location, :content, :contentType])
67
- expect(data[:type]).to eq(:DocString)
68
- end
69
-
70
- it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
71
- doc_string = clazz.new("\"\"\" content type\nsome doc string\n\"\"\"")
72
- data = doc_string.parsing_data
73
-
74
- expect(data.keys).to match_array(['value', 'content_type', 'line'])
75
- expect(data['value']).to eq('some doc string')
76
- end
77
-
78
- it 'stores its content as a String' do
79
- source = "\"\"\"\nsome text\nsome more text\n\"\"\""
80
- doc_string = clazz.new(source)
81
-
82
- content = doc_string.content
83
-
84
- expect(content).to be_a(String)
85
- end
86
-
87
-
88
- describe 'getting ancestors' do
89
-
90
- before(:each) do
91
- CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'doc_string_test_file', :directory => test_directory)
92
- end
93
-
94
-
95
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
96
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
97
-
98
- #{SCENARIO_KEYWORD}: Test test
99
- #{STEP_KEYWORD} a big step:
100
- \"\"\"
101
- a
102
- doc
103
- string
104
- \"\"\""
105
- }
106
-
107
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
108
- let(:doc_string_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block }
109
-
110
-
111
- it 'can get its directory' do
112
- ancestor = doc_string_model.get_ancestor(:directory)
113
-
114
- expect(ancestor).to equal(directory_model)
115
- end
116
-
117
- it 'can get its feature file' do
118
- ancestor = doc_string_model.get_ancestor(:feature_file)
119
-
120
- expect(ancestor).to equal(directory_model.feature_files.first)
121
- end
122
-
123
- it 'can get its feature' do
124
- ancestor = doc_string_model.get_ancestor(:feature)
125
-
126
- expect(ancestor).to equal(directory_model.feature_files.first.feature)
127
- end
128
-
129
- context 'a doc string that is part of a scenario' do
130
-
131
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
132
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
133
-
134
- #{SCENARIO_KEYWORD}: Test test
135
- #{STEP_KEYWORD} a big step:
136
- \"\"\"
137
- a
138
- doc
139
- string
140
- \"\"\""
141
- }
142
-
143
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
144
- let(:doc_string_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block }
145
-
146
-
147
- it 'can get its scenario' do
148
- ancestor = doc_string_model.get_ancestor(:scenario)
149
-
150
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
151
- end
152
-
153
- end
154
-
155
- context 'a doc string that is part of an outline' do
156
-
157
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
158
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
159
-
160
- #{OUTLINE_KEYWORD}: Test outline
161
- #{STEP_KEYWORD} a big step:
162
- \"\"\"
163
- a
164
- doc
165
- string
166
- \"\"\"
167
- #{EXAMPLE_KEYWORD}:
168
- | param |
169
- | value |"
170
- }
171
-
172
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
173
- let(:doc_string_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block }
174
-
175
-
176
- it 'can get its outline' do
177
- ancestor = doc_string_model.get_ancestor(:outline)
178
-
179
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
180
- end
181
-
182
- end
183
-
184
- context 'a doc string that is part of a background' do
185
-
186
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
187
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
188
-
189
- #{BACKGROUND_KEYWORD}: Test background
190
- #{STEP_KEYWORD} a big step:
191
- \"\"\"
192
- a
193
- doc
194
- string
195
- \"\"\""
196
- }
197
-
198
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
199
- let(:doc_string_model) { directory_model.feature_files.first.feature.background.steps.first.block }
200
-
201
-
202
- it 'can get its background' do
203
- ancestor = doc_string_model.get_ancestor(:background)
204
-
205
- expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
206
- end
207
-
208
- end
209
-
210
- it 'can get its step' do
211
- ancestor = doc_string_model.get_ancestor(:step)
212
-
213
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first)
214
- end
215
-
216
- it 'returns nil if it does not have the requested type of ancestor' do
217
- ancestor = doc_string_model.get_ancestor(:example)
218
-
219
- expect(ancestor).to be_nil
220
- end
221
-
222
- end
223
-
224
-
225
- describe 'model population' do
226
-
227
- context 'from source text' do
228
-
229
- context 'a filled doc string' do
230
-
231
- let(:source_text) { ['""" type foo',
232
- 'bar',
233
- '"""'].join("\n") }
234
- let(:doc_string) { clazz.new(source_text) }
235
-
236
-
237
- it "models the doc string's content type" do
238
- expect(doc_string.content_type).to eq('type foo')
239
- end
240
-
241
- it "models the doc_string's content" do
242
- expect(doc_string.content).to eq('bar')
243
- end
244
-
245
- end
246
-
247
- context 'an empty doc_string' do
248
-
249
- let(:source_text) { '"""
250
- """' }
251
- let(:doc_string) { clazz.new(source_text) }
252
-
253
- it "models the doc_string's content type" do
254
- expect(doc_string.content_type).to be_nil
255
- end
256
-
257
- it "models the doc_string's content" do
258
- expect(doc_string.content).to eq('')
259
- end
260
-
261
- end
262
-
263
- it "models the doc string's source line" do
264
- source_text = "#{FEATURE_KEYWORD}:
265
-
266
- #{SCENARIO_KEYWORD}:
267
- #{STEP_KEYWORD} step
268
- \"\"\"
269
- foo
270
- \"\"\""
271
- doc_string = CukeModeler::Feature.new(source_text).tests.first.steps.first.block
272
-
273
- expect(doc_string.source_line).to eq(5)
274
- end
275
-
276
- end
277
-
278
- end
279
-
280
-
281
- describe 'doc string output' do
282
-
283
- it 'can be remade from its own output' do
284
- source = ['"""" the type',
285
- "#{STEP_KEYWORD} a step",
286
- ' \"\"\"',
287
- ' that also has a doc string',
288
- ' \"\"\"',
289
- '"""']
290
- source = source.join("\n")
291
- doc_string = clazz.new(source)
292
-
293
- doc_string_output = doc_string.to_s
294
- remade_doc_string_output = clazz.new(doc_string_output).to_s
295
-
296
- expect(remade_doc_string_output).to eq(doc_string_output)
297
- end
298
-
299
-
300
- context 'from source text' do
301
-
302
- it 'can output an empty doc string' do
303
- source = ['"""',
304
- '"""']
305
- source = source.join("\n")
306
- doc_string = clazz.new(source)
307
-
308
- doc_string_output = doc_string.to_s.split("\n", -1)
309
-
310
- expect(doc_string_output).to eq(['"""', '"""'])
311
- end
312
-
313
- it 'can output a doc string that has a content type' do
314
- source = ['""" foo',
315
- '"""']
316
- source = source.join("\n")
317
- doc_string = clazz.new(source)
318
-
319
- doc_string_output = doc_string.to_s.split("\n", -1)
320
-
321
- expect(doc_string_output).to eq(['""" foo',
322
- '"""'])
323
- end
324
-
325
- it 'can output a doc_string that has contents' do
326
- source = ['"""',
327
- 'foo',
328
- '"""']
329
- source = source.join("\n")
330
- doc_string = clazz.new(source)
331
-
332
- doc_string_output = doc_string.to_s.split("\n", -1)
333
-
334
- expect(doc_string_output).to eq(['"""',
335
- 'foo',
336
- '"""'])
337
- end
338
-
339
- # Since triple double quotes mark the beginning and end of a doc string, any triple
340
- # double quotes inside of the doc string (which would have had to have been escaped
341
- # to get inside in the first place) will be escaped when outputted so as to
342
- # retain the quality of being able to use the output directly as gherkin.
343
-
344
- it 'can output a doc_string that has triple double quotes in the contents' do
345
- source = ['"""',
346
- 'a \"\"\"',
347
- '\"\"\" again',
348
- '"""']
349
- source = source.join("\n")
350
- doc_string = clazz.new(source)
351
-
352
- doc_string_output = doc_string.to_s.split("\n", -1)
353
-
354
- expect(doc_string_output).to eq(['"""',
355
- 'a \"\"\"',
356
- '\"\"\" again',
357
- '"""'])
358
- end
359
-
360
- # Double quotes that are not three (or more) in a row do not seem to need and special escaping when
361
- # used in Gherkin. Therefore they should be left alone.
362
- it 'only escapes triple double quotes' do
363
- source = ['"""',
364
- 'change these \"\"\"\"\"\"',
365
- 'but leave " and "" alone',
366
- '"""']
367
- source = source.join("\n")
368
- doc_string = clazz.new(source)
369
-
370
- doc_string_output = doc_string.to_s.split("\n", -1)
371
-
372
- expect(doc_string_output).to eq(['"""',
373
- 'change these \"\"\"\"\"\"',
374
- 'but leave " and "" alone',
375
- '"""'])
376
- end
377
-
378
- it 'can output a doc string that has everything' do
379
- source = ['""" type foo',
380
- '\"\"\"',
381
- 'bar',
382
- '\"\"\"',
383
- '"""']
384
- source = source.join("\n")
385
- doc_string = clazz.new(source)
386
-
387
- doc_string_output = doc_string.to_s.split("\n", -1)
388
-
389
- expect(doc_string_output).to eq(['""" type foo',
390
- '\"\"\"',
391
- 'bar',
392
- '\"\"\"',
393
- '"""'])
394
- end
395
-
396
- end
397
-
398
- end
399
-
400
- end
401
-
402
- end