howitzer 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -1
  3. data/.travis.yml +3 -2
  4. data/CHANGELOG.md +25 -5
  5. data/GETTING_STARTED.md +158 -13
  6. data/README.md +49 -32
  7. data/Rakefile +10 -1
  8. data/bin/howitzer +49 -78
  9. data/features/cli_help.feature +30 -0
  10. data/features/cli_new.feature +263 -0
  11. data/features/cli_unknown.feature +17 -0
  12. data/features/cli_version.feature +14 -0
  13. data/features/step_definitions/common_steps.rb +1 -0
  14. data/features/support/env.rb +1 -0
  15. data/features/support/transformers.rb +3 -0
  16. data/generators/base_generator.rb +2 -0
  17. data/generators/config/config_generator.rb +1 -1
  18. data/generators/config/templates/default.yml +4 -14
  19. data/generators/cucumber/cucumber_generator.rb +1 -1
  20. data/generators/cucumber/templates/cucumber.yml +1 -2
  21. data/generators/cucumber/templates/env.rb +8 -7
  22. data/generators/emails/emails_generator.rb +1 -1
  23. data/generators/pages/pages_generator.rb +1 -1
  24. data/generators/pages/templates/example_page.rb +2 -2
  25. data/generators/root/root_generator.rb +1 -1
  26. data/generators/root/templates/Gemfile +1 -1
  27. data/generators/rspec/rspec_generator.rb +1 -1
  28. data/generators/rspec/templates/example_spec.rb +2 -2
  29. data/generators/rspec/templates/rspec.rake +1 -1
  30. data/generators/rspec/templates/spec_helper.rb +6 -5
  31. data/generators/tasks/tasks_generator.rb +1 -1
  32. data/generators/tasks/templates/common.rake +1 -0
  33. data/howitzer.gemspec +8 -8
  34. data/lib/howitzer.rb +4 -1
  35. data/lib/howitzer/blank_page.rb +6 -0
  36. data/lib/howitzer/capybara/dsl_ex.rb +15 -0
  37. data/lib/howitzer/capybara/settings.rb +267 -0
  38. data/lib/howitzer/email.rb +134 -0
  39. data/lib/howitzer/exceptions.rb +18 -0
  40. data/lib/howitzer/helpers.rb +34 -23
  41. data/lib/howitzer/init.rb +1 -4
  42. data/lib/howitzer/mailgun/client.rb +48 -0
  43. data/lib/howitzer/mailgun/connector.rb +34 -0
  44. data/lib/howitzer/mailgun/response.rb +28 -0
  45. data/lib/howitzer/utils.rb +2 -2
  46. data/lib/howitzer/utils/data_generator/data_storage.rb +15 -2
  47. data/lib/howitzer/utils/data_generator/gen.rb +14 -10
  48. data/lib/howitzer/utils/locator_store.rb +14 -7
  49. data/lib/howitzer/utils/log.rb +2 -0
  50. data/lib/howitzer/utils/page_validator.rb +74 -27
  51. data/lib/howitzer/version.rb +1 -1
  52. data/lib/howitzer/web_page.rb +83 -32
  53. data/spec/config/default.yml +10 -12
  54. data/spec/spec_helper.rb +12 -0
  55. data/spec/support/mailgun_unit_client.rb +60 -0
  56. data/spec/unit/generators/generators_spec.rb +7 -7
  57. data/spec/unit/lib/capybara/dsl_ex_spec.rb +60 -0
  58. data/spec/unit/lib/{capybara_settings_spec.rb → capybara/settings_spec.rb} +16 -10
  59. data/spec/unit/lib/email_spec.rb +129 -0
  60. data/spec/unit/lib/helpers_spec.rb +160 -34
  61. data/spec/unit/lib/init_spec.rb +1 -12
  62. data/spec/unit/lib/mailgun/client_spec.rb +36 -0
  63. data/spec/unit/lib/mailgun/connector_spec.rb +70 -0
  64. data/spec/unit/lib/mailgun/response_spec.rb +29 -0
  65. data/spec/unit/lib/utils/data_generator/data_storage_spec.rb +23 -5
  66. data/spec/unit/lib/utils/data_generator/gen_spec.rb +2 -63
  67. data/spec/unit/lib/utils/locator_store_spec.rb +41 -6
  68. data/spec/unit/lib/utils/log_spec.rb +1 -1
  69. data/spec/unit/lib/utils/page_validator_spec.rb +149 -25
  70. data/spec/unit/lib/web_page_spec.rb +127 -53
  71. metadata +102 -142
  72. data/lib/howitzer/utils/capybara_patched.rb +0 -23
  73. data/lib/howitzer/utils/capybara_settings.rb +0 -247
  74. data/lib/howitzer/utils/email/email.rb +0 -85
  75. data/lib/howitzer/utils/email/mail_client.rb +0 -132
  76. data/lib/howitzer/utils/email/mailgun.rb +0 -175
  77. data/lib/howitzer/utils/email/mailgun_helper.rb +0 -61
  78. data/spec/unit/bin/howitzer_spec.rb +0 -175
  79. data/spec/unit/lib/utils/email/email_spec.rb +0 -75
  80. data/spec/unit/lib/utils/email/mail_client_spec.rb +0 -115
  81. data/spec/unit/lib/utils/email/mailgun_helper_spec.rb +0 -95
data/bin/howitzer CHANGED
@@ -1,89 +1,60 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require 'rubygems' unless ENV['NO_RUBYGEMS']
4
-
5
- Dir[File.join(File.dirname(__FILE__), '..', 'generators', '**', '*_generator.rb')].each{ |f| require File.expand_path(f) }
6
-
7
- def check_arguments
8
- expected_option_list = [
9
- 'install --cucumber',
10
- 'install --rspec',
11
- 'install --cucumber --rspec',
12
- 'install --rspec --cucumber',
13
- '--version',
14
- '--help'
15
- ]
16
-
17
- actual_options = ARGV.map(&:downcase).join(' ')
18
- unless expected_option_list.include?(actual_options)
19
- puts "ERROR: incorrect options. Please, see help for details"
20
- show_help
21
- exit 1
2
+ require 'gli'
3
+ require_relative '../lib/howitzer/version'
4
+
5
+ module HowitzerCli
6
+
7
+ extend GLI::App
8
+ synopsis_format :compact
9
+ program_desc 'Ruby based framework for acceptance testing'
10
+ version Howitzer::VERSION
11
+
12
+ desc 'Generate new project'
13
+ arg_name '<PROJECT NAME>'
14
+ command :new do |c|
15
+ c.desc 'Integrate Cucumber'
16
+ c.switch [:c, :cucumber] , negatable: false
17
+
18
+ c.desc 'Integrate Rspec'
19
+ c.switch [:r, :rspec], negatable: false
20
+
21
+ c.action do |global_options, options, args|
22
+ if args.size > 0
23
+ validate_options(options)
24
+ Dir[File.join(File.dirname(__FILE__), '..', 'generators', '**', '*_generator.rb')].each{ |f| require File.expand_path(f) }
25
+ path_to_dir = File.join(Dir.pwd, args.first)
26
+ puts " * New project directory creation ..."
27
+ Dir.mkdir(path_to_dir)
28
+ puts " Created new './#{args.first}' folder"
29
+ Dir.chdir(path_to_dir)
30
+ Howitzer::ConfigGenerator.new
31
+ Howitzer::PagesGenerator.new
32
+ Howitzer::TasksGenerator.new
33
+ Howitzer::EmailsGenerator.new
34
+ Howitzer::RootGenerator.new
35
+ Howitzer::CucumberGenerator.new if options['cucumber']
36
+ Howitzer::RspecGenerator.new if options['rspec']
37
+ puts "[WARN] Extra parameters were skipped" if args.size > 1
38
+ elsif args.size.zero?
39
+ exit_now!("Please specify <PROJECT NAME>", 64)
40
+ end
41
+ end
22
42
  end
23
- end
24
43
 
25
- def parse_options
26
- first_option = ARGV.shift.to_s.downcase
27
- case first_option
28
- when 'install' then execute_generator(ARGV.map(&:downcase))
29
- when '--version' then show_version
30
- when '--help' then show_help
31
- else
32
- puts "ERROR: incorrect first argument ('#{first_option}')"
33
- show_help
34
- exit 1
44
+ def self.call
45
+ exit run(ARGV)
35
46
  end
36
- end
37
-
38
- private
39
47
 
40
- def show_help
41
- puts %{
42
- howitzer [command {--cucumber, --rspec}] | {options}
43
-
44
- Commands are ...
45
- install Generate test framework units:
46
- --rspec add RSpec integration with framework
47
- --cucumber add Cucumber integration with framework
48
- Options are ...
49
- --help Display this help message.
50
- --version Display the program version.
51
- }
52
- end
53
-
54
- def show_version
55
- require_relative "../lib/howitzer/version"
56
- puts "Version: #{Howitzer::VERSION}"
57
- exit 0
58
- end
59
-
60
- def execute_generator(options)
61
- if %w[--cucumber --rspec].include?(options.first)
62
- Howitzer::ConfigGenerator.new
63
- Howitzer::PagesGenerator.new
64
- Howitzer::TasksGenerator.new
65
- Howitzer::EmailsGenerator.new
66
- Howitzer::RootGenerator.new
67
-
68
- options.each do |option|
69
- case option
70
- when '--cucumber' then Howitzer::CucumberGenerator.new
71
- when '--rspec' then Howitzer::RspecGenerator.new
72
- else nil
48
+ class << self
49
+ private
50
+ def validate_options(options)
51
+ if !options['cucumber'] && !options['rspec']
52
+ exit_now!("Provide --cucumber and/or --rspec option", 64)
73
53
  end
74
54
  end
75
- else
76
- if options.empty?
77
- puts "ERROR: No option specified for install command."
78
- else
79
- puts "ERROR: Unknown '#{options.first}' option specified."
80
- end
81
- show_help
82
- exit 1
83
55
  end
84
56
  end
85
57
 
86
58
  unless ENV['TEST_MODE']
87
- check_arguments
88
- parse_options
89
- end
59
+ HowitzerCli.call
60
+ end
@@ -0,0 +1,30 @@
1
+ Feature: Howitzer CLI Help
2
+
3
+ Scenario Outline: Run with help global option
4
+ When I run `howitzer <option>`
5
+ Then the output should contain exactly:
6
+ """
7
+ NAME
8
+ howitzer - Ruby based framework for acceptance testing
9
+
10
+ SYNOPSIS
11
+ howitzer [global options] command [command options] [arguments...]
12
+
13
+ VERSION
14
+ <HOWITZER_VERSION>
15
+
16
+ GLOBAL OPTIONS
17
+ --help - Show this message
18
+ --version - Display the program version
19
+
20
+ COMMANDS
21
+ help - Shows a list of commands or help for one command
22
+ new - Generate new project
23
+
24
+ """
25
+ And the exit status should be 0
26
+ Examples:
27
+ | option |
28
+ | |
29
+ | --help |
30
+ | -h |
@@ -0,0 +1,263 @@
1
+ Feature: Howitzer CLI Version
2
+
3
+ Scenario: Run with new command without argument and options
4
+ When I run `howitzer new`
5
+ Then the output should contain exactly:
6
+ """
7
+ error: Please specify <PROJECT NAME>
8
+
9
+ """
10
+ And the exit status should be 64
11
+
12
+ Scenario: Run with new command with argument and without options
13
+ When I run `howitzer new test_automation`
14
+ Then the output should contain exactly:
15
+ """
16
+ error: Provide --cucumber and/or --rspec option
17
+
18
+ """
19
+ And the exit status should be 64
20
+
21
+ Scenario: Run with new command with argument and unknown option
22
+ When I run `howitzer new test_automation --unknown`
23
+ Then the output should contain:
24
+ """
25
+ error: Unknown option --unknown
26
+
27
+ """
28
+ And the exit status should be 64
29
+
30
+ Scenario Outline: Run with new command with help option
31
+ When I run `howitzer new <option>`
32
+ Then the output should contain exactly:
33
+ """
34
+ NAME
35
+ new - Generate new project
36
+
37
+ SYNOPSIS
38
+ howitzer [global options] new [command options] <PROJECT NAME>
39
+
40
+ COMMAND OPTIONS
41
+ -c, --cucumber - Integrate Cucumber
42
+ -r, --rspec - Integrate Rspec
43
+
44
+ """
45
+ And the exit status should be 0
46
+ Examples:
47
+ | option |
48
+ | --help |
49
+ | -h |
50
+
51
+ Scenario Outline: Run with new command with argument and with rspec option
52
+ When I run `howitzer new test_automation <option>`
53
+ Then the output should contain exactly:
54
+ """
55
+ * New project directory creation ...
56
+ Created new './test_automation' folder
57
+ * Config files generation ...
58
+ Added 'config/custom.yml' file
59
+ Added 'config/default.yml' file
60
+ * PageOriented pattern structure generation ...
61
+ Added 'pages/example_page.rb' file
62
+ Added 'pages/example_menu.rb' file
63
+ * Base rake task generation ...
64
+ Added 'tasks/common.rake' file
65
+ * Email example generation ...
66
+ Added '/emails/example_email.rb' file
67
+ * Root files generation ...
68
+ Added '.gitignore' file
69
+ Added 'Gemfile' file
70
+ Added 'Rakefile' file
71
+ Added 'boot.rb' file
72
+ * RSpec integration to the framework ...
73
+ Added 'spec/spec_helper.rb' file
74
+ Added 'spec/example_spec.rb' file
75
+ Added 'tasks/rspec.rake' file
76
+
77
+ """
78
+ Then a directory named "test_automation" should exist
79
+ Then the following files should exist:
80
+ | test_automation/config/custom.yml |
81
+ | test_automation/config/default.yml |
82
+ | test_automation/emails/example_email.rb |
83
+ | test_automation/pages/example_menu.rb |
84
+ | test_automation/pages/example_page.rb |
85
+ | test_automation/spec/example_spec.rb |
86
+ | test_automation/spec/spec_helper.rb |
87
+ | test_automation/tasks/common.rake |
88
+ | test_automation/tasks/rspec.rake |
89
+ | test_automation/boot.rb |
90
+ | test_automation/Gemfile |
91
+ | test_automation/Rakefile |
92
+ | test_automation/.gitignore |
93
+ And the exit status should be 0
94
+ Examples:
95
+ | option |
96
+ | --rspec |
97
+ | -r |
98
+
99
+ Scenario Outline: Run with new command with argument and with cucumber option
100
+ When I run `howitzer new test_automation <option>`
101
+ Then the output should contain exactly:
102
+ """
103
+ * New project directory creation ...
104
+ Created new './test_automation' folder
105
+ * Config files generation ...
106
+ Added 'config/custom.yml' file
107
+ Added 'config/default.yml' file
108
+ * PageOriented pattern structure generation ...
109
+ Added 'pages/example_page.rb' file
110
+ Added 'pages/example_menu.rb' file
111
+ * Base rake task generation ...
112
+ Added 'tasks/common.rake' file
113
+ * Email example generation ...
114
+ Added '/emails/example_email.rb' file
115
+ * Root files generation ...
116
+ Added '.gitignore' file
117
+ Added 'Gemfile' file
118
+ Added 'Rakefile' file
119
+ Added 'boot.rb' file
120
+ * Cucumber integration to the framework ...
121
+ Added 'features/step_definitions/common_steps.rb' file
122
+ Added 'features/support/env.rb' file
123
+ Added 'features/support/transformers.rb' file
124
+ Added 'features/example.feature' file
125
+ Added 'tasks/cucumber.rake' file
126
+ Added 'config/cucumber.yml' file
127
+
128
+ """
129
+ Then a directory named "test_automation" should exist
130
+ Then the following files should exist:
131
+ | test_automation/config/cucumber.yml |
132
+ | test_automation/config/custom.yml |
133
+ | test_automation/config/default.yml |
134
+ | test_automation/emails/example_email.rb |
135
+ | test_automation/features/step_definitions/common_steps.rb |
136
+ | test_automation/features/support/env.rb |
137
+ | test_automation/features/support/transformers.rb |
138
+ | test_automation/features/example.feature |
139
+ | test_automation/pages/example_menu.rb |
140
+ | test_automation/pages/example_page.rb |
141
+ | test_automation/tasks/common.rake |
142
+ | test_automation/tasks/cucumber.rake |
143
+ | test_automation/boot.rb |
144
+ | test_automation/Gemfile |
145
+ | test_automation/Rakefile |
146
+ | test_automation/.gitignore |
147
+ And the exit status should be 0
148
+ Examples:
149
+ | option |
150
+ | --cucumber |
151
+ | -c |
152
+
153
+ Scenario Outline: Run with new command with argument and with cucumber and rspec option
154
+ When I run `howitzer new test_automation <options>`
155
+ Then the output should contain exactly:
156
+ """
157
+ * New project directory creation ...
158
+ Created new './test_automation' folder
159
+ * Config files generation ...
160
+ Added 'config/custom.yml' file
161
+ Added 'config/default.yml' file
162
+ * PageOriented pattern structure generation ...
163
+ Added 'pages/example_page.rb' file
164
+ Added 'pages/example_menu.rb' file
165
+ * Base rake task generation ...
166
+ Added 'tasks/common.rake' file
167
+ * Email example generation ...
168
+ Added '/emails/example_email.rb' file
169
+ * Root files generation ...
170
+ Added '.gitignore' file
171
+ Added 'Gemfile' file
172
+ Added 'Rakefile' file
173
+ Added 'boot.rb' file
174
+ * Cucumber integration to the framework ...
175
+ Added 'features/step_definitions/common_steps.rb' file
176
+ Added 'features/support/env.rb' file
177
+ Added 'features/support/transformers.rb' file
178
+ Added 'features/example.feature' file
179
+ Added 'tasks/cucumber.rake' file
180
+ Added 'config/cucumber.yml' file
181
+ * RSpec integration to the framework ...
182
+ Added 'spec/spec_helper.rb' file
183
+ Added 'spec/example_spec.rb' file
184
+ Added 'tasks/rspec.rake' file
185
+
186
+ """
187
+ Then a directory named "test_automation" should exist
188
+ Then the following files should exist:
189
+ | test_automation/config/cucumber.yml |
190
+ | test_automation/config/custom.yml |
191
+ | test_automation/config/default.yml |
192
+ | test_automation/emails/example_email.rb |
193
+ | test_automation/features/step_definitions/common_steps.rb |
194
+ | test_automation/features/support/env.rb |
195
+ | test_automation/features/support/transformers.rb |
196
+ | test_automation/features/example.feature |
197
+ | test_automation/pages/example_menu.rb |
198
+ | test_automation/pages/example_page.rb |
199
+ | test_automation/spec/spec_helper.rb |
200
+ | test_automation/spec/example_spec.rb |
201
+ | test_automation/tasks/common.rake |
202
+ | test_automation/tasks/cucumber.rake |
203
+ | test_automation/tasks/rspec.rake |
204
+ | test_automation/boot.rb |
205
+ | test_automation/Gemfile |
206
+ | test_automation/Rakefile |
207
+ | test_automation/.gitignore |
208
+ And the exit status should be 0
209
+ Examples:
210
+ | options |
211
+ | --cucumber --rspec |
212
+ | --rspec --cucumber |
213
+ | -c -r |
214
+ | -r -c |
215
+ | -cr |
216
+ | -rc |
217
+
218
+ Scenario Outline: Run with new command with options and with rspec argument
219
+ When I run `howitzer new <option> test_automation`
220
+ Then the output should contain exactly:
221
+ """
222
+ * New project directory creation ...
223
+ Created new './test_automation' folder
224
+ * Config files generation ...
225
+ Added 'config/custom.yml' file
226
+ Added 'config/default.yml' file
227
+ * PageOriented pattern structure generation ...
228
+ Added 'pages/example_page.rb' file
229
+ Added 'pages/example_menu.rb' file
230
+ * Base rake task generation ...
231
+ Added 'tasks/common.rake' file
232
+ * Email example generation ...
233
+ Added '/emails/example_email.rb' file
234
+ * Root files generation ...
235
+ Added '.gitignore' file
236
+ Added 'Gemfile' file
237
+ Added 'Rakefile' file
238
+ Added 'boot.rb' file
239
+ * RSpec integration to the framework ...
240
+ Added 'spec/spec_helper.rb' file
241
+ Added 'spec/example_spec.rb' file
242
+ Added 'tasks/rspec.rake' file
243
+
244
+ """
245
+ Then a directory named "test_automation" should exist
246
+ Then the following files should exist:
247
+ | test_automation/config/custom.yml |
248
+ | test_automation/config/default.yml |
249
+ | test_automation/emails/example_email.rb |
250
+ | test_automation/pages/example_menu.rb |
251
+ | test_automation/pages/example_page.rb |
252
+ | test_automation/spec/example_spec.rb |
253
+ | test_automation/spec/spec_helper.rb |
254
+ | test_automation/tasks/common.rake |
255
+ | test_automation/tasks/rspec.rake |
256
+ | test_automation/boot.rb |
257
+ | test_automation/Gemfile |
258
+ | test_automation/Rakefile |
259
+ | test_automation/.gitignore |
260
+ And the exit status should be 0
261
+ Examples:
262
+ | option |
263
+ | --rspec |
@@ -0,0 +1,17 @@
1
+ Feature: Howitzer CLI Version
2
+
3
+ Scenario: Run with --unknown global option
4
+ When I run `howitzer --unknown`
5
+ Then the output should contain:
6
+ """
7
+ error: Unknown option --unknown
8
+ """
9
+ And the exit status should be 64
10
+
11
+ Scenario: Run with unknown command
12
+ When I run `howitzer unknown`
13
+ Then the output should contain:
14
+ """
15
+ error: Unknown command 'unknown'
16
+ """
17
+ And the exit status should be 64