howitzer 2.2.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -1
  3. data/LICENSE +1 -1
  4. data/README.md +16 -17
  5. data/generators/base_generator.rb +4 -6
  6. data/generators/config/config_generator.rb +2 -4
  7. data/generators/config/templates/boot.rb +1 -1
  8. data/generators/config/templates/capybara.rb +3 -5
  9. data/generators/config/templates/default.yml +19 -20
  10. data/generators/config/templates/drivers/browserstack.rb +31 -4
  11. data/generators/config/templates/drivers/crossbrowsertesting.rb +9 -11
  12. data/generators/config/templates/drivers/headless_chrome.rb +1 -1
  13. data/generators/config/templates/drivers/headless_firefox.rb +1 -1
  14. data/generators/config/templates/drivers/lambdatest.rb +30 -0
  15. data/generators/config/templates/drivers/sauce.rb +30 -2
  16. data/generators/config/templates/drivers/selenium.rb +1 -1
  17. data/generators/config/templates/drivers/selenium_grid.rb +3 -3
  18. data/generators/config/templates/drivers/testingbot.rb +29 -2
  19. data/generators/cucumber/templates/env.rb +1 -1
  20. data/generators/cucumber/templates/hooks.rb +9 -3
  21. data/generators/cucumber/templates/transformers.rb +1 -1
  22. data/generators/prerequisites/templates/factory_bot.rb +1 -1
  23. data/generators/root/templates/Gemfile.erb +4 -14
  24. data/generators/rspec/templates/spec_helper.rb +5 -5
  25. data/generators/turnip/templates/spec_helper.rb +5 -5
  26. data/generators/web/templates/example_page.rb +1 -1
  27. data/lib/howitzer/cache.rb +1 -1
  28. data/lib/howitzer/capybara_helpers.rb +46 -9
  29. data/lib/howitzer/email.rb +2 -2
  30. data/lib/howitzer/exceptions.rb +21 -21
  31. data/lib/howitzer/gmail_api/client.rb +13 -4
  32. data/lib/howitzer/log.rb +6 -6
  33. data/lib/howitzer/mail_adapters/mailgun.rb +1 -1
  34. data/lib/howitzer/mail_adapters/mailtrap.rb +3 -3
  35. data/lib/howitzer/mail_adapters/onesecmail.rb +80 -0
  36. data/lib/howitzer/mail_adapters/testmail.rb +102 -0
  37. data/lib/howitzer/mailgun_api/client.rb +3 -2
  38. data/lib/howitzer/mailgun_api/response.rb +1 -2
  39. data/lib/howitzer/mailtrap_api/client.rb +19 -1
  40. data/lib/howitzer/meta/actions.rb +13 -16
  41. data/lib/howitzer/meta/element.rb +12 -10
  42. data/lib/howitzer/onesecmail_api/client.rb +44 -0
  43. data/lib/howitzer/onesecmail_api.rb +7 -0
  44. data/lib/howitzer/testmail_api/client.rb +44 -0
  45. data/lib/howitzer/testmail_api.rb +7 -0
  46. data/lib/howitzer/utils/string_extensions.rb +6 -2
  47. data/lib/howitzer/version.rb +1 -1
  48. data/lib/howitzer/web/base_section.rb +1 -1
  49. data/lib/howitzer/web/capybara_methods_proxy.rb +11 -5
  50. data/lib/howitzer/web/element_dsl.rb +104 -45
  51. data/lib/howitzer/web/iframe_dsl.rb +2 -2
  52. data/lib/howitzer/web/page.rb +4 -14
  53. data/lib/howitzer/web/page_dsl.rb +15 -6
  54. data/lib/howitzer/web/page_validator.rb +25 -26
  55. data/lib/howitzer/web/section.rb +5 -2
  56. data/lib/howitzer/web/section_dsl.rb +64 -30
  57. data/lib/howitzer.rb +2 -2
  58. metadata +29 -165
  59. data/.coveralls.yml +0 -1
  60. data/.gitignore +0 -14
  61. data/.rspec +0 -3
  62. data/.rubocop.yml +0 -60
  63. data/.ruby-gemset +0 -1
  64. data/.travis.yml +0 -8
  65. data/Gemfile +0 -14
  66. data/ISSUE_TEMPLATE.md +0 -16
  67. data/MAINTENANCE.md +0 -32
  68. data/Rakefile +0 -38
  69. data/features/cli_help.feature +0 -31
  70. data/features/cli_new.feature +0 -393
  71. data/features/cli_unknown.feature +0 -17
  72. data/features/cli_update.feature +0 -223
  73. data/features/cli_version.feature +0 -14
  74. data/features/step_definitions/common_steps.rb +0 -34
  75. data/features/support/env.rb +0 -1
  76. data/generators/config/templates/drivers/appium.rb +0 -25
  77. data/generators/config/templates/drivers/poltergeist.rb +0 -11
  78. data/generators/config/templates/drivers/webkit.rb +0 -6
  79. data/generators/root/templates/.gitignore +0 -21
  80. data/generators/root/templates/.rubocop.yml.erb +0 -56
  81. data/generators/turnip/templates/.rspec +0 -1
  82. data/howitzer.gemspec +0 -39
  83. data/lib/howitzer/mail_adapters/debugmail.rb +0 -0
  84. data/spec/config/custom.yml +0 -9
  85. data/spec/spec_helper.rb +0 -73
  86. data/spec/support/generator_helper.rb +0 -21
  87. data/spec/support/logger_helper.rb +0 -13
  88. data/spec/support/shared_examples/capybara_context_holder.rb +0 -33
  89. data/spec/support/shared_examples/capybara_methods_proxy.rb +0 -94
  90. data/spec/support/shared_examples/dynamic_section_methods.rb +0 -35
  91. data/spec/support/shared_examples/element_dsl.rb +0 -242
  92. data/spec/support/shared_examples/meta_highlight_xpath.rb +0 -41
  93. data/spec/unit/generators/base_generator_spec.rb +0 -283
  94. data/spec/unit/generators/config_generator_spec.rb +0 -61
  95. data/spec/unit/generators/cucumber_generator_spec.rb +0 -62
  96. data/spec/unit/generators/emails_generator_spec.rb +0 -35
  97. data/spec/unit/generators/prerequisites_generator_spec.rb +0 -53
  98. data/spec/unit/generators/root_generator_spec.rb +0 -86
  99. data/spec/unit/generators/rspec_generator_spec.rb +0 -36
  100. data/spec/unit/generators/tasks_generator_spec.rb +0 -31
  101. data/spec/unit/generators/templates/cucumber_spec.rb +0 -97
  102. data/spec/unit/generators/templates/rspec_spec.rb +0 -88
  103. data/spec/unit/generators/templates/turnip_spec.rb +0 -98
  104. data/spec/unit/generators/turnip_generator_spec.rb +0 -52
  105. data/spec/unit/generators/web_generator_spec.rb +0 -52
  106. data/spec/unit/lib/cache_spec.rb +0 -85
  107. data/spec/unit/lib/capybara_helpers_spec.rb +0 -730
  108. data/spec/unit/lib/email_spec.rb +0 -186
  109. data/spec/unit/lib/gmail_api/client_spec.rb +0 -26
  110. data/spec/unit/lib/howitzer_spec.rb +0 -92
  111. data/spec/unit/lib/init_spec.rb +0 -2
  112. data/spec/unit/lib/log_spec.rb +0 -122
  113. data/spec/unit/lib/mail_adapters/abstract_spec.rb +0 -62
  114. data/spec/unit/lib/mail_adapters/gmail_spec.rb +0 -128
  115. data/spec/unit/lib/mail_adapters/mailgun_spec.rb +0 -158
  116. data/spec/unit/lib/mail_adapters/mailtrap_spec.rb +0 -130
  117. data/spec/unit/lib/mailgun_api/client_spec.rb +0 -80
  118. data/spec/unit/lib/mailgun_api/connector_spec.rb +0 -54
  119. data/spec/unit/lib/mailgun_api/response_spec.rb +0 -28
  120. data/spec/unit/lib/mailtrap_api/client_spec.rb +0 -67
  121. data/spec/unit/lib/meta/element_spec.rb +0 -59
  122. data/spec/unit/lib/meta/entry_spec.rb +0 -77
  123. data/spec/unit/lib/meta/iframe_spec.rb +0 -66
  124. data/spec/unit/lib/meta/section_spec.rb +0 -43
  125. data/spec/unit/lib/utils/string_extensions_spec.rb +0 -77
  126. data/spec/unit/lib/web/base_section_spec.rb +0 -43
  127. data/spec/unit/lib/web/element_dsl_spec.rb +0 -31
  128. data/spec/unit/lib/web/iframe_dsl_spec.rb +0 -203
  129. data/spec/unit/lib/web/page_dsl_spec.rb +0 -74
  130. data/spec/unit/lib/web/page_spec.rb +0 -385
  131. data/spec/unit/lib/web/page_validator_spec.rb +0 -276
  132. data/spec/unit/lib/web/section_dsl_spec.rb +0 -165
  133. data/spec/unit/lib/web/section_spec.rb +0 -70
  134. data/spec/unit/version_spec.rb +0 -8
@@ -1,283 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Howitzer::BaseGenerator do
4
- let(:output) { StringIO.new }
5
- let(:destination) { Dir.mktmpdir }
6
-
7
- describe '.logger' do
8
- subject { described_class.logger }
9
- before { described_class.instance_variable_set('@logger', output) }
10
- it { is_expected.to eq(output) }
11
- end
12
-
13
- describe '.logger=' do
14
- subject { described_class.instance_variable_get('@logger') }
15
- before { described_class.logger = output }
16
- it { is_expected.to eq(output) }
17
- end
18
-
19
- describe '.destination' do
20
- subject { described_class.destination }
21
- before { described_class.instance_variable_set('@destination', destination) }
22
- it { is_expected.to eq(destination) }
23
- end
24
-
25
- describe '.destination=' do
26
- subject { described_class.instance_variable_get('@destination') }
27
- before { described_class.destination = destination }
28
- it { is_expected.to eq(destination) }
29
- end
30
-
31
- describe 'constructor' do
32
- let(:list1) { double(:list1) }
33
- let(:list2) { double(:list2) }
34
- let(:options) { { r: true, rspec: true } }
35
- subject { described_class.new(options) }
36
- before do
37
- expect_any_instance_of(described_class).to receive(:print_banner).with(no_args).once
38
- allow_any_instance_of(described_class).to receive(:manifest) do
39
- {
40
- files: list1,
41
- templates: list2,
42
- unknown: nil
43
- }
44
- end
45
- end
46
- it do
47
- expect_any_instance_of(described_class).to receive(:copy_files).with(list1).once
48
- expect_any_instance_of(described_class).to receive(:copy_templates).with(list2).once
49
- expect(subject.instance_variable_get(:@options)).to eql options
50
- end
51
- end
52
-
53
- describe '#manifest' do
54
- subject { described_class.new({}).manifest }
55
- before { allow_any_instance_of(described_class).to receive(:print_banner) { nil } }
56
- it { is_expected.to eq([]) }
57
- end
58
-
59
- describe '#banner' do
60
- subject { described_class.new({}).send(:banner) }
61
- before { allow_any_instance_of(described_class).to receive(:print_banner) { nil } }
62
- it { is_expected.to be_nil }
63
- end
64
-
65
- describe '#logger' do
66
- subject { described_class.new({}).send(:logger) }
67
- before { allow_any_instance_of(described_class).to receive(:print_banner) { nil } }
68
- context 'when not specified' do
69
- before { described_class.instance_variable_set('@logger', nil) }
70
- it { is_expected.to eq($stdout) }
71
- end
72
- context 'when custom' do
73
- let(:output) { StringIO.new }
74
- before { described_class.instance_variable_set('@logger', output) }
75
- it { is_expected.to eq(output) }
76
- end
77
- end
78
-
79
- describe '#destination' do
80
- subject { described_class.new({}).send(:destination) }
81
- before do
82
- allow_any_instance_of(described_class).to receive(:print_banner) { nil }
83
- allow(described_class).to receive(:destination) { '/' }
84
- end
85
- it { is_expected.to eq('/') }
86
- end
87
-
88
- describe '#copy_files' do
89
- let(:list) { [{ source: 'example.txt' }] }
90
- let(:source_path) { '/example_path/example.txt' }
91
- let(:generator) { described_class.new({}) }
92
- subject { generator.send(:copy_files, list) }
93
- before do
94
- allow_any_instance_of(described_class).to receive(:print_banner) { nil }
95
- allow(generator).to receive(:source_path).with(list.first[:source]) { source_path }
96
- end
97
- after { subject }
98
- context 'when source_file exists' do
99
- before { allow(File).to receive(:exist?).with(source_path) { true } }
100
- it { expect(generator).to receive(:copy_with_path).with(list.first).once }
101
- end
102
- context 'when source_file missing' do
103
- before { allow(File).to receive(:exist?).with(source_path) { false } }
104
- it { expect(generator).to receive(:puts_error).with("File '/example_path/example.txt' was not found.").once }
105
- end
106
- end
107
-
108
- describe '#copy_templates' do
109
- let(:list) { [{ source: 'example.txt.erb', destination: 'example.txt' }] }
110
- let(:source_path) { '/example_path/example.txt.erb' }
111
- let(:destination_path) { '/example_path/example.txt' }
112
- let(:generator) { described_class.new('rspec' => true) }
113
- subject { generator.send(:copy_templates, list) }
114
- before do
115
- allow_any_instance_of(described_class).to receive(:print_banner) { nil }
116
- allow(generator).to receive(:source_path).with(list.first[:source]) { source_path }
117
- allow(generator).to receive(:dest_path).with(list.first[:destination]) { destination_path }
118
- allow(generator).to receive(:write_template).with(destination_path, source_path)
119
- allow(generator).to receive(:gets) { 'h' }
120
- end
121
- after { subject }
122
- context 'when destination file exists' do
123
- before { allow(File).to receive(:exist?).with(destination_path) { true } }
124
- it do
125
- expect(generator).to receive(:puts_info).with(
126
- ColorizedString.new("Conflict with '#{list.first[:destination]}' template").yellow
127
- ).once
128
- end
129
- it do
130
- expect(generator).to receive(:print_info).with(
131
- ColorizedString.new(" Overwrite '#{list.first[:destination]}' template? [Yn]:").yellow
132
- ).once
133
- end
134
- context 'and answer is yes' do
135
- before { allow(generator).to receive(:gets) { 'y' } }
136
- it { expect(generator).to receive(:write_template).with(destination_path, source_path).once }
137
- it { expect(generator).to receive(:puts_info).twice }
138
- end
139
- context 'and answer is no' do
140
- before { allow(generator).to receive(:gets) { 'n' } }
141
- it { expect(generator).to receive(:puts_info).twice }
142
- end
143
- end
144
- context 'when source file exists' do
145
- before { allow(File).to receive(:exist?).with(destination_path) { false } }
146
- it { expect(generator).to receive(:write_template).with(destination_path, source_path).once }
147
- end
148
- end
149
-
150
- describe '#print_banner' do
151
- let(:generator) { described_class.new({}) }
152
- subject { generator.send(:print_banner) }
153
- before do
154
- allow_any_instance_of(described_class).to receive(:banner) { banner }
155
- end
156
- after { subject }
157
- context 'when banner present' do
158
- let(:banner) { 'banner' }
159
- it { expect(described_class.logger).to receive(:puts).with(ColorizedString.new(banner.chomp).light_cyan).twice }
160
- end
161
- context 'when banner blank' do
162
- let(:banner) { '' }
163
- it { expect(described_class.logger).not_to receive(:puts) }
164
- end
165
- end
166
-
167
- describe '#print_info' do
168
- subject { described_class.new({}).send(:print_info, 'data') }
169
- before { allow_any_instance_of(described_class).to receive(:print_banner) { nil } }
170
- after { subject }
171
- it { expect(described_class.logger).to receive(:print).with(' data') }
172
- end
173
-
174
- describe '#puts_info' do
175
- subject { described_class.new({}).send(:puts_info, 'data') }
176
- before { allow_any_instance_of(described_class).to receive(:print_banner) { nil } }
177
- after { subject }
178
- it { expect(described_class.logger).to receive(:puts).with(' data') }
179
- end
180
-
181
- describe '#puts_error' do
182
- subject { described_class.new({}).send(:puts_error, 'data') }
183
- before { allow_any_instance_of(described_class).to receive(:print_banner) { nil } }
184
- after { subject }
185
- it { expect(described_class.logger).to receive(:puts).with(ColorizedString.new(' ERROR: data').red) }
186
- end
187
-
188
- describe '#source_path' do
189
- subject { described_class.new({}).send(:source_path, 'example.txt') }
190
- before do
191
- allow_any_instance_of(described_class).to receive(:print_banner) { nil }
192
- end
193
- it { is_expected.to include('/base/templates/example.txt') }
194
- end
195
-
196
- describe '#dest_path' do
197
- subject { described_class.new({}).send(:dest_path, 'example.txt') }
198
- before { allow_any_instance_of(described_class).to receive(:print_banner) { nil } }
199
- it { is_expected.to include('/example.txt') }
200
- end
201
-
202
- describe '#copy_with_path' do
203
- let(:generator) { described_class.new({}) }
204
- let(:data) { { source: 's.txt', destination: 'd.txt' } }
205
- let(:src) { '/path/to/s.txt' }
206
- let(:dst) { '/path/to/d.txt' }
207
- subject { generator.send(:copy_with_path, data) }
208
- before do
209
- allow_any_instance_of(described_class).to receive(:print_banner) { nil }
210
- allow(generator).to receive(:source_path).with('s.txt') { src }
211
- allow(generator).to receive(:dest_path).with('d.txt') { dst }
212
- allow(FileUtils).to receive(:mkdir_p).with('/path/to') { true }
213
- end
214
- after { subject }
215
- context 'when destination file present' do
216
- before { allow(File).to receive(:exist?).with(dst) { true } }
217
- context 'when identical with source file' do
218
- before { allow(FileUtils).to receive(:identical?).with(src, dst) { true } }
219
- it do
220
- expect(generator).to receive(:puts_info).with("#{ColorizedString.new('Identical').light_green}"\
221
- " 'd.txt' file").once
222
- end
223
- end
224
- context 'when not identical with source file' do
225
- before do
226
- allow(FileUtils).to receive(:identical?).with(src, dst) { false }
227
- expect(generator).to receive(:puts_info).with(ColorizedString.new("Conflict with 'd.txt' file").yellow)
228
- expect(generator).to receive(:print_info).with(ColorizedString.new(" Overwrite 'd.txt' file? [Yn]:").yellow)
229
- end
230
- context 'when user typed Y' do
231
- before { allow(generator).to receive(:gets) { 'Y' } }
232
- it do
233
- expect(FileUtils).to receive(:cp).with(src, dst) { nil }.once
234
- expect(generator).to receive(:puts_info).with(" #{ColorizedString.new('Forced').light_green}"\
235
- " 'd.txt' file")
236
- end
237
- end
238
- context 'when user typed y' do
239
- before { allow(generator).to receive(:gets) { 'y' } }
240
- it do
241
- expect(FileUtils).to receive(:cp).with(src, dst) { nil }.once
242
- expect(generator).to receive(:puts_info).with(" #{ColorizedString.new('Forced').light_green}"\
243
- " 'd.txt' file")
244
- end
245
- end
246
- context 'when user typed N' do
247
- before { allow(generator).to receive(:gets) { 'N' } }
248
- it do
249
- expect(generator).to receive(:puts_info).with(" #{ColorizedString.new('Skipped').light_black}"\
250
- " 'd.txt' file")
251
- expect(FileUtils).not_to receive(:cp)
252
- end
253
- end
254
- context 'when user typed n' do
255
- before { allow(generator).to receive(:gets) { 'n' } }
256
- it do
257
- expect(generator).to receive(:puts_info).with(" #{ColorizedString.new('Skipped').light_black}"\
258
- " 'd.txt' file")
259
- expect(FileUtils).not_to receive(:cp)
260
- end
261
- end
262
- context 'when user typed hello' do
263
- before { allow(generator).to receive(:gets) { 'hello' } }
264
- it do
265
- expect(generator).not_to receive(:puts_info)
266
- expect(FileUtils).not_to receive(:cp)
267
- end
268
- end
269
- end
270
- end
271
- context 'when destination file missing' do
272
- before { allow(File).to receive(:exist?).with(dst) { false } }
273
- it do
274
- expect(generator).to receive(:puts_info).with("#{ColorizedString.new('Added').light_green} 'd.txt' file")
275
- expect(FileUtils).to receive(:cp).with(src, dst).once
276
- end
277
- end
278
- context 'when exception happened' do
279
- before { allow(FileUtils).to receive(:mkdir_p).and_raise(StandardError.new('Some error')) }
280
- it { expect(generator).to receive(:puts_error).with("Impossible to create 'd.txt' file. Reason: Some error") }
281
- end
282
- end
283
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe 'Generators' do
4
- let(:destination) { Howitzer::BaseGenerator.destination }
5
- let(:output) { StringIO.new }
6
- subject { file_tree_info(destination) }
7
- before do
8
- Howitzer::BaseGenerator.logger = output
9
- generator_name.new({})
10
- end
11
- after { FileUtils.rm_r(destination) }
12
-
13
- describe Howitzer::ConfigGenerator do
14
- let(:generator_name) { described_class }
15
- let(:expected_result) do
16
- [
17
- { name: '/config', is_directory: true },
18
- { name: '/config/boot.rb', is_directory: false, size: template_file_size('config', 'boot.rb') },
19
- { name: '/config/capybara.rb', is_directory: false, size: template_file_size('config', 'capybara.rb') },
20
- { name: '/config/custom.yml', is_directory: false, size: template_file_size('config', 'custom.yml') },
21
- { name: '/config/default.yml', is_directory: false, size: template_file_size('config', 'default.yml') },
22
- { name: '/config/drivers', is_directory: true },
23
- { name: '/config/drivers/appium.rb', is_directory: false, size: 723 },
24
- { name: '/config/drivers/browserstack.rb', is_directory: false, size: 1018 },
25
- { name: '/config/drivers/crossbrowsertesting.rb', is_directory: false, size: 1237 },
26
- { name: '/config/drivers/headless_chrome.rb', is_directory: false, size: 649 },
27
- { name: '/config/drivers/headless_firefox.rb', is_directory: false, size: 1059 },
28
- { name: '/config/drivers/poltergeist.rb', is_directory: false, size: 362 },
29
- { name: '/config/drivers/sauce.rb', is_directory: false, size: 968 },
30
- { name: '/config/drivers/selenium.rb', is_directory: false, size: 1097 },
31
- { name: '/config/drivers/selenium_grid.rb', is_directory: false, size: 1377 },
32
- { name: '/config/drivers/testingbot.rb', is_directory: false, size: 906 },
33
- { name: '/config/drivers/webkit.rb', is_directory: false, size: 179 }
34
- ]
35
- end
36
-
37
- it { is_expected.to eql(expected_result) }
38
- describe 'output' do
39
- let(:expected_output) do
40
- "#{ColorizedString.new(' * Config files generation ...').light_cyan}
41
- #{ColorizedString.new('Added').light_green} 'config/boot.rb' file
42
- #{ColorizedString.new('Added').light_green} 'config/custom.yml' file
43
- #{ColorizedString.new('Added').light_green} 'config/capybara.rb' file
44
- #{ColorizedString.new('Added').light_green} 'config/default.yml' file
45
- #{ColorizedString.new('Added').light_green} 'config/drivers/appium.rb' file
46
- #{ColorizedString.new('Added').light_green} 'config/drivers/browserstack.rb' file
47
- #{ColorizedString.new('Added').light_green} 'config/drivers/crossbrowsertesting.rb' file
48
- #{ColorizedString.new('Added').light_green} 'config/drivers/headless_chrome.rb' file
49
- #{ColorizedString.new('Added').light_green} 'config/drivers/headless_firefox.rb' file
50
- #{ColorizedString.new('Added').light_green} 'config/drivers/poltergeist.rb' file
51
- #{ColorizedString.new('Added').light_green} 'config/drivers/sauce.rb' file
52
- #{ColorizedString.new('Added').light_green} 'config/drivers/selenium.rb' file
53
- #{ColorizedString.new('Added').light_green} 'config/drivers/selenium_grid.rb' file
54
- #{ColorizedString.new('Added').light_green} 'config/drivers/testingbot.rb' file
55
- #{ColorizedString.new('Added').light_green} 'config/drivers/webkit.rb' file\n"
56
- end
57
- subject { output.string }
58
- it { is_expected.to eql(expected_output) }
59
- end
60
- end
61
- end
@@ -1,62 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe 'Generators' do
4
- let(:destination) { Howitzer::BaseGenerator.destination }
5
- let(:output) { StringIO.new }
6
- subject { file_tree_info(destination) }
7
- before do
8
- Howitzer::BaseGenerator.logger = output
9
- generator_name.new(cucumber: true)
10
- end
11
- after { FileUtils.rm_r(destination) }
12
-
13
- describe Howitzer::CucumberGenerator do
14
- let(:generator_name) { described_class }
15
- let(:expected_result) do
16
- [
17
- { name: '/features', is_directory: true },
18
- {
19
- name: '/features/example.feature',
20
- is_directory: false,
21
- size: template_file_size('cucumber', 'example.feature')
22
- },
23
- { name: '/features/step_definitions', is_directory: true },
24
- {
25
- name: '/features/step_definitions/common_steps.rb',
26
- is_directory: false,
27
- size: template_file_size('cucumber', 'common_steps.rb')
28
- },
29
- { name: '/features/support', is_directory: true },
30
- { name: '/features/support/env.rb', is_directory: false, size: template_file_size('cucumber', 'env.rb') },
31
- { name: '/features/support/hooks.rb', is_directory: false, size: template_file_size('cucumber', 'hooks.rb') },
32
- {
33
- name: '/features/support/transformers.rb',
34
- is_directory: false,
35
- size: template_file_size('cucumber', 'transformers.rb')
36
- },
37
- { name: '/tasks', is_directory: true },
38
- { name: '/tasks/cucumber.rake', is_directory: false, size: template_file_size('cucumber', 'cucumber.rake') },
39
- {
40
- name: '/tasks/cuke_sniffer.rake',
41
- is_directory: false,
42
- size: template_file_size('cucumber', 'cuke_sniffer.rake')
43
- }
44
- ]
45
- end
46
- it { is_expected.to eql(expected_result) }
47
- describe 'output' do
48
- let(:expected_output) do
49
- "#{ColorizedString.new(' * Cucumber integration to the framework ...').light_cyan}
50
- #{ColorizedString.new('Added').light_green} 'features/step_definitions/common_steps.rb' file
51
- #{ColorizedString.new('Added').light_green} 'features/support/env.rb' file
52
- #{ColorizedString.new('Added').light_green} 'features/support/hooks.rb' file
53
- #{ColorizedString.new('Added').light_green} 'features/support/transformers.rb' file
54
- #{ColorizedString.new('Added').light_green} 'features/example.feature' file
55
- #{ColorizedString.new('Added').light_green} 'tasks/cucumber.rake' file
56
- #{ColorizedString.new('Added').light_green} 'tasks/cuke_sniffer.rake' file\n"
57
- end
58
- subject { output.string }
59
- it { is_expected.to eql(expected_output) }
60
- end
61
- end
62
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe 'Generators' do
4
- let(:destination) { Howitzer::BaseGenerator.destination }
5
- let(:output) { StringIO.new }
6
- subject { file_tree_info(destination) }
7
- before do
8
- Howitzer::BaseGenerator.logger = output
9
- generator_name.new({})
10
- end
11
- after { FileUtils.rm_r(destination) }
12
-
13
- describe Howitzer::EmailsGenerator do
14
- let(:generator_name) { described_class }
15
- let(:expected_result) do
16
- [
17
- { name: '/emails', is_directory: true },
18
- {
19
- name: '/emails/example_email.rb',
20
- is_directory: false,
21
- size: template_file_size('emails', 'example_email.rb')
22
- }
23
- ]
24
- end
25
- it { is_expected.to eql(expected_result) }
26
- describe 'output' do
27
- let(:expected_output) do
28
- "#{ColorizedString.new(' * Email example generation ...').light_cyan}
29
- #{ColorizedString.new('Added').light_green} '/emails/example_email.rb' file\n"
30
- end
31
- subject { output.string }
32
- it { is_expected.to eql(expected_output) }
33
- end
34
- end
35
- end
@@ -1,53 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe 'Generators' do
4
- let(:destination) { Howitzer::BaseGenerator.destination }
5
- let(:output) { StringIO.new }
6
- subject { file_tree_info(destination) }
7
- before do
8
- Howitzer::BaseGenerator.logger = output
9
- generator_name.new({})
10
- end
11
- after { FileUtils.rm_r(destination) }
12
-
13
- describe Howitzer::PrerequisitesGenerator do
14
- let(:generator_name) { described_class }
15
- let(:expected_result) do
16
- [
17
- { name: '/prerequisites', is_directory: true },
18
- { name: '/prerequisites/factories', is_directory: true },
19
- {
20
- name: '/prerequisites/factories/users.rb',
21
- is_directory: false, size: template_file_size('prerequisites', 'users.rb')
22
- },
23
- {
24
- name: '/prerequisites/factory_bot.rb',
25
- is_directory: false, size: template_file_size('prerequisites', 'factory_bot.rb')
26
- },
27
- { name: '/prerequisites/models', is_directory: true },
28
- {
29
- name: '/prerequisites/models/base.rb',
30
- is_directory: false,
31
- size: template_file_size('prerequisites', 'base.rb')
32
- },
33
- {
34
- name: '/prerequisites/models/user.rb',
35
- is_directory: false,
36
- size: template_file_size('prerequisites', 'user.rb')
37
- }
38
- ]
39
- end
40
- it { is_expected.to eql(expected_result) }
41
- describe 'output' do
42
- let(:expected_output) do
43
- "#{ColorizedString.new(' * Pre-requisites integration to the framework ...').light_cyan}
44
- #{ColorizedString.new('Added').light_green} 'prerequisites/factory_bot.rb' file
45
- #{ColorizedString.new('Added').light_green} 'prerequisites/factories/users.rb' file
46
- #{ColorizedString.new('Added').light_green} 'prerequisites/models/base.rb' file
47
- #{ColorizedString.new('Added').light_green} 'prerequisites/models/user.rb' file\n"
48
- end
49
- subject { output.string }
50
- it { is_expected.to eql(expected_output) }
51
- end
52
- end
53
- end
@@ -1,86 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe 'Generators' do
4
- let(:destination) { Howitzer::BaseGenerator.destination }
5
- let(:output) { StringIO.new }
6
- subject { file_tree_info(destination) }
7
- before do
8
- Howitzer::BaseGenerator.logger = output
9
- generator_name.new(options)
10
- end
11
- after { FileUtils.rm_r(destination) }
12
-
13
- describe Howitzer::RootGenerator do
14
- let(:generator_name) { described_class }
15
- let(:expected_result) do
16
- [
17
- { name: '/.gitignore', is_directory: false, size: 196 },
18
- { name: '/.rubocop.yml', is_directory: false, size: 616 },
19
- { name: '/Gemfile', is_directory: false, size: 811 },
20
- { name: '/Rakefile', is_directory: false, size: template_file_size('root', 'Rakefile') }
21
- ]
22
- end
23
- let(:options) { {} }
24
-
25
- it { is_expected.to eql(expected_result) }
26
-
27
- describe 'output' do
28
- subject { output.string }
29
-
30
- context 'when options is empty' do
31
- let(:expected_output) do
32
- added_text = ColorizedString.new('Added').light_green
33
- "#{ColorizedString.new(' * Root files generation ...').light_cyan}
34
- #{added_text} '.gitignore' file
35
- #{added_text} 'Rakefile' file
36
- #{added_text} template '.rubocop.yml.erb' with params '{}' to destination '.rubocop.yml'
37
- #{added_text} template 'Gemfile.erb' with params '{}' to destination 'Gemfile'\n"
38
- end
39
-
40
- it { is_expected.to eql(expected_output) }
41
- end
42
-
43
- context 'when options is rspec => true' do
44
- let(:expected_output) do
45
- added_text = ColorizedString.new('Added').light_green
46
- "#{ColorizedString.new(' * Root files generation ...').light_cyan}
47
- #{added_text} '.gitignore' file
48
- #{added_text} 'Rakefile' file
49
- #{added_text} template '.rubocop.yml.erb' with params '{:rspec=>true}' to destination '.rubocop.yml'
50
- #{added_text} template 'Gemfile.erb' with params '{:rspec=>true}' to destination 'Gemfile'\n"
51
- end
52
- let(:options) { { rspec: true } }
53
-
54
- it { is_expected.to eql(expected_output) }
55
- end
56
-
57
- context 'when options is cucumber => cucumber' do
58
- let(:expected_output) do
59
- added_text = ColorizedString.new('Added').light_green
60
- "#{ColorizedString.new(' * Root files generation ...').light_cyan}
61
- #{added_text} '.gitignore' file
62
- #{added_text} 'Rakefile' file
63
- #{added_text} template '.rubocop.yml.erb' with params '{:cucumber=>true}' to destination '.rubocop.yml'
64
- #{added_text} template 'Gemfile.erb' with params '{:cucumber=>true}' to destination 'Gemfile'\n"
65
- end
66
- let(:options) { { cucumber: true } }
67
-
68
- it { is_expected.to eql(expected_output) }
69
- end
70
-
71
- context 'when options is turnip => true' do
72
- let(:expected_output) do
73
- added_text = ColorizedString.new('Added').light_green
74
- "#{ColorizedString.new(' * Root files generation ...').light_cyan}
75
- #{added_text} '.gitignore' file
76
- #{added_text} 'Rakefile' file
77
- #{added_text} template '.rubocop.yml.erb' with params '{:turnip=>true}' to destination '.rubocop.yml'
78
- #{added_text} template 'Gemfile.erb' with params '{:turnip=>true}' to destination 'Gemfile'\n"
79
- end
80
- let(:options) { { turnip: true } }
81
-
82
- it { is_expected.to eql(expected_output) }
83
- end
84
- end
85
- end
86
- end
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe 'Generators' do
4
- let(:destination) { Howitzer::BaseGenerator.destination }
5
- let(:output) { StringIO.new }
6
- subject { file_tree_info(destination) }
7
- before do
8
- Howitzer::BaseGenerator.logger = output
9
- generator_name.new(rspec: true)
10
- end
11
- after { FileUtils.rm_r(destination) }
12
-
13
- describe Howitzer::RspecGenerator do
14
- let(:generator_name) { described_class }
15
- let(:expected_result) do
16
- [
17
- { name: '/spec', is_directory: true },
18
- { name: '/spec/example_spec.rb', is_directory: false, size: template_file_size('rspec', 'example_spec.rb') },
19
- { name: '/spec/spec_helper.rb', is_directory: false, size: template_file_size('rspec', 'spec_helper.rb') },
20
- { name: '/tasks', is_directory: true },
21
- { name: '/tasks/rspec.rake', is_directory: false, size: template_file_size('rspec', 'rspec.rake') }
22
- ]
23
- end
24
- it { is_expected.to eql(expected_result) }
25
- describe 'output' do
26
- let(:expected_output) do
27
- "#{ColorizedString.new(' * RSpec integration to the framework ...').light_cyan}
28
- #{ColorizedString.new('Added').light_green} 'spec/spec_helper.rb' file
29
- #{ColorizedString.new('Added').light_green} 'spec/example_spec.rb' file
30
- #{ColorizedString.new('Added').light_green} 'tasks/rspec.rake' file\n"
31
- end
32
- subject { output.string }
33
- it { is_expected.to eql(expected_output) }
34
- end
35
- end
36
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe 'Generators' do
4
- let(:destination) { Howitzer::BaseGenerator.destination }
5
- let(:output) { StringIO.new }
6
- subject { file_tree_info(destination) }
7
- before do
8
- Howitzer::BaseGenerator.logger = output
9
- generator_name.new({})
10
- end
11
- after { FileUtils.rm_r(destination) }
12
-
13
- describe Howitzer::TasksGenerator do
14
- let(:generator_name) { described_class }
15
- let(:expected_result) do
16
- [
17
- { name: '/tasks', is_directory: true },
18
- { name: '/tasks/common.rake', is_directory: false, size: template_file_size('tasks', 'common.rake') }
19
- ]
20
- end
21
- it { is_expected.to eql(expected_result) }
22
- describe 'output' do
23
- let(:expected_output) do
24
- "#{ColorizedString.new(' * Base rake task generation ...').light_cyan}
25
- #{ColorizedString.new('Added').light_green} 'tasks/common.rake' file\n"
26
- end
27
- subject { output.string }
28
- it { is_expected.to eql(expected_output) }
29
- end
30
- end
31
- end