howitzer 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +32 -0
  4. data/.travis.yml +1 -4
  5. data/.yardopts +1 -2
  6. data/CHANGELOG.md +28 -1
  7. data/Gemfile +6 -0
  8. data/LICENSE +1 -1
  9. data/README.md +55 -85
  10. data/Rakefile +7 -7
  11. data/bin/howitzer +56 -31
  12. data/features/cli_new.feature +162 -79
  13. data/features/cli_update.feature +114 -21
  14. data/features/step_definitions/common_steps.rb +29 -9
  15. data/features/support/env.rb +1 -1
  16. data/features/support/transformers.rb +2 -2
  17. data/generators/base_generator.rb +121 -49
  18. data/generators/config/config_generator.rb +8 -5
  19. data/generators/config/templates/boot.rb +14 -0
  20. data/generators/config/templates/capybara.rb +156 -0
  21. data/generators/config/templates/custom.yml +2 -3
  22. data/generators/config/templates/default.yml +50 -82
  23. data/generators/cucumber/cucumber_generator.rb +9 -9
  24. data/generators/cucumber/templates/common_steps.rb +4 -4
  25. data/generators/cucumber/templates/cucumber.rake +63 -54
  26. data/generators/cucumber/templates/env.rb +24 -23
  27. data/generators/cucumber/templates/transformers.rb +23 -15
  28. data/generators/emails/emails_generator.rb +4 -2
  29. data/generators/emails/templates/example_email.rb +4 -4
  30. data/generators/prerequisites/prerequisites_generator.rb +24 -0
  31. data/generators/prerequisites/templates/base.rb +22 -0
  32. data/generators/prerequisites/templates/factory_girl.rb +30 -0
  33. data/generators/prerequisites/templates/user.rb +7 -0
  34. data/generators/prerequisites/templates/users.rb +12 -0
  35. data/generators/root/root_generator.rb +11 -7
  36. data/generators/root/templates/.rubocop.yml +32 -0
  37. data/generators/root/templates/Gemfile.erb +27 -0
  38. data/generators/root/templates/Rakefile +6 -8
  39. data/generators/rspec/rspec_generator.rb +7 -7
  40. data/generators/rspec/templates/example_spec.rb +1 -1
  41. data/generators/rspec/templates/rspec.rake +48 -29
  42. data/generators/rspec/templates/spec_helper.rb +33 -32
  43. data/generators/tasks/tasks_generator.rb +4 -2
  44. data/generators/tasks/templates/common.rake +1 -16
  45. data/generators/turnip/templates/.rspec +1 -0
  46. data/generators/turnip/templates/common_steps.rb +25 -0
  47. data/generators/turnip/templates/example.feature +8 -0
  48. data/generators/turnip/templates/spec_helper.rb +56 -0
  49. data/generators/turnip/templates/turnip.rake +61 -0
  50. data/generators/turnip/templates/turnip_helper.rb +6 -0
  51. data/generators/turnip/turnip_generator.rb +26 -0
  52. data/generators/web/templates/example_page.rb +15 -0
  53. data/generators/web/templates/menu_section.rb +13 -0
  54. data/generators/web/web_generator.rb +22 -0
  55. data/howitzer.gemspec +14 -21
  56. data/lib/howitzer.rb +47 -7
  57. data/lib/howitzer/cache.rb +70 -0
  58. data/lib/howitzer/capybara_helpers.rb +194 -0
  59. data/lib/howitzer/email.rb +96 -104
  60. data/lib/howitzer/exceptions.rb +10 -6
  61. data/lib/howitzer/log.rb +120 -0
  62. data/lib/howitzer/mail_adapters.rb +7 -0
  63. data/lib/howitzer/mail_adapters/abstract.rb +84 -0
  64. data/lib/howitzer/mail_adapters/mailgun.rb +115 -0
  65. data/lib/howitzer/mailgun_api.rb +9 -0
  66. data/lib/howitzer/mailgun_api/client.rb +79 -0
  67. data/lib/howitzer/mailgun_api/connector.rb +37 -0
  68. data/lib/howitzer/mailgun_api/response.rb +28 -0
  69. data/lib/howitzer/tasks/framework.rake +2 -2
  70. data/lib/howitzer/utils.rb +7 -1
  71. data/lib/howitzer/utils/string_extensions.rb +66 -0
  72. data/lib/howitzer/version.rb +2 -1
  73. data/lib/howitzer/web.rb +11 -0
  74. data/lib/howitzer/web/base_section.rb +27 -0
  75. data/lib/howitzer/web/blank_page.rb +12 -0
  76. data/lib/howitzer/web/capybara_methods_proxy.rb +29 -0
  77. data/lib/howitzer/web/element_dsl.rb +109 -0
  78. data/lib/howitzer/web/iframe_dsl.rb +93 -0
  79. data/lib/howitzer/web/page.rb +173 -0
  80. data/lib/howitzer/web/page_dsl.rb +64 -0
  81. data/lib/howitzer/web/page_validator.rb +118 -0
  82. data/lib/howitzer/web/section.rb +27 -0
  83. data/lib/howitzer/web/section_dsl.rb +154 -0
  84. data/spec/config/custom.yml +10 -1
  85. data/spec/spec_helper.rb +37 -19
  86. data/spec/support/generator_helper.rb +12 -11
  87. data/spec/support/logger_helper.rb +10 -9
  88. data/spec/support/mailgun_unit_client.rb +52 -44
  89. data/spec/support/shared_examples/capybara_context_holder.rb +33 -0
  90. data/spec/support/shared_examples/capybara_methods_proxy.rb +94 -0
  91. data/spec/support/shared_examples/dynamic_section_methods.rb +35 -0
  92. data/spec/support/shared_examples/element_dsl.rb +119 -0
  93. data/spec/unit/generators/base_generator_spec.rb +64 -33
  94. data/spec/unit/generators/config_generator_spec.rb +11 -7
  95. data/spec/unit/generators/cucumber_generator_spec.rb +26 -17
  96. data/spec/unit/generators/emails_generator_spec.rb +10 -6
  97. data/spec/unit/generators/prerequisites_generator_spec.rb +53 -0
  98. data/spec/unit/generators/root_generator_spec.rb +50 -13
  99. data/spec/unit/generators/rspec_generator_spec.rb +9 -9
  100. data/spec/unit/generators/tasks_generator_spec.rb +6 -6
  101. data/spec/unit/generators/turnip_generator_spec.rb +52 -0
  102. data/spec/unit/generators/web_generator_spec.rb +52 -0
  103. data/spec/unit/lib/cache_spec.rb +85 -0
  104. data/spec/unit/lib/capybara_helpers_spec.rb +696 -0
  105. data/spec/unit/lib/email_spec.rb +104 -91
  106. data/spec/unit/lib/howitzer.rb +31 -0
  107. data/spec/unit/lib/init_spec.rb +0 -1
  108. data/spec/unit/lib/log_spec.rb +122 -0
  109. data/spec/unit/lib/mail_adapters/abstract_spec.rb +62 -0
  110. data/spec/unit/lib/mail_adapters/mailgun_spec.rb +163 -0
  111. data/spec/unit/lib/mailgun_api/client_spec.rb +58 -0
  112. data/spec/unit/lib/mailgun_api/connector_spec.rb +54 -0
  113. data/spec/unit/lib/mailgun_api/response_spec.rb +28 -0
  114. data/spec/unit/lib/utils/string_extensions_spec.rb +77 -0
  115. data/spec/unit/lib/web/base_section_spec.rb +41 -0
  116. data/spec/unit/lib/web/element_dsl_spec.rb +17 -0
  117. data/spec/unit/lib/web/iframe_dsl_spec.rb +99 -0
  118. data/spec/unit/lib/web/page_dsl_spec.rb +52 -0
  119. data/spec/unit/lib/web/page_spec.rb +304 -0
  120. data/spec/unit/lib/web/page_validator_spec.rb +218 -0
  121. data/spec/unit/lib/web/section_dsl_spec.rb +165 -0
  122. data/spec/unit/lib/web/section_spec.rb +61 -0
  123. data/spec/unit/version_spec.rb +1 -1
  124. metadata +116 -203
  125. data/GETTING_STARTED.md +0 -774
  126. data/generators/cucumber/templates/cucumber.yml +0 -10
  127. data/generators/pages/pages_generator.rb +0 -21
  128. data/generators/pages/templates/example_menu.rb +0 -15
  129. data/generators/pages/templates/example_page.rb +0 -15
  130. data/generators/root/templates/Gemfile +0 -7
  131. data/generators/root/templates/boot.rb +0 -10
  132. data/lib/howitzer/blank_page.rb +0 -6
  133. data/lib/howitzer/capybara/dsl_ex.rb +0 -15
  134. data/lib/howitzer/capybara/settings.rb +0 -343
  135. data/lib/howitzer/helpers.rb +0 -230
  136. data/lib/howitzer/init.rb +0 -1
  137. data/lib/howitzer/mailgun/client.rb +0 -65
  138. data/lib/howitzer/mailgun/connector.rb +0 -34
  139. data/lib/howitzer/mailgun/response.rb +0 -28
  140. data/lib/howitzer/patches/rawler_patched.rb +0 -86
  141. data/lib/howitzer/settings.rb +0 -27
  142. data/lib/howitzer/utils/data_generator/data_storage.rb +0 -88
  143. data/lib/howitzer/utils/data_generator/gen.rb +0 -135
  144. data/lib/howitzer/utils/locator_store.rb +0 -217
  145. data/lib/howitzer/utils/log.rb +0 -139
  146. data/lib/howitzer/utils/page_validator.rb +0 -133
  147. data/lib/howitzer/vendor/firebug-1.12.1-fx.xpi +0 -0
  148. data/lib/howitzer/vendor/firepath-0.9.7-fx.xpi +0 -0
  149. data/lib/howitzer/web_page.rb +0 -253
  150. data/spec/active_resource.rb +0 -0
  151. data/spec/config/default.yml +0 -26
  152. data/spec/support/boot_helper.rb +0 -15
  153. data/spec/unit/generators/pages_generator_spec.rb +0 -33
  154. data/spec/unit/lib/capybara/dsl_ex_spec.rb +0 -60
  155. data/spec/unit/lib/capybara/settings_spec.rb +0 -441
  156. data/spec/unit/lib/helpers_spec.rb +0 -1129
  157. data/spec/unit/lib/mailgun/client_spec.rb +0 -36
  158. data/spec/unit/lib/mailgun/connector_spec.rb +0 -70
  159. data/spec/unit/lib/mailgun/response_spec.rb +0 -28
  160. data/spec/unit/lib/settings_spec.rb +0 -17
  161. data/spec/unit/lib/utils/data_generator/data_storage_spec.rb +0 -80
  162. data/spec/unit/lib/utils/data_generator/gen_spec.rb +0 -90
  163. data/spec/unit/lib/utils/locator_store_spec.rb +0 -157
  164. data/spec/unit/lib/utils/log_spec.rb +0 -107
  165. data/spec/unit/lib/utils/page_validator_spec.rb +0 -265
  166. data/spec/unit/lib/web_page_spec.rb +0 -346
@@ -31,7 +31,8 @@ RSpec.describe Howitzer::BaseGenerator do
31
31
  describe 'constructor' do
32
32
  let(:list1) { double(:list1) }
33
33
  let(:list2) { double(:list2) }
34
- subject { described_class.new }
34
+ let(:options) { { r: true, rspec: true } }
35
+ subject { described_class.new(options) }
35
36
  before do
36
37
  expect_any_instance_of(described_class).to receive(:print_banner).with(no_args).once
37
38
  allow_any_instance_of(described_class).to receive(:manifest) do
@@ -45,24 +46,24 @@ RSpec.describe Howitzer::BaseGenerator do
45
46
  it do
46
47
  expect_any_instance_of(described_class).to receive(:copy_files).with(list1).once
47
48
  expect_any_instance_of(described_class).to receive(:copy_templates).with(list2).once
48
- subject
49
+ expect(subject.instance_variable_get(:@options)).to eql options
49
50
  end
50
51
  end
51
52
 
52
53
  describe '#manifest' do
53
- subject { described_class.new.manifest }
54
+ subject { described_class.new({}).manifest }
54
55
  before { allow_any_instance_of(described_class).to receive(:initialize) { nil } }
55
56
  it { is_expected.to be_nil }
56
57
  end
57
58
 
58
59
  describe '#banner' do
59
- subject { described_class.new.send(:banner) }
60
+ subject { described_class.new({}).send(:banner) }
60
61
  before { allow_any_instance_of(described_class).to receive(:initialize) { nil } }
61
62
  it { is_expected.to be_nil }
62
63
  end
63
64
 
64
65
  describe '#logger' do
65
- subject { described_class.new.send(:logger) }
66
+ subject { described_class.new({}).send(:logger) }
66
67
  before { allow_any_instance_of(described_class).to receive(:initialize) { nil } }
67
68
  context 'when not specified' do
68
69
  before { described_class.instance_variable_set('@logger', nil) }
@@ -76,7 +77,7 @@ RSpec.describe Howitzer::BaseGenerator do
76
77
  end
77
78
 
78
79
  describe '#destination' do
79
- subject { described_class.new.send(:destination) }
80
+ subject { described_class.new({}).send(:destination) }
80
81
  before do
81
82
  allow_any_instance_of(described_class).to receive(:initialize) { nil }
82
83
  allow(described_class).to receive(:destination) { '/' }
@@ -85,9 +86,9 @@ RSpec.describe Howitzer::BaseGenerator do
85
86
  end
86
87
 
87
88
  describe '#copy_files' do
88
- let(:list) { [ {source: 'example.txt'} ] }
89
+ let(:list) { [{ source: 'example.txt' }] }
89
90
  let(:source_path) { '/example_path/example.txt' }
90
- let(:generator) { described_class.new }
91
+ let(:generator) { described_class.new({}) }
91
92
  subject { generator.send(:copy_files, list) }
92
93
  before do
93
94
  allow_any_instance_of(described_class).to receive(:initialize) { nil }
@@ -95,23 +96,55 @@ RSpec.describe Howitzer::BaseGenerator do
95
96
  end
96
97
  after { subject }
97
98
  context 'when source_file exists' do
98
- before { allow(File).to receive(:exists?).with(source_path) { true } }
99
+ before { allow(File).to receive(:exist?).with(source_path) { true } }
99
100
  it { expect(generator).to receive(:copy_with_path).with(list.first).once }
100
101
  end
101
102
  context 'when source_file missing' do
102
- before { allow(File).to receive(:exists?).with(source_path) { false } }
103
+ before { allow(File).to receive(:exist?).with(source_path) { false } }
103
104
  it { expect(generator).to receive(:puts_error).with("File '/example_path/example.txt' was not found.").once }
104
105
  end
105
106
  end
106
107
 
107
108
  describe '#copy_templates' do
108
- subject { described_class.new.send(:copy_templates, nil) }
109
- before { allow_any_instance_of(described_class).to receive(:initialize) { nil } }
110
- it { is_expected.to be_nil }
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(:initialize) { 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 { expect(generator).to receive(:puts_info).with("Conflict with '#{list.first[:destination]}' template").once }
125
+ it do
126
+ expect(generator).to receive(:print_info).with(
127
+ " Overwrite '#{list.first[:destination]}' template? [Yn]:"
128
+ ).once
129
+ end
130
+ context 'and answer is yes' do
131
+ before { allow(generator).to receive(:gets) { 'y' } }
132
+ it { expect(generator).to receive(:write_template).with(destination_path, source_path).once }
133
+ it { expect(generator).to receive(:puts_info).twice }
134
+ end
135
+ context 'and answer is no' do
136
+ before { allow(generator).to receive(:gets) { 'n' } }
137
+ it { expect(generator).to receive(:puts_info).twice }
138
+ end
139
+ end
140
+ context 'when source file exists' do
141
+ before { allow(File).to receive(:exist?).with(destination_path) { false } }
142
+ it { expect(generator).to receive(:write_template).with(destination_path, source_path).once }
143
+ end
111
144
  end
112
145
 
113
146
  describe '#print_banner' do
114
- let(:generator) { described_class.new }
147
+ let(:generator) { described_class.new({}) }
115
148
  subject { generator.send(:print_banner) }
116
149
  before do
117
150
  allow_any_instance_of(described_class).to receive(:initialize) { nil }
@@ -129,44 +162,43 @@ RSpec.describe Howitzer::BaseGenerator do
129
162
  end
130
163
 
131
164
  describe '#print_info' do
132
- subject { described_class.new.send(:print_info, 'data') }
165
+ subject { described_class.new({}).send(:print_info, 'data') }
133
166
  before { allow_any_instance_of(described_class).to receive(:initialize) { nil } }
134
167
  after { subject }
135
- it { expect(described_class.logger).to receive(:print).with(' data')}
168
+ it { expect(described_class.logger).to receive(:print).with(' data') }
136
169
  end
137
170
 
138
171
  describe '#puts_info' do
139
- subject { described_class.new.send(:puts_info, 'data') }
172
+ subject { described_class.new({}).send(:puts_info, 'data') }
140
173
  before { allow_any_instance_of(described_class).to receive(:initialize) { nil } }
141
174
  after { subject }
142
- it { expect(described_class.logger).to receive(:puts).with(' data')}
175
+ it { expect(described_class.logger).to receive(:puts).with(' data') }
143
176
  end
144
177
 
145
178
  describe '#puts_error' do
146
- subject { described_class.new.send(:puts_error, 'data') }
179
+ subject { described_class.new({}).send(:puts_error, 'data') }
147
180
  before { allow_any_instance_of(described_class).to receive(:initialize) { nil } }
148
181
  after { subject }
149
- it { expect(described_class.logger).to receive(:puts).with(' ERROR: data')}
182
+ it { expect(described_class.logger).to receive(:puts).with(' ERROR: data') }
150
183
  end
151
184
 
152
185
  describe '#source_path' do
153
- subject { described_class.new.send(:source_path, 'example.txt') }
186
+ subject { described_class.new({}).send(:source_path, 'example.txt') }
154
187
  before do
155
188
  allow_any_instance_of(described_class).to receive(:initialize) { nil }
156
- allow(File).to receive(:dirname) { '/' }
157
189
  end
158
- it { is_expected.to eq('/base/templates/example.txt') }
190
+ it { is_expected.to include('/base/templates/example.txt') }
159
191
  end
160
192
 
161
193
  describe '#dest_path' do
162
- subject { described_class.new.send(:dest_path, 'example.txt') }
194
+ subject { described_class.new({}).send(:dest_path, 'example.txt') }
163
195
  before { allow_any_instance_of(described_class).to receive(:initialize) { nil } }
164
196
  it { is_expected.to include('/example.txt') }
165
197
  end
166
198
 
167
199
  describe '#copy_with_path' do
168
- let(:generator) { described_class.new }
169
- let(:data) { {source: 's.txt', destination: 'd.txt'} }
200
+ let(:generator) { described_class.new({}) }
201
+ let(:data) { { source: 's.txt', destination: 'd.txt' } }
170
202
  let(:src) { '/path/to/s.txt' }
171
203
  let(:dst) { '/path/to/d.txt' }
172
204
  subject { generator.send(:copy_with_path, data) }
@@ -178,7 +210,7 @@ RSpec.describe Howitzer::BaseGenerator do
178
210
  end
179
211
  after { subject }
180
212
  context 'when destination file present' do
181
- before { allow(File).to receive(:exists?).with(dst) { true } }
213
+ before { allow(File).to receive(:exist?).with(dst) { true } }
182
214
  context 'when identical with source file' do
183
215
  before { allow(FileUtils).to receive(:identical?).with(src, dst) { true } }
184
216
  it { expect(generator).to receive(:puts_info).with("Identical 'd.txt' file").once }
@@ -192,14 +224,14 @@ RSpec.describe Howitzer::BaseGenerator do
192
224
  context 'when user typed Y' do
193
225
  before { allow(generator).to receive(:gets) { 'Y' } }
194
226
  it do
195
- expect(FileUtils).to receive(:cp).with(src, dst) {nil}.once
227
+ expect(FileUtils).to receive(:cp).with(src, dst) { nil }.once
196
228
  expect(generator).to receive(:puts_info).with(" Forced 'd.txt' file")
197
229
  end
198
230
  end
199
231
  context 'when user typed y' do
200
232
  before { allow(generator).to receive(:gets) { 'y' } }
201
233
  it do
202
- expect(FileUtils).to receive(:cp).with(src, dst) {nil}.once
234
+ expect(FileUtils).to receive(:cp).with(src, dst) { nil }.once
203
235
  expect(generator).to receive(:puts_info).with(" Forced 'd.txt' file")
204
236
  end
205
237
  end
@@ -227,7 +259,7 @@ RSpec.describe Howitzer::BaseGenerator do
227
259
  end
228
260
  end
229
261
  context 'when destination file missing' do
230
- before { allow(File).to receive(:exists?).with(dst) { false } }
262
+ before { allow(File).to receive(:exist?).with(dst) { false } }
231
263
  it do
232
264
  expect(generator).to receive(:puts_info).with("Added 'd.txt' file")
233
265
  expect(FileUtils).to receive(:cp).with(src, dst).once
@@ -235,8 +267,7 @@ RSpec.describe Howitzer::BaseGenerator do
235
267
  end
236
268
  context 'when exception happened' do
237
269
  before { allow(FileUtils).to receive(:mkdir_p).and_raise(StandardError.new('Some error')) }
238
- it { expect(generator).to receive(:puts_error).with("Impossible to create 'd.txt' file. Reason: Some error")}
270
+ it { expect(generator).to receive(:puts_error).with("Impossible to create 'd.txt' file. Reason: Some error") }
239
271
  end
240
272
  end
241
-
242
- end
273
+ end
@@ -6,17 +6,19 @@ RSpec.describe 'Generators' do
6
6
  subject { file_tree_info(destination) }
7
7
  before do
8
8
  Howitzer::BaseGenerator.logger = output
9
- generator_name.new
9
+ generator_name.new({})
10
10
  end
11
11
  after { FileUtils.rm_r(destination) }
12
12
 
13
- describe 'ConfigGenerator' do
14
- let(:generator_name) { Howitzer::ConfigGenerator }
13
+ describe Howitzer::ConfigGenerator do
14
+ let(:generator_name) { described_class }
15
15
  let(:expected_result) do
16
16
  [
17
- {:name=> '/config', :is_directory=>true},
18
- {:name=> '/config/custom.yml', :is_directory=>false, :size=>template_file_size('config', 'custom.yml')},
19
- {:name=> '/config/default.yml', :is_directory=>false, :size=>template_file_size('config', 'default.yml')}
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') }
20
22
  ]
21
23
  end
22
24
 
@@ -24,11 +26,13 @@ RSpec.describe 'Generators' do
24
26
  describe 'output' do
25
27
  let(:expected_output) do
26
28
  " * Config files generation ...
29
+ Added 'config/boot.rb' file
27
30
  Added 'config/custom.yml' file
31
+ Added 'config/capybara.rb' file
28
32
  Added 'config/default.yml' file\n"
29
33
  end
30
34
  subject { output.string }
31
35
  it { is_expected.to eql(expected_output) }
32
36
  end
33
37
  end
34
- end
38
+ end
@@ -6,25 +6,35 @@ RSpec.describe 'Generators' do
6
6
  subject { file_tree_info(destination) }
7
7
  before do
8
8
  Howitzer::BaseGenerator.logger = output
9
- generator_name.new
9
+ generator_name.new(cucumber: true)
10
10
  end
11
11
  after { FileUtils.rm_r(destination) }
12
12
 
13
- describe 'CucumberGenerator' do
14
- let(:generator_name) { Howitzer::CucumberGenerator }
13
+ describe Howitzer::CucumberGenerator do
14
+ let(:generator_name) { described_class }
15
15
  let(:expected_result) do
16
16
  [
17
- {:name=> '/config', :is_directory=>true},
18
- {:name=> '/config/cucumber.yml', :is_directory=>false, :size=>template_file_size('cucumber', 'cucumber.yml')},
19
- {:name=> '/features', :is_directory=>true},
20
- {:name=> '/features/example.feature', :is_directory=>false, :size=>template_file_size('cucumber', 'example.feature')},
21
- {:name=> '/features/step_definitions', :is_directory=>true},
22
- {:name=> '/features/step_definitions/common_steps.rb', :is_directory=>false, :size=>template_file_size('cucumber', 'common_steps.rb')},
23
- {:name=> '/features/support', :is_directory=>true},
24
- {:name=> '/features/support/env.rb', :is_directory=>false, :size=>template_file_size('cucumber', 'env.rb')},
25
- {:name=> '/features/support/transformers.rb', :is_directory=>false, :size=>template_file_size('cucumber', 'transformers.rb')},
26
- {:name=> '/tasks', :is_directory=>true},
27
- {:name=> '/tasks/cucumber.rake', :is_directory=>false, :size=>template_file_size('cucumber', 'cucumber.rake')}
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
+ {
32
+ name: '/features/support/transformers.rb',
33
+ is_directory: false,
34
+ size: template_file_size('cucumber', 'transformers.rb')
35
+ },
36
+ { name: '/tasks', is_directory: true },
37
+ { name: '/tasks/cucumber.rake', is_directory: false, size: template_file_size('cucumber', 'cucumber.rake') }
28
38
  ]
29
39
  end
30
40
  it { is_expected.to eql(expected_result) }
@@ -35,11 +45,10 @@ RSpec.describe 'Generators' do
35
45
  Added 'features/support/env.rb' file
36
46
  Added 'features/support/transformers.rb' file
37
47
  Added 'features/example.feature' file
38
- Added 'tasks/cucumber.rake' file
39
- Added 'config/cucumber.yml' file\n"
48
+ Added 'tasks/cucumber.rake' file\n"
40
49
  end
41
50
  subject { output.string }
42
51
  it { is_expected.to eql(expected_output) }
43
52
  end
44
53
  end
45
- end
54
+ end
@@ -6,16 +6,20 @@ RSpec.describe 'Generators' do
6
6
  subject { file_tree_info(destination) }
7
7
  before do
8
8
  Howitzer::BaseGenerator.logger = output
9
- generator_name.new
9
+ generator_name.new({})
10
10
  end
11
11
  after { FileUtils.rm_r(destination) }
12
12
 
13
- describe 'EmailsGenerator' do
14
- let(:generator_name) { Howitzer::EmailsGenerator }
13
+ describe Howitzer::EmailsGenerator do
14
+ let(:generator_name) { described_class }
15
15
  let(:expected_result) do
16
16
  [
17
- {:name=> '/emails', :is_directory=>true},
18
- {:name=> '/emails/example_email.rb', :is_directory=>false, :size=>template_file_size('emails', 'example_email.rb')}
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
+ }
19
23
  ]
20
24
  end
21
25
  it { is_expected.to eql(expected_result) }
@@ -28,4 +32,4 @@ RSpec.describe 'Generators' do
28
32
  it { is_expected.to eql(expected_output) }
29
33
  end
30
34
  end
31
- end
35
+ end
@@ -0,0 +1,53 @@
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_girl.rb',
25
+ is_directory: false, size: template_file_size('prerequisites', 'factory_girl.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
+ " * Pre-requisites integration to the framework ...
44
+ Added 'prerequisites/factory_girl.rb' file
45
+ Added 'prerequisites/factories/users.rb' file
46
+ Added 'prerequisites/models/base.rb' file
47
+ Added '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
@@ -6,30 +6,67 @@ RSpec.describe 'Generators' do
6
6
  subject { file_tree_info(destination) }
7
7
  before do
8
8
  Howitzer::BaseGenerator.logger = output
9
- generator_name.new
9
+ generator_name.new(options)
10
10
  end
11
11
  after { FileUtils.rm_r(destination) }
12
12
 
13
- describe 'RootGenerator' do
14
- let(:generator_name) { Howitzer::RootGenerator }
13
+ describe Howitzer::RootGenerator do
14
+ let(:generator_name) { described_class }
15
15
  let(:expected_result) do
16
16
  [
17
- {:name=> '/Gemfile', :is_directory=>false, :size=>template_file_size('root', 'Gemfile')},
18
- {:name=> '/Rakefile', :is_directory=>false, :size=>template_file_size('root', 'Rakefile')},
19
- {:name=> '/boot.rb', :is_directory=>false, :size=>template_file_size('root', 'boot.rb')}
17
+ { name: '/.gitignore', is_directory: false, size: 196 },
18
+ { name: '/.rubocop.yml', is_directory: false, size: 584 },
19
+ { name: '/Gemfile', is_directory: false, size: 605 },
20
+ { name: '/Rakefile', is_directory: false, size: template_file_size('root', 'Rakefile') }
20
21
  ]
21
22
  end
23
+ let(:options) { {} }
22
24
  it { is_expected.to eql(expected_result) }
23
25
  describe 'output' do
24
- let(:expected_output) do
25
- " * Root files generation ...
26
+ subject { output.string }
27
+ context 'when options is empty' do
28
+ let(:expected_output) do
29
+ " * Root files generation ...
26
30
  Added '.gitignore' file
27
- Added 'Gemfile' file
31
+ Added '.rubocop.yml' file
28
32
  Added 'Rakefile' file
29
- Added 'boot.rb' file\n"
33
+ Added template 'Gemfile.erb' with params '{}' to destination 'Gemfile'\n"
34
+ end
35
+ it { is_expected.to eql(expected_output) }
36
+ end
37
+ context 'when options is rspec => true' do
38
+ let(:expected_output) do
39
+ " * Root files generation ...
40
+ Added '.gitignore' file
41
+ Added '.rubocop.yml' file
42
+ Added 'Rakefile' file
43
+ Added template 'Gemfile.erb' with params '{:rspec=>true}' to destination 'Gemfile'\n"
44
+ end
45
+ let(:options) { { rspec: true } }
46
+ it { is_expected.to eql(expected_output) }
47
+ end
48
+ context 'when options is cucumber => cucumber' do
49
+ let(:expected_output) do
50
+ " * Root files generation ...
51
+ Added '.gitignore' file
52
+ Added '.rubocop.yml' file
53
+ Added 'Rakefile' file
54
+ Added template 'Gemfile.erb' with params '{:cucumber=>true}' to destination 'Gemfile'\n"
55
+ end
56
+ let(:options) { { cucumber: true } }
57
+ it { is_expected.to eql(expected_output) }
58
+ end
59
+ context 'when options is turnip => true' do
60
+ let(:expected_output) do
61
+ " * Root files generation ...
62
+ Added '.gitignore' file
63
+ Added '.rubocop.yml' file
64
+ Added 'Rakefile' file
65
+ Added template 'Gemfile.erb' with params '{:turnip=>true}' to destination 'Gemfile'\n"
66
+ end
67
+ let(:options) { { turnip: true } }
68
+ it { is_expected.to eql(expected_output) }
30
69
  end
31
- subject { output.string }
32
- it { is_expected.to eql(expected_output) }
33
70
  end
34
71
  end
35
- end
72
+ end