howitzer 1.1.1 → 2.0.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +32 -0
- data/.travis.yml +1 -4
- data/.yardopts +1 -2
- data/CHANGELOG.md +28 -1
- data/Gemfile +6 -0
- data/LICENSE +1 -1
- data/README.md +55 -85
- data/Rakefile +7 -7
- data/bin/howitzer +56 -31
- data/features/cli_new.feature +162 -79
- data/features/cli_update.feature +114 -21
- data/features/step_definitions/common_steps.rb +29 -9
- data/features/support/env.rb +1 -1
- data/features/support/transformers.rb +2 -2
- data/generators/base_generator.rb +121 -49
- data/generators/config/config_generator.rb +8 -5
- data/generators/config/templates/boot.rb +14 -0
- data/generators/config/templates/capybara.rb +156 -0
- data/generators/config/templates/custom.yml +2 -3
- data/generators/config/templates/default.yml +50 -82
- data/generators/cucumber/cucumber_generator.rb +9 -9
- data/generators/cucumber/templates/common_steps.rb +4 -4
- data/generators/cucumber/templates/cucumber.rake +63 -54
- data/generators/cucumber/templates/env.rb +24 -23
- data/generators/cucumber/templates/transformers.rb +23 -15
- data/generators/emails/emails_generator.rb +4 -2
- data/generators/emails/templates/example_email.rb +4 -4
- data/generators/prerequisites/prerequisites_generator.rb +24 -0
- data/generators/prerequisites/templates/base.rb +22 -0
- data/generators/prerequisites/templates/factory_girl.rb +30 -0
- data/generators/prerequisites/templates/user.rb +7 -0
- data/generators/prerequisites/templates/users.rb +12 -0
- data/generators/root/root_generator.rb +11 -7
- data/generators/root/templates/.rubocop.yml +32 -0
- data/generators/root/templates/Gemfile.erb +27 -0
- data/generators/root/templates/Rakefile +6 -8
- data/generators/rspec/rspec_generator.rb +7 -7
- data/generators/rspec/templates/example_spec.rb +1 -1
- data/generators/rspec/templates/rspec.rake +48 -29
- data/generators/rspec/templates/spec_helper.rb +33 -32
- data/generators/tasks/tasks_generator.rb +4 -2
- data/generators/tasks/templates/common.rake +1 -16
- data/generators/turnip/templates/.rspec +1 -0
- data/generators/turnip/templates/common_steps.rb +25 -0
- data/generators/turnip/templates/example.feature +8 -0
- data/generators/turnip/templates/spec_helper.rb +56 -0
- data/generators/turnip/templates/turnip.rake +61 -0
- data/generators/turnip/templates/turnip_helper.rb +6 -0
- data/generators/turnip/turnip_generator.rb +26 -0
- data/generators/web/templates/example_page.rb +15 -0
- data/generators/web/templates/menu_section.rb +13 -0
- data/generators/web/web_generator.rb +22 -0
- data/howitzer.gemspec +14 -21
- data/lib/howitzer.rb +47 -7
- data/lib/howitzer/cache.rb +70 -0
- data/lib/howitzer/capybara_helpers.rb +194 -0
- data/lib/howitzer/email.rb +96 -104
- data/lib/howitzer/exceptions.rb +10 -6
- data/lib/howitzer/log.rb +120 -0
- data/lib/howitzer/mail_adapters.rb +7 -0
- data/lib/howitzer/mail_adapters/abstract.rb +84 -0
- data/lib/howitzer/mail_adapters/mailgun.rb +115 -0
- data/lib/howitzer/mailgun_api.rb +9 -0
- data/lib/howitzer/mailgun_api/client.rb +79 -0
- data/lib/howitzer/mailgun_api/connector.rb +37 -0
- data/lib/howitzer/mailgun_api/response.rb +28 -0
- data/lib/howitzer/tasks/framework.rake +2 -2
- data/lib/howitzer/utils.rb +7 -1
- data/lib/howitzer/utils/string_extensions.rb +66 -0
- data/lib/howitzer/version.rb +2 -1
- data/lib/howitzer/web.rb +11 -0
- data/lib/howitzer/web/base_section.rb +27 -0
- data/lib/howitzer/web/blank_page.rb +12 -0
- data/lib/howitzer/web/capybara_methods_proxy.rb +29 -0
- data/lib/howitzer/web/element_dsl.rb +109 -0
- data/lib/howitzer/web/iframe_dsl.rb +93 -0
- data/lib/howitzer/web/page.rb +173 -0
- data/lib/howitzer/web/page_dsl.rb +64 -0
- data/lib/howitzer/web/page_validator.rb +118 -0
- data/lib/howitzer/web/section.rb +27 -0
- data/lib/howitzer/web/section_dsl.rb +154 -0
- data/spec/config/custom.yml +10 -1
- data/spec/spec_helper.rb +37 -19
- data/spec/support/generator_helper.rb +12 -11
- data/spec/support/logger_helper.rb +10 -9
- data/spec/support/mailgun_unit_client.rb +52 -44
- data/spec/support/shared_examples/capybara_context_holder.rb +33 -0
- data/spec/support/shared_examples/capybara_methods_proxy.rb +94 -0
- data/spec/support/shared_examples/dynamic_section_methods.rb +35 -0
- data/spec/support/shared_examples/element_dsl.rb +119 -0
- data/spec/unit/generators/base_generator_spec.rb +64 -33
- data/spec/unit/generators/config_generator_spec.rb +11 -7
- data/spec/unit/generators/cucumber_generator_spec.rb +26 -17
- data/spec/unit/generators/emails_generator_spec.rb +10 -6
- data/spec/unit/generators/prerequisites_generator_spec.rb +53 -0
- data/spec/unit/generators/root_generator_spec.rb +50 -13
- data/spec/unit/generators/rspec_generator_spec.rb +9 -9
- data/spec/unit/generators/tasks_generator_spec.rb +6 -6
- data/spec/unit/generators/turnip_generator_spec.rb +52 -0
- data/spec/unit/generators/web_generator_spec.rb +52 -0
- data/spec/unit/lib/cache_spec.rb +85 -0
- data/spec/unit/lib/capybara_helpers_spec.rb +696 -0
- data/spec/unit/lib/email_spec.rb +104 -91
- data/spec/unit/lib/howitzer.rb +31 -0
- data/spec/unit/lib/init_spec.rb +0 -1
- data/spec/unit/lib/log_spec.rb +122 -0
- data/spec/unit/lib/mail_adapters/abstract_spec.rb +62 -0
- data/spec/unit/lib/mail_adapters/mailgun_spec.rb +163 -0
- data/spec/unit/lib/mailgun_api/client_spec.rb +58 -0
- data/spec/unit/lib/mailgun_api/connector_spec.rb +54 -0
- data/spec/unit/lib/mailgun_api/response_spec.rb +28 -0
- data/spec/unit/lib/utils/string_extensions_spec.rb +77 -0
- data/spec/unit/lib/web/base_section_spec.rb +41 -0
- data/spec/unit/lib/web/element_dsl_spec.rb +17 -0
- data/spec/unit/lib/web/iframe_dsl_spec.rb +99 -0
- data/spec/unit/lib/web/page_dsl_spec.rb +52 -0
- data/spec/unit/lib/web/page_spec.rb +304 -0
- data/spec/unit/lib/web/page_validator_spec.rb +218 -0
- data/spec/unit/lib/web/section_dsl_spec.rb +165 -0
- data/spec/unit/lib/web/section_spec.rb +61 -0
- data/spec/unit/version_spec.rb +1 -1
- metadata +116 -203
- data/GETTING_STARTED.md +0 -774
- data/generators/cucumber/templates/cucumber.yml +0 -10
- data/generators/pages/pages_generator.rb +0 -21
- data/generators/pages/templates/example_menu.rb +0 -15
- data/generators/pages/templates/example_page.rb +0 -15
- data/generators/root/templates/Gemfile +0 -7
- data/generators/root/templates/boot.rb +0 -10
- data/lib/howitzer/blank_page.rb +0 -6
- data/lib/howitzer/capybara/dsl_ex.rb +0 -15
- data/lib/howitzer/capybara/settings.rb +0 -343
- data/lib/howitzer/helpers.rb +0 -230
- data/lib/howitzer/init.rb +0 -1
- data/lib/howitzer/mailgun/client.rb +0 -65
- data/lib/howitzer/mailgun/connector.rb +0 -34
- data/lib/howitzer/mailgun/response.rb +0 -28
- data/lib/howitzer/patches/rawler_patched.rb +0 -86
- data/lib/howitzer/settings.rb +0 -27
- data/lib/howitzer/utils/data_generator/data_storage.rb +0 -88
- data/lib/howitzer/utils/data_generator/gen.rb +0 -135
- data/lib/howitzer/utils/locator_store.rb +0 -217
- data/lib/howitzer/utils/log.rb +0 -139
- data/lib/howitzer/utils/page_validator.rb +0 -133
- data/lib/howitzer/vendor/firebug-1.12.1-fx.xpi +0 -0
- data/lib/howitzer/vendor/firepath-0.9.7-fx.xpi +0 -0
- data/lib/howitzer/web_page.rb +0 -253
- data/spec/active_resource.rb +0 -0
- data/spec/config/default.yml +0 -26
- data/spec/support/boot_helper.rb +0 -15
- data/spec/unit/generators/pages_generator_spec.rb +0 -33
- data/spec/unit/lib/capybara/dsl_ex_spec.rb +0 -60
- data/spec/unit/lib/capybara/settings_spec.rb +0 -441
- data/spec/unit/lib/helpers_spec.rb +0 -1129
- data/spec/unit/lib/mailgun/client_spec.rb +0 -36
- data/spec/unit/lib/mailgun/connector_spec.rb +0 -70
- data/spec/unit/lib/mailgun/response_spec.rb +0 -28
- data/spec/unit/lib/settings_spec.rb +0 -17
- data/spec/unit/lib/utils/data_generator/data_storage_spec.rb +0 -80
- data/spec/unit/lib/utils/data_generator/gen_spec.rb +0 -90
- data/spec/unit/lib/utils/locator_store_spec.rb +0 -157
- data/spec/unit/lib/utils/log_spec.rb +0 -107
- data/spec/unit/lib/utils/page_validator_spec.rb +0 -265
- data/spec/unit/lib/web_page_spec.rb +0 -346
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
Given /^created old howitzer project$/ do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
FileUtils.
|
|
6
|
-
|
|
7
|
-
overwrite_file('
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
Given /^created old howitzer project based on rspec$/ do
|
|
2
|
+
run_simple 'howitzer new test_automation --rspec'
|
|
3
|
+
all_commands.shift
|
|
4
|
+
|
|
5
|
+
FileUtils.move(Dir.glob("#{expand_path('.')}/test_automation/*"), expand_path('.'))
|
|
6
|
+
FileUtils.remove_dir File.join(expand_path('.'), 'test_automation'), true
|
|
7
|
+
overwrite_file('Rakefile', "Dir.chdir(File.join(__dir__, '.'))")
|
|
8
|
+
overwrite_file('Gemfile', 'Hello')
|
|
9
|
+
remove 'config/default.yml'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Given /^created old howitzer project based on cucumber$/ do
|
|
13
|
+
run_simple 'howitzer new test_automation --cucumber'
|
|
14
|
+
all_commands.shift
|
|
15
|
+
|
|
16
|
+
FileUtils.move(Dir.glob("#{expand_path('.')}/test_automation/*"), expand_path('.'))
|
|
17
|
+
FileUtils.remove_dir File.join(expand_path('.'), 'test_automation'), true
|
|
18
|
+
overwrite_file('Rakefile', "Dir.chdir(File.join(__dir__, '.'))")
|
|
19
|
+
overwrite_file('Gemfile', 'Hello')
|
|
20
|
+
remove 'config/default.yml'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Given /^created old howitzer project based on turnip$/ do
|
|
24
|
+
run_simple 'howitzer new test_automation --turnip'
|
|
25
|
+
all_commands.shift
|
|
26
|
+
|
|
27
|
+
FileUtils.move(Dir.glob("#{expand_path('.')}/test_automation/*"), expand_path('.'))
|
|
28
|
+
FileUtils.remove_dir File.join(expand_path('.'), 'test_automation'), true
|
|
29
|
+
end
|
data/features/support/env.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require 'aruba/cucumber'
|
|
1
|
+
require 'aruba/cucumber'
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
Transform /<HOWITZER_VERSION>/ do |text|
|
|
2
|
-
text.gsub(
|
|
3
|
-
end
|
|
2
|
+
text.gsub('<HOWITZER_VERSION>', Howitzer::VERSION)
|
|
3
|
+
end
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
|
+
require 'erb'
|
|
3
|
+
require 'ostruct'
|
|
4
|
+
require 'active_support/core_ext/hash'
|
|
2
5
|
|
|
3
6
|
module Howitzer
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
# This module combines all methods related with information printing to stdout
|
|
8
|
+
module Outputable
|
|
9
|
+
def self.included(base)
|
|
10
|
+
class << base
|
|
11
|
+
attr_accessor :logger
|
|
12
|
+
end
|
|
7
13
|
end
|
|
8
14
|
|
|
9
15
|
def initialize
|
|
10
16
|
print_banner
|
|
11
|
-
manifest.each do |type, list|
|
|
12
|
-
case type
|
|
13
|
-
when :files
|
|
14
|
-
copy_files(list)
|
|
15
|
-
when :templates
|
|
16
|
-
copy_templates(list)
|
|
17
|
-
else nil
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
17
|
end
|
|
21
18
|
|
|
22
|
-
def manifest; end
|
|
23
|
-
|
|
24
19
|
protected
|
|
20
|
+
|
|
25
21
|
def banner; end
|
|
26
22
|
|
|
27
23
|
def logger
|
|
@@ -32,22 +28,6 @@ module Howitzer
|
|
|
32
28
|
BaseGenerator.destination || Dir.pwd
|
|
33
29
|
end
|
|
34
30
|
|
|
35
|
-
def copy_files(list)
|
|
36
|
-
list.each do |data|
|
|
37
|
-
source_file = source_path(data[:source])
|
|
38
|
-
|
|
39
|
-
if File.exists?(source_file)
|
|
40
|
-
copy_with_path(data)
|
|
41
|
-
else
|
|
42
|
-
puts_error("File '#{source_file}' was not found.")
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def copy_templates(list)
|
|
48
|
-
#TODO implement me if it is require
|
|
49
|
-
end
|
|
50
|
-
|
|
51
31
|
def print_banner
|
|
52
32
|
logger.puts banner unless banner.empty?
|
|
53
33
|
end
|
|
@@ -63,11 +43,57 @@ module Howitzer
|
|
|
63
43
|
def puts_error(data)
|
|
64
44
|
logger.puts " ERROR: #{data}"
|
|
65
45
|
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# This module combines methods for copying files and templates
|
|
49
|
+
module Copyable
|
|
50
|
+
def self.included(base)
|
|
51
|
+
class << base
|
|
52
|
+
attr_accessor :destination
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def initialize(_options)
|
|
57
|
+
super()
|
|
58
|
+
|
|
59
|
+
manifest.each do |type, list|
|
|
60
|
+
case type
|
|
61
|
+
when :files
|
|
62
|
+
copy_files(list)
|
|
63
|
+
when :templates
|
|
64
|
+
copy_templates(list)
|
|
65
|
+
else nil
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def manifest; end
|
|
71
|
+
|
|
72
|
+
protected
|
|
73
|
+
|
|
74
|
+
def copy_files(list)
|
|
75
|
+
list.each do |data|
|
|
76
|
+
source_file = source_path(data[:source])
|
|
77
|
+
File.exist?(source_file) ? copy_with_path(data) : puts_error("File '#{source_file}' was not found.")
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def copy_templates(list)
|
|
82
|
+
list.each do |data|
|
|
83
|
+
destination_path = dest_path(data[:destination])
|
|
84
|
+
source_path = source_path(data[:source])
|
|
85
|
+
if File.exist?(destination_path)
|
|
86
|
+
copy_templates_file_exist(data, destination_path, source_path)
|
|
87
|
+
else
|
|
88
|
+
write_template(destination_path, source_path)
|
|
89
|
+
puts_info "Added template '#{data[:source]}' with params '#{@options}' to destination '#{data[:destination]}'"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
66
93
|
|
|
67
94
|
def source_path(file_name)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
95
|
+
base_name = self.class.name.sub('Generator', '').sub('Howitzer::', '').downcase
|
|
96
|
+
File.expand_path(file_name, File.join(__dir__, base_name, 'templates'))
|
|
71
97
|
end
|
|
72
98
|
|
|
73
99
|
def dest_path(path)
|
|
@@ -78,21 +104,8 @@ module Howitzer
|
|
|
78
104
|
src = source_path(data[:source])
|
|
79
105
|
dst = dest_path(data[:destination])
|
|
80
106
|
FileUtils.mkdir_p(File.dirname(dst))
|
|
81
|
-
if File.
|
|
82
|
-
|
|
83
|
-
puts_info("Identical '#{data[:destination]}' file")
|
|
84
|
-
else
|
|
85
|
-
puts_info("Conflict with '#{data[:destination]}' file")
|
|
86
|
-
print_info(" Overwrite '#{data[:destination]}' file? [Yn]:")
|
|
87
|
-
case gets.strip.downcase
|
|
88
|
-
when 'y'
|
|
89
|
-
FileUtils.cp(src, dst)
|
|
90
|
-
puts_info(" Forced '#{data[:destination]}' file")
|
|
91
|
-
when 'n' then nil
|
|
92
|
-
puts_info(" Skipped '#{data[:destination]}' file")
|
|
93
|
-
else nil
|
|
94
|
-
end
|
|
95
|
-
end
|
|
107
|
+
if File.exist?(dst)
|
|
108
|
+
copy_with_path_file_exist(data, src, dst)
|
|
96
109
|
else
|
|
97
110
|
FileUtils.cp(src, dst)
|
|
98
111
|
puts_info("Added '#{data[:destination]}' file")
|
|
@@ -100,5 +113,64 @@ module Howitzer
|
|
|
100
113
|
rescue => e
|
|
101
114
|
puts_error("Impossible to create '#{data[:destination]}' file. Reason: #{e.message}")
|
|
102
115
|
end
|
|
116
|
+
|
|
117
|
+
def write_template(dest_path, source_path)
|
|
118
|
+
File.open(dest_path, 'w+') do |f|
|
|
119
|
+
f.write(ERB.new(File.open(source_path, 'r').read).result(OpenStruct.new(@options).instance_eval { binding }))
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
private
|
|
124
|
+
|
|
125
|
+
def copy_templates_file_exist(data, destination_path, source_path)
|
|
126
|
+
puts_info("Conflict with '#{data[:destination]}' template")
|
|
127
|
+
print_info(" Overwrite '#{data[:destination]}' template? [Yn]:")
|
|
128
|
+
copy_templates_overwrite(gets.strip.downcase, data, destination_path, source_path)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def copy_with_path_file_exist(data, source, destination)
|
|
132
|
+
if FileUtils.identical?(source, destination)
|
|
133
|
+
puts_info("Identical '#{data[:destination]}' file")
|
|
134
|
+
else
|
|
135
|
+
puts_info("Conflict with '#{data[:destination]}' file")
|
|
136
|
+
print_info(" Overwrite '#{data[:destination]}' file? [Yn]:")
|
|
137
|
+
copy_with_path_overwrite(gets.strip.downcase, data, source, destination)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def copy_templates_overwrite(answer, data, destination_path, source_path)
|
|
142
|
+
case answer
|
|
143
|
+
when 'y'
|
|
144
|
+
write_template(destination_path, source_path)
|
|
145
|
+
puts_info(" Forced '#{data[:destination]}' template")
|
|
146
|
+
when 'n'
|
|
147
|
+
puts_info(" Skipped '#{data[:destination]}' template")
|
|
148
|
+
else nil
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def copy_with_path_overwrite(answer, data, source, destination)
|
|
153
|
+
case answer
|
|
154
|
+
when 'y'
|
|
155
|
+
FileUtils.cp(source, destination)
|
|
156
|
+
puts_info(" Forced '#{data[:destination]}' file")
|
|
157
|
+
when 'n' then
|
|
158
|
+
puts_info(" Skipped '#{data[:destination]}' file")
|
|
159
|
+
else nil
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Parent class for all generators
|
|
165
|
+
class BaseGenerator
|
|
166
|
+
attr_reader :options
|
|
167
|
+
|
|
168
|
+
include Outputable
|
|
169
|
+
include Copyable
|
|
170
|
+
|
|
171
|
+
def initialize(options = {})
|
|
172
|
+
@options = options.symbolize_keys
|
|
173
|
+
super
|
|
174
|
+
end
|
|
103
175
|
end
|
|
104
|
-
end
|
|
176
|
+
end
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
require_relative '../base_generator'
|
|
2
2
|
module Howitzer
|
|
3
|
+
# This class responsible for configuration files generation
|
|
3
4
|
class ConfigGenerator < BaseGenerator
|
|
4
5
|
def manifest
|
|
5
6
|
{ files:
|
|
6
7
|
[
|
|
7
|
-
{ source: '
|
|
8
|
-
{ source: '
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
{ source: 'boot.rb', destination: 'config/boot.rb' },
|
|
9
|
+
{ source: 'custom.yml', destination: 'config/custom.yml' },
|
|
10
|
+
{ source: 'capybara.rb', destination: 'config/capybara.rb' },
|
|
11
|
+
{ source: 'default.yml', destination: 'config/default.yml' }
|
|
12
|
+
] }
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
protected
|
|
16
|
+
|
|
14
17
|
def banner
|
|
15
18
|
<<-EOF
|
|
16
19
|
* Config files generation ...
|
|
17
20
|
EOF
|
|
18
21
|
end
|
|
19
22
|
end
|
|
20
|
-
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
|
|
4
|
+
Bundler.require(:default)
|
|
5
|
+
|
|
6
|
+
Dir[
|
|
7
|
+
'./emails/**/*.rb',
|
|
8
|
+
'./web/sections/**/*.rb',
|
|
9
|
+
'./web/pages/**/*.rb',
|
|
10
|
+
'./prerequisites/models/**/*.rb',
|
|
11
|
+
'./prerequisites/factory_girl.rb'
|
|
12
|
+
].each { |f| require f }
|
|
13
|
+
|
|
14
|
+
String.send(:include, Howitzer::Utils::StringExtensions)
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
HOWITZER_KNOWN_DRIVERS = [
|
|
2
|
+
:selenium,
|
|
3
|
+
:selenium_grid,
|
|
4
|
+
:webkit,
|
|
5
|
+
:poltergeist,
|
|
6
|
+
:phantomjs,
|
|
7
|
+
:sauce,
|
|
8
|
+
:testingbot,
|
|
9
|
+
:browserstack
|
|
10
|
+
].freeze
|
|
11
|
+
|
|
12
|
+
unless HOWITZER_KNOWN_DRIVERS.include?(Howitzer.driver.to_s.to_sym)
|
|
13
|
+
raise Howitzer::UnknownDriverError, "Unknown '#{Howitzer.driver}' driver." \
|
|
14
|
+
" Check your settings, it should be one of #{HOWITZER_KNOWN_DRIVERS}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Capybara.configure do |config|
|
|
18
|
+
config.run_server = false
|
|
19
|
+
config.app_host = nil
|
|
20
|
+
config.asset_host = Howitzer.app_uri.origin
|
|
21
|
+
config.default_selector = :css
|
|
22
|
+
config.default_max_wait_time = Howitzer.capybara_wait_time
|
|
23
|
+
config.ignore_hidden_elements = true
|
|
24
|
+
config.match = :one
|
|
25
|
+
config.exact = true
|
|
26
|
+
config.visible_text_only = true
|
|
27
|
+
config.default_driver = Howitzer.driver.to_s.to_sym
|
|
28
|
+
config.javascript_driver = Howitzer.driver.to_s.to_sym
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
require 'howitzer/capybara_helpers'
|
|
32
|
+
|
|
33
|
+
# namespace for capybara helpers
|
|
34
|
+
module CapybaraHelpers
|
|
35
|
+
extend Howitzer::CapybaraHelpers
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# :selenium driver
|
|
39
|
+
|
|
40
|
+
Capybara.register_driver :selenium do |app|
|
|
41
|
+
params = { browser: Howitzer.selenium_browser.to_s.to_sym }
|
|
42
|
+
if CapybaraHelpers.ff_browser?
|
|
43
|
+
ff_profile = Selenium::WebDriver::Firefox::Profile.new.tap do |profile|
|
|
44
|
+
profile['network.http.phishy-userpass-length'] = 255
|
|
45
|
+
profile['browser.safebrowsing.malware.enabled'] = false
|
|
46
|
+
profile['network.automatic-ntlm-auth.allow-non-fqdn'] = true
|
|
47
|
+
profile['network.ntlm.send-lm-response'] = true
|
|
48
|
+
profile['network.automatic-ntlm-auth.trusted-uris'] = Howitzer.app_host
|
|
49
|
+
end
|
|
50
|
+
params[:profile] = ff_profile
|
|
51
|
+
end
|
|
52
|
+
Capybara::Selenium::Driver.new app, params
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# :webkit driver
|
|
56
|
+
|
|
57
|
+
if Howitzer.driver.to_sym == :webkit
|
|
58
|
+
CapybaraHelpers.load_driver_gem!(:webkit, 'capybara-webkit', 'capybara-webkit')
|
|
59
|
+
Capybara::Webkit.configure do |config|
|
|
60
|
+
config.allow_url(Howitzer.app_host)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# :poltergeist driver
|
|
65
|
+
|
|
66
|
+
if Howitzer.driver.to_sym == :poltergeist
|
|
67
|
+
CapybaraHelpers.load_driver_gem!(:poltergeist, 'capybara/poltergeist', 'poltergeist')
|
|
68
|
+
|
|
69
|
+
Capybara.register_driver :poltergeist do |app|
|
|
70
|
+
Capybara::Poltergeist::Driver.new(
|
|
71
|
+
app,
|
|
72
|
+
js_errors: !Howitzer.phantom_ignore_js_errors,
|
|
73
|
+
phantomjs_options: ["--ignore-ssl-errors=#{Howitzer.phantom_ignore_ssl_errors ? 'yes' : 'no'}"]
|
|
74
|
+
)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# :phantomjs driver
|
|
79
|
+
|
|
80
|
+
Capybara.register_driver :phantomjs do |app|
|
|
81
|
+
Capybara::Selenium::Driver.new(
|
|
82
|
+
app, browser: :phantomjs,
|
|
83
|
+
desired_capabilities: {
|
|
84
|
+
javascript_enabled: !Howitzer.phantom_ignore_js_errors
|
|
85
|
+
},
|
|
86
|
+
args: ["--ignore-ssl-errors=#{Howitzer.phantom_ignore_ssl_errors ? 'yes' : 'no'}"]
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# :sauce driver
|
|
91
|
+
|
|
92
|
+
Capybara.register_driver :sauce do |app|
|
|
93
|
+
caps = CapybaraHelpers.required_cloud_caps.merge(
|
|
94
|
+
maxDuration: Howitzer.cloud_max_duration,
|
|
95
|
+
idleTimeout: Howitzer.cloud_sauce_idle_timeout,
|
|
96
|
+
recordScreenshots: Howitzer.cloud_sauce_record_screenshots,
|
|
97
|
+
videoUploadOnPass: Howitzer.cloud_sauce_video_upload_on_pass
|
|
98
|
+
)
|
|
99
|
+
url = "http://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@ondemand.saucelabs.com:80/wd/hub"
|
|
100
|
+
CapybaraHelpers.cloud_driver(app, caps, url)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# :testingbot driver
|
|
104
|
+
|
|
105
|
+
Capybara.register_driver :testingbot do |app|
|
|
106
|
+
caps = CapybaraHelpers.required_cloud_caps.merge(
|
|
107
|
+
maxduration: Howitzer.cloud_max_duration,
|
|
108
|
+
idletimeout: Howitzer.cloud_testingbot_idle_timeout,
|
|
109
|
+
screenshot: Howitzer.cloud_testingbot_screenshots
|
|
110
|
+
)
|
|
111
|
+
url = "http://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@hub.testingbot.com/wd/hub"
|
|
112
|
+
CapybaraHelpers.cloud_driver(app, caps, url)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# :browserstack driver
|
|
116
|
+
|
|
117
|
+
Capybara.register_driver :browserstack do |app|
|
|
118
|
+
caps = CapybaraHelpers.required_cloud_caps.merge(
|
|
119
|
+
project: Howitzer.cloud_bstack_project,
|
|
120
|
+
build: Howitzer.cloud_bstack_build
|
|
121
|
+
)
|
|
122
|
+
caps[:resolution] = Howitzer.cloud_bstack_resolution if Howitzer.cloud_bstack_resolution.present?
|
|
123
|
+
caps[:device] = Howitzer.cloud_bstack_mobile_device if Howitzer.cloud_bstack_mobile_device.present?
|
|
124
|
+
url = "http://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@hub.browserstack.com/wd/hub"
|
|
125
|
+
CapybaraHelpers.cloud_driver(app, caps, url)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# :selenium_grid driver
|
|
129
|
+
|
|
130
|
+
Capybara.register_driver :selenium_grid do |app|
|
|
131
|
+
caps = if CapybaraHelpers.ie_browser?
|
|
132
|
+
Selenium::WebDriver::Remote::Capabilities.internet_explorer
|
|
133
|
+
elsif CapybaraHelpers.ff_browser?
|
|
134
|
+
Selenium::WebDriver::Remote::Capabilities.firefox
|
|
135
|
+
elsif CapybaraHelpers.chrome_browser?
|
|
136
|
+
Selenium::WebDriver::Remote::Capabilities.chrome
|
|
137
|
+
elsif CapybaraHelpers.safari_browser?
|
|
138
|
+
Selenium::WebDriver::Remote::Capabilities.safari
|
|
139
|
+
else
|
|
140
|
+
raise Howitzer::UnknownBrowserError, "Unknown '#{Howitzer.selenium_browser}' selenium_browser." \
|
|
141
|
+
' Check your settings, it should be one of' \
|
|
142
|
+
' [:ie, :iexplore, :ff, :firefox, :chrome, safari]'
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
Capybara::Selenium::Driver.new(app, browser: :remote, url: Howitzer.selenium_hub_url, desired_capabilities: caps)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
Capybara.save_path = Howitzer.log_dir
|
|
149
|
+
Capybara::Screenshot.register_driver(:phantomjs) do |driver, path|
|
|
150
|
+
driver.browser.save_screenshot path
|
|
151
|
+
end
|
|
152
|
+
Capybara::Screenshot.append_timestamp = false
|
|
153
|
+
Capybara::Screenshot.register_filename_prefix_formatter(:default) do
|
|
154
|
+
"capybara-screenshot-#{Gen.serial}"
|
|
155
|
+
end
|
|
156
|
+
Capybara::Screenshot.prune_strategy = :keep_last_run
|