howitzer 2.0.3 → 2.3.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 +5 -5
- data/CHANGELOG.md +69 -11
- data/LICENSE +1 -1
- data/README.md +21 -17
- data/bin/howitzer +7 -6
- data/generators/base_generator.rb +31 -17
- data/generators/config/config_generator.rb +11 -3
- data/generators/config/templates/boot.rb +3 -3
- data/generators/config/templates/capybara.rb +6 -131
- data/generators/config/templates/default.yml +34 -13
- data/generators/config/templates/drivers/appium.rb +25 -0
- data/generators/config/templates/drivers/browserstack.rb +23 -0
- data/generators/config/templates/drivers/crossbrowsertesting.rb +29 -0
- data/generators/config/templates/drivers/headless_chrome.rb +15 -0
- data/generators/config/templates/drivers/headless_firefox.rb +23 -0
- data/generators/config/templates/drivers/sauce.rb +25 -0
- data/generators/config/templates/drivers/selenium.rb +24 -0
- data/generators/config/templates/drivers/selenium_grid.rb +31 -0
- data/generators/config/templates/drivers/testingbot.rb +24 -0
- data/generators/cucumber/cucumber_generator.rb +2 -2
- data/generators/cucumber/templates/common_steps.rb +3 -3
- data/generators/cucumber/templates/cucumber.rake +5 -13
- data/generators/cucumber/templates/cuke_sniffer.rake +2 -2
- data/generators/cucumber/templates/env.rb +9 -1
- data/generators/cucumber/templates/hooks.rb +8 -2
- data/generators/cucumber/templates/transformers.rb +11 -25
- data/generators/emails/emails_generator.rb +2 -2
- data/generators/emails/templates/example_email.rb +1 -1
- data/generators/prerequisites/prerequisites_generator.rb +3 -3
- data/generators/prerequisites/templates/base.rb +1 -1
- data/generators/prerequisites/templates/{factory_girl.rb → factory_bot.rb} +7 -6
- data/generators/prerequisites/templates/users.rb +1 -1
- data/generators/root/root_generator.rb +3 -3
- data/generators/root/templates/Gemfile.erb +16 -22
- data/generators/rspec/rspec_generator.rb +2 -2
- data/generators/rspec/templates/rspec.rake +8 -8
- data/generators/rspec/templates/spec_helper.rb +6 -5
- data/generators/tasks/tasks_generator.rb +2 -2
- data/generators/turnip/templates/spec_helper.rb +6 -5
- data/generators/turnip/turnip_generator.rb +2 -2
- data/generators/web/templates/example_page.rb +1 -1
- data/generators/web/web_generator.rb +2 -2
- data/lib/howitzer/cache.rb +20 -19
- data/lib/howitzer/capybara_helpers.rb +58 -13
- data/lib/howitzer/email.rb +3 -2
- data/lib/howitzer/exceptions.rb +21 -20
- data/lib/howitzer/gmail_api/client.rb +31 -0
- data/lib/howitzer/gmail_api.rb +7 -0
- data/lib/howitzer/log.rb +6 -6
- data/lib/howitzer/mail_adapters/gmail.rb +96 -0
- data/lib/howitzer/mail_adapters/mailgun.rb +4 -2
- data/lib/howitzer/mail_adapters/mailtrap.rb +108 -0
- data/lib/howitzer/mailgun_api/client.rb +3 -2
- data/lib/howitzer/mailgun_api/connector.rb +1 -0
- data/lib/howitzer/mailgun_api/response.rb +1 -2
- data/lib/howitzer/mailtrap_api/client.rb +52 -0
- data/lib/howitzer/mailtrap_api.rb +7 -0
- data/lib/howitzer/meta/actions.rb +35 -0
- data/lib/howitzer/meta/element.rb +40 -0
- data/lib/howitzer/meta/entry.rb +62 -0
- data/lib/howitzer/meta/iframe.rb +41 -0
- data/lib/howitzer/meta/section.rb +30 -0
- data/lib/howitzer/meta.rb +11 -0
- data/lib/howitzer/utils/string_extensions.rb +6 -2
- data/lib/howitzer/version.rb +1 -1
- data/lib/howitzer/web/base_section.rb +1 -1
- data/lib/howitzer/web/capybara_context_holder.rb +1 -0
- data/lib/howitzer/web/capybara_methods_proxy.rb +15 -6
- data/lib/howitzer/web/element_dsl.rb +104 -44
- data/lib/howitzer/web/iframe_dsl.rb +23 -3
- data/lib/howitzer/web/page.rb +16 -4
- data/lib/howitzer/web/page_dsl.rb +19 -7
- data/lib/howitzer/web/page_validator.rb +27 -26
- data/lib/howitzer/web/section.rb +13 -2
- data/lib/howitzer/web/section_dsl.rb +65 -30
- data/lib/howitzer.rb +66 -10
- metadata +67 -133
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.rubocop.yml +0 -44
- data/.ruby-gemset +0 -1
- data/.travis.yml +0 -7
- data/Gemfile +0 -13
- data/MAINTENANCE.md +0 -32
- data/Rakefile +0 -22
- data/features/cli_help.feature +0 -31
- data/features/cli_new.feature +0 -349
- data/features/cli_unknown.feature +0 -17
- data/features/cli_update.feature +0 -178
- data/features/cli_version.feature +0 -14
- data/features/step_definitions/common_steps.rb +0 -29
- data/features/support/env.rb +0 -1
- data/features/support/transformers.rb +0 -3
- data/generators/root/templates/.gitignore +0 -21
- data/generators/root/templates/.rubocop.yml +0 -35
- data/generators/turnip/templates/.rspec +0 -1
- data/howitzer.gemspec +0 -37
- data/lib/howitzer/mail_adapters/debugmail.rb +0 -0
- data/spec/config/custom.yml +0 -9
- data/spec/spec_helper.rb +0 -72
- data/spec/support/generator_helper.rb +0 -21
- data/spec/support/logger_helper.rb +0 -13
- data/spec/support/mailgun_unit_client.rb +0 -68
- data/spec/support/shared_examples/capybara_context_holder.rb +0 -33
- data/spec/support/shared_examples/capybara_methods_proxy.rb +0 -94
- data/spec/support/shared_examples/dynamic_section_methods.rb +0 -35
- data/spec/support/shared_examples/element_dsl.rb +0 -242
- data/spec/unit/generators/base_generator_spec.rb +0 -272
- data/spec/unit/generators/config_generator_spec.rb +0 -38
- data/spec/unit/generators/cucumber_generator_spec.rb +0 -62
- data/spec/unit/generators/emails_generator_spec.rb +0 -35
- data/spec/unit/generators/prerequisites_generator_spec.rb +0 -53
- data/spec/unit/generators/root_generator_spec.rb +0 -72
- data/spec/unit/generators/rspec_generator_spec.rb +0 -36
- data/spec/unit/generators/tasks_generator_spec.rb +0 -31
- data/spec/unit/generators/turnip_generator_spec.rb +0 -52
- data/spec/unit/generators/web_generator_spec.rb +0 -52
- data/spec/unit/lib/cache_spec.rb +0 -85
- data/spec/unit/lib/capybara_helpers_spec.rb +0 -696
- data/spec/unit/lib/email_spec.rb +0 -186
- data/spec/unit/lib/howitzer_spec.rb +0 -40
- data/spec/unit/lib/init_spec.rb +0 -2
- data/spec/unit/lib/log_spec.rb +0 -122
- data/spec/unit/lib/mail_adapters/abstract_spec.rb +0 -62
- data/spec/unit/lib/mail_adapters/mailgun_spec.rb +0 -163
- data/spec/unit/lib/mailgun_api/client_spec.rb +0 -58
- data/spec/unit/lib/mailgun_api/connector_spec.rb +0 -54
- data/spec/unit/lib/mailgun_api/response_spec.rb +0 -28
- data/spec/unit/lib/utils/string_extensions_spec.rb +0 -77
- data/spec/unit/lib/web/base_section_spec.rb +0 -43
- data/spec/unit/lib/web/element_dsl_spec.rb +0 -22
- data/spec/unit/lib/web/iframe_dsl_spec.rb +0 -144
- data/spec/unit/lib/web/page_dsl_spec.rb +0 -74
- data/spec/unit/lib/web/page_spec.rb +0 -349
- data/spec/unit/lib/web/page_validator_spec.rb +0 -276
- data/spec/unit/lib/web/section_dsl_spec.rb +0 -165
- data/spec/unit/lib/web/section_spec.rb +0 -63
- data/spec/unit/version_spec.rb +0 -8
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
# See https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit
|
|
5
|
-
#
|
|
6
|
-
# gem 'capybara-webkit'
|
|
3
|
+
ruby '>=2.6.8'
|
|
7
4
|
|
|
8
|
-
gem 'howitzer'
|
|
9
|
-
# Uncomment it if you are going to use 'poltergeist' driver. PhantomJS should be installed.
|
|
10
|
-
# See https://github.com/jnicklas/capybara#poltergeist
|
|
11
|
-
# gem 'poltergeist', git: 'https://github.com/teampoltergeist/poltergeist.git', branch: :master
|
|
12
|
-
gem 'rest-client'
|
|
13
|
-
gem 'repeater'
|
|
14
|
-
gem 'factory_girl'
|
|
15
5
|
gem 'capybara-screenshot'
|
|
16
|
-
|
|
17
|
-
gem '
|
|
18
|
-
gem '
|
|
19
|
-
gem '
|
|
20
|
-
<% elsif rspec %>
|
|
21
|
-
gem 'rspec', '~>3.2'
|
|
22
|
-
<% elsif turnip %>
|
|
23
|
-
gem 'rspec', '~>3.2'
|
|
24
|
-
gem 'turnip'
|
|
25
|
-
<% end %>
|
|
26
|
-
gem 'rubocop'
|
|
6
|
+
<%= "gem 'cucumber', '>=3.0', '<7'\n" if cucumber -%>
|
|
7
|
+
<%= "gem 'cuke_sniffer', require: false\n" if cucumber -%>
|
|
8
|
+
gem 'factory_bot'
|
|
9
|
+
gem 'howitzer'
|
|
27
10
|
gem 'pry'
|
|
28
11
|
gem 'pry-byebug'
|
|
12
|
+
gem 'repeater'
|
|
13
|
+
gem 'rest-client'
|
|
14
|
+
<%= "gem 'rspec', '~>3.2'\n" if rspec || turnip -%>
|
|
15
|
+
gem 'rubocop'
|
|
16
|
+
<%= "gem 'rubocop-rspec'\n" if rspec || turnip -%>
|
|
17
|
+
<%= "gem 'turnip'\n" if turnip -%>
|
|
18
|
+
<%= "gem 'syntax'\n" if cucumber -%>
|
|
19
|
+
|
|
20
|
+
# Uncomment it if you are going to use 'appium' driver. Appium and Android SDK should be installed.
|
|
21
|
+
# See https://appium.io/docs/en/about-appium/getting-started/
|
|
22
|
+
# gem 'appium_capybara'
|
|
@@ -10,43 +10,43 @@ end
|
|
|
10
10
|
|
|
11
11
|
RSpec::Core::RakeTask.new(:rspec, 'Run all rspec scenarios') do |t|
|
|
12
12
|
Howitzer.current_rake_task = t.name
|
|
13
|
-
t.
|
|
13
|
+
t.rspec_opts = opts.call(t.name)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
RSpec::Core::RakeTask.new(:features, 'Run all workable scenarios (without @wip and @bug tags)') do |t|
|
|
17
17
|
Howitzer.current_rake_task = t.name
|
|
18
|
-
t.
|
|
18
|
+
t.rspec_opts = "#{opts.call(t.name)} --tag ~wip --tag ~bug"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
namespace :features do
|
|
22
22
|
RSpec::Core::RakeTask.new(:wip, 'Run scenarios in progress (with @wip tag)') do |t|
|
|
23
23
|
Howitzer.current_rake_task = t.name
|
|
24
|
-
t.
|
|
24
|
+
t.rspec_opts = "#{opts.call(t.name)} --tag wip"
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
RSpec::Core::RakeTask.new(:bug, 'Run scenarios with known bugs (with @bug tag)') do |t|
|
|
28
28
|
Howitzer.current_rake_task = t.name
|
|
29
|
-
t.
|
|
29
|
+
t.rspec_opts = "#{opts.call(t.name)} --tag bug"
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
RSpec::Core::RakeTask.new(:smoke, 'Run workable smoke scenarios (with @smoke tag)') do |t|
|
|
33
33
|
Howitzer.current_rake_task = t.name
|
|
34
|
-
t.
|
|
34
|
+
t.rspec_opts = "#{opts.call(t.name)} --tag smoke --tag ~wip --tag ~bug"
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
RSpec::Core::RakeTask.new(:bvt, 'Run workable build verification test scenarios') do |t|
|
|
38
38
|
Howitzer.current_rake_task = t.name
|
|
39
|
-
t.
|
|
39
|
+
t.rspec_opts = "#{opts.call(t.name)} --tag ~wip --tag ~bug --tag ~p1 --tag ~p2 --tag ~smoke"
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
RSpec::Core::RakeTask.new(:p1, 'Run workable scenarios with normal priority (with @p1 tag)') do |t|
|
|
43
43
|
Howitzer.current_rake_task = t.name
|
|
44
|
-
t.
|
|
44
|
+
t.rspec_opts = "#{opts.call(t.name)} --tag p1 --tag ~wip --tag ~bug"
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
RSpec::Core::RakeTask.new(:p2, 'Run workable scenarios with low priority (with @p2 tag)') do |t|
|
|
48
48
|
Howitzer.current_rake_task = t.name
|
|
49
|
-
t.
|
|
49
|
+
t.rspec_opts = "#{opts.call(t.name)} --tag p2 --tag ~wip --tag ~bug"
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
@@ -2,7 +2,7 @@ require 'capybara/rspec/features'
|
|
|
2
2
|
require_relative '../config/boot'
|
|
3
3
|
require_relative '../config/capybara'
|
|
4
4
|
|
|
5
|
-
Dir['./spec/support/**/*.rb'].each { |f| require f }
|
|
5
|
+
Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
|
|
6
6
|
|
|
7
7
|
RSpec.configure do |config|
|
|
8
8
|
Howitzer::Log.settings_as_formatted_text
|
|
@@ -10,13 +10,14 @@ RSpec.configure do |config|
|
|
|
10
10
|
Howitzer::Cache.store(:cloud, :start_time, Time.now.utc)
|
|
11
11
|
Howitzer::Cache.store(:cloud, :status, true)
|
|
12
12
|
|
|
13
|
-
config.include
|
|
13
|
+
config.include FactoryBot::Syntax::Methods
|
|
14
14
|
|
|
15
15
|
config.disable_monkey_patching!
|
|
16
16
|
config.color = true
|
|
17
17
|
config.wait_timeout = Howitzer.rspec_wait_timeout
|
|
18
|
+
config.order = Howitzer.test_order.presence || :defined
|
|
18
19
|
|
|
19
|
-
config.before
|
|
20
|
+
config.before do
|
|
20
21
|
scenario_name =
|
|
21
22
|
if RSpec.current_example.description.blank?
|
|
22
23
|
RSpec.current_example.metadata[:full_description]
|
|
@@ -27,12 +28,12 @@ RSpec.configure do |config|
|
|
|
27
28
|
@session_start = CapybaraHelpers.duration(Time.now.utc - Howitzer::Cache.extract(:cloud, :start_time))
|
|
28
29
|
end
|
|
29
30
|
|
|
30
|
-
config.after
|
|
31
|
+
config.after do
|
|
31
32
|
Howitzer::Cache.clear_all_ns
|
|
32
33
|
if CapybaraHelpers.cloud_driver?
|
|
33
34
|
session_end = CapybaraHelpers.duration(Time.now.utc - Howitzer::Cache.extract(:cloud, :start_time))
|
|
34
35
|
Howitzer::Log.info "CLOUD VIDEO #{@session_start} - #{session_end}" \
|
|
35
|
-
|
|
36
|
+
" URL: #{CapybaraHelpers.cloud_resource_path(:video)}"
|
|
36
37
|
elsif CapybaraHelpers.ie_browser?
|
|
37
38
|
Howitzer::Log.info 'IE reset session'
|
|
38
39
|
Capybara.current_session.execute_script("void(document.execCommand('ClearAuthenticationCache', false));")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require_relative '../config/boot'
|
|
2
2
|
require_relative '../config/capybara'
|
|
3
3
|
|
|
4
|
-
Dir['./spec/support/**/*.rb'].each { |f| require f }
|
|
4
|
+
Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
|
|
5
5
|
|
|
6
6
|
RSpec.configure do |config|
|
|
7
7
|
Howitzer::Log.settings_as_formatted_text
|
|
@@ -9,13 +9,14 @@ RSpec.configure do |config|
|
|
|
9
9
|
Howitzer::Cache.store(:cloud, :start_time, Time.now.utc)
|
|
10
10
|
Howitzer::Cache.store(:cloud, :status, true)
|
|
11
11
|
|
|
12
|
-
config.include
|
|
12
|
+
config.include FactoryBot::Syntax::Methods
|
|
13
13
|
|
|
14
14
|
config.disable_monkey_patching!
|
|
15
15
|
config.color = true
|
|
16
16
|
config.wait_timeout = Howitzer.rspec_wait_timeout
|
|
17
|
+
config.order = Howitzer.test_order.presence || :defined
|
|
17
18
|
|
|
18
|
-
config.before
|
|
19
|
+
config.before do
|
|
19
20
|
scenario_name =
|
|
20
21
|
if RSpec.current_example.description.blank?
|
|
21
22
|
RSpec.current_example.metadata[:full_description]
|
|
@@ -26,12 +27,12 @@ RSpec.configure do |config|
|
|
|
26
27
|
@session_start = CapybaraHelpers.duration(Time.now.utc - Howitzer::Cache.extract(:cloud, :start_time))
|
|
27
28
|
end
|
|
28
29
|
|
|
29
|
-
config.after
|
|
30
|
+
config.after do
|
|
30
31
|
Howitzer::Cache.clear_all_ns
|
|
31
32
|
if CapybaraHelpers.cloud_driver?
|
|
32
33
|
session_end = CapybaraHelpers.duration(Time.now.utc - Howitzer::Cache.extract(:cloud, :start_time))
|
|
33
34
|
Howitzer::Log.info "CLOUD VIDEO #{@session_start} - #{session_end}" \
|
|
34
|
-
|
|
35
|
+
" URL: #{CapybaraHelpers.cloud_resource_path(:video)}"
|
|
35
36
|
elsif CapybaraHelpers.ie_browser?
|
|
36
37
|
Howitzer::Log.info 'IE reset session'
|
|
37
38
|
Capybara.current_session.execute_script("void(document.execCommand('ClearAuthenticationCache', false));")
|
data/lib/howitzer/cache.rb
CHANGED
|
@@ -4,7 +4,7 @@ module Howitzer
|
|
|
4
4
|
# Data can be stored in memory using this class
|
|
5
5
|
#
|
|
6
6
|
module Cache
|
|
7
|
-
SPECIAL_NS_LIST = [:cloud].freeze
|
|
7
|
+
SPECIAL_NS_LIST = [:cloud].freeze # :nodoc:
|
|
8
8
|
@data ||= {}
|
|
9
9
|
|
|
10
10
|
class << self
|
|
@@ -12,35 +12,35 @@ module Howitzer
|
|
|
12
12
|
|
|
13
13
|
# Saves data into memory. Marking by a namespace and a key
|
|
14
14
|
#
|
|
15
|
-
# @param
|
|
15
|
+
# @param namespace [String] a namespace
|
|
16
16
|
# @param key [String] a key that should be uniq within the namespace
|
|
17
17
|
# @param value [Object] everything you want to store in Memory
|
|
18
18
|
# @raise [NoDataError] if the namespace missing
|
|
19
19
|
|
|
20
|
-
def store(
|
|
21
|
-
check_ns(
|
|
22
|
-
@data[
|
|
20
|
+
def store(namespace, key, value)
|
|
21
|
+
check_ns(namespace)
|
|
22
|
+
@data[namespace][key] = value
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
# Gets data from memory. Can get all namespace or single data value in namespace using key
|
|
26
26
|
#
|
|
27
|
-
# @param
|
|
27
|
+
# @param namespace [String] a namespace
|
|
28
28
|
# @param key [String] key that isn't necessary required
|
|
29
29
|
# @return [Object, Hash] all data from the namespace if the key is ommited, otherwise returs
|
|
30
30
|
# all data for the namespace
|
|
31
31
|
# @raise [NoDataError] if the namespace missing
|
|
32
32
|
|
|
33
|
-
def extract(
|
|
34
|
-
check_ns(
|
|
35
|
-
key ? @data[
|
|
33
|
+
def extract(namespace, key = nil)
|
|
34
|
+
check_ns(namespace)
|
|
35
|
+
key ? @data[namespace][key] : @data[namespace]
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
# Deletes all data from a namespace
|
|
39
39
|
#
|
|
40
|
-
# @param
|
|
40
|
+
# @param namespace [String] a namespace
|
|
41
41
|
|
|
42
|
-
def clear_ns(
|
|
43
|
-
init_ns(
|
|
42
|
+
def clear_ns(namespace)
|
|
43
|
+
init_ns(namespace)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
# Deletes all namespaces with data
|
|
@@ -53,17 +53,18 @@ module Howitzer
|
|
|
53
53
|
|
|
54
54
|
private
|
|
55
55
|
|
|
56
|
-
def check_ns(
|
|
57
|
-
raise Howitzer::NoDataError, 'Data storage namespace can not be empty' unless
|
|
58
|
-
|
|
56
|
+
def check_ns(namespace)
|
|
57
|
+
raise Howitzer::NoDataError, 'Data storage namespace can not be empty' unless namespace
|
|
58
|
+
|
|
59
|
+
init_ns(namespace) if ns_absent?(namespace)
|
|
59
60
|
end
|
|
60
61
|
|
|
61
|
-
def ns_absent?(
|
|
62
|
-
!@data.key?(
|
|
62
|
+
def ns_absent?(namespace)
|
|
63
|
+
!@data.key?(namespace)
|
|
63
64
|
end
|
|
64
65
|
|
|
65
|
-
def init_ns(
|
|
66
|
-
@data[
|
|
66
|
+
def init_ns(namespace)
|
|
67
|
+
@data[namespace] = {}
|
|
67
68
|
end
|
|
68
69
|
end
|
|
69
70
|
end
|
|
@@ -1,16 +1,52 @@
|
|
|
1
1
|
require 'rest-client'
|
|
2
2
|
require 'howitzer/exceptions'
|
|
3
3
|
|
|
4
|
+
# There is an issue with supporting Ruby 3 by Selenium Webdriver 3.x version
|
|
5
|
+
# https://github.com/SeleniumHQ/selenium/issues/9001
|
|
6
|
+
# Migration to Selenium Webdriver 4 is planned when it will be released without alfa, beta stages.
|
|
7
|
+
if Gem::Requirement.new('>=3').satisfied_by?(Gem::Version.new(RUBY_VERSION)) ||
|
|
8
|
+
Gem::Requirement.new(['>=3', '<4']).satisfied_by?(Gem::Version.new(Selenium::WebDriver::VERSION))
|
|
9
|
+
module Selenium
|
|
10
|
+
module WebDriver
|
|
11
|
+
module Remote
|
|
12
|
+
class Bridge # rubocop:disable Style/Documentation
|
|
13
|
+
class << self
|
|
14
|
+
alias original_handshake handshake
|
|
15
|
+
|
|
16
|
+
def handshake(opts = {})
|
|
17
|
+
original_handshake(**opts)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
4
26
|
module Howitzer
|
|
5
27
|
# This module holds capybara helpers methods
|
|
6
28
|
module CapybaraHelpers
|
|
7
|
-
CHECK_YOUR_SETTINGS_MSG = 'Please check your settings'.freeze
|
|
29
|
+
CHECK_YOUR_SETTINGS_MSG = 'Please check your settings'.freeze # :nodoc:
|
|
30
|
+
HOWITZER_KNOWN_BROWSERS = [ # :nodoc:
|
|
31
|
+
CLOUD_BROWSERS = [
|
|
32
|
+
SAUCE = :sauce,
|
|
33
|
+
TESTINGBOT = :testingbot,
|
|
34
|
+
BROWSERSTACK = :browserstack,
|
|
35
|
+
CROSSBROWSERTESTING = :crossbrowsertesting
|
|
36
|
+
].freeze,
|
|
37
|
+
LOCAL_BROWSERS = [
|
|
38
|
+
HEADLESS_CHROME = :headless_chrome,
|
|
39
|
+
HEADLESS_FIREFOX = :headless_firefox,
|
|
40
|
+
SELENIUM = :selenium,
|
|
41
|
+
SELENIUM_GRID = :selenium_grid
|
|
42
|
+
].freeze
|
|
43
|
+
].freeze
|
|
8
44
|
|
|
9
45
|
# @return [Boolean] true if current driver related with SauceLab,
|
|
10
46
|
# Testingbot or Browserstack cloud service
|
|
11
47
|
|
|
12
48
|
def cloud_driver?
|
|
13
|
-
|
|
49
|
+
CLOUD_BROWSERS.include?(Howitzer.driver.to_sym)
|
|
14
50
|
end
|
|
15
51
|
|
|
16
52
|
# @return [Boolean] whether or not current browser is
|
|
@@ -64,7 +100,7 @@ module Howitzer
|
|
|
64
100
|
|
|
65
101
|
def update_cloud_job_status(json_data = {})
|
|
66
102
|
case Howitzer.driver.to_sym
|
|
67
|
-
when
|
|
103
|
+
when SAUCE then update_sauce_job_status(json_data)
|
|
68
104
|
else
|
|
69
105
|
'[NOT IMPLEMENTED]'
|
|
70
106
|
end
|
|
@@ -102,7 +138,8 @@ module Howitzer
|
|
|
102
138
|
|
|
103
139
|
def cloud_driver(app, caps, url)
|
|
104
140
|
http_client = ::Selenium::WebDriver::Remote::Http::Default.new
|
|
105
|
-
http_client.
|
|
141
|
+
http_client.read_timeout = Howitzer.cloud_http_idle_timeout
|
|
142
|
+
http_client.open_timeout = Howitzer.cloud_http_idle_timeout
|
|
106
143
|
|
|
107
144
|
options = {
|
|
108
145
|
url: url,
|
|
@@ -110,7 +147,7 @@ module Howitzer
|
|
|
110
147
|
http_client: http_client,
|
|
111
148
|
browser: :remote
|
|
112
149
|
}
|
|
113
|
-
driver = Capybara::Selenium::Driver.new(app, options)
|
|
150
|
+
driver = Capybara::Selenium::Driver.new(app, **options)
|
|
114
151
|
driver.browser.file_detector = remote_file_detector
|
|
115
152
|
driver
|
|
116
153
|
end
|
|
@@ -121,7 +158,7 @@ module Howitzer
|
|
|
121
158
|
|
|
122
159
|
def cloud_resource_path(kind)
|
|
123
160
|
case Howitzer.driver.to_sym
|
|
124
|
-
when
|
|
161
|
+
when SAUCE then sauce_resource_path(kind)
|
|
125
162
|
else
|
|
126
163
|
'[NOT IMPLEMENTED]'
|
|
127
164
|
end
|
|
@@ -136,24 +173,32 @@ module Howitzer
|
|
|
136
173
|
|
|
137
174
|
def cloud_browser?(*browser_aliases)
|
|
138
175
|
unless Howitzer.cloud_browser_name.nil?
|
|
139
|
-
return browser_aliases.include?(Howitzer.cloud_browser_name.to_s.to_sym)
|
|
176
|
+
return browser_aliases.include?(Howitzer.cloud_browser_name.to_s.downcase.to_sym)
|
|
140
177
|
end
|
|
178
|
+
|
|
141
179
|
raise Howitzer::CloudBrowserNotSpecifiedError, CHECK_YOUR_SETTINGS_MSG
|
|
142
180
|
end
|
|
143
181
|
|
|
144
182
|
def selenium_browser?(*browser_aliases)
|
|
145
|
-
unless Howitzer.selenium_browser.nil?
|
|
146
|
-
|
|
147
|
-
end
|
|
183
|
+
return browser_aliases.include?(Howitzer.selenium_browser.to_s.to_sym) unless Howitzer.selenium_browser.nil?
|
|
184
|
+
|
|
148
185
|
raise Howitzer::SelBrowserNotSpecifiedError, CHECK_YOUR_SETTINGS_MSG
|
|
149
186
|
end
|
|
150
187
|
|
|
151
188
|
def selenium_driver?
|
|
152
|
-
Howitzer.driver.to_sym ==
|
|
189
|
+
Howitzer.driver.to_sym == SELENIUM
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def headless_chrome_driver?
|
|
193
|
+
Howitzer.driver.to_sym == HEADLESS_CHROME
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def headless_firefox_driver?
|
|
197
|
+
Howitzer.driver.to_sym == HEADLESS_FIREFOX
|
|
153
198
|
end
|
|
154
199
|
|
|
155
200
|
def selenium_grid_driver?
|
|
156
|
-
Howitzer.driver.to_sym ==
|
|
201
|
+
Howitzer.driver.to_sym == SELENIUM_GRID
|
|
157
202
|
end
|
|
158
203
|
|
|
159
204
|
def prefix_name
|
|
@@ -174,7 +219,7 @@ module Howitzer
|
|
|
174
219
|
end
|
|
175
220
|
|
|
176
221
|
def update_sauce_job_status(json_data = {})
|
|
177
|
-
host = "
|
|
222
|
+
host = "https://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@saucelabs.com"
|
|
178
223
|
path = "/rest/v1/#{Howitzer.cloud_auth_login}/jobs/#{session_id}"
|
|
179
224
|
url = "#{host}#{path}"
|
|
180
225
|
::RestClient.put url, json_data.to_json, content_type: :json, accept: :json
|
data/lib/howitzer/email.rb
CHANGED
|
@@ -12,6 +12,7 @@ module Howitzer
|
|
|
12
12
|
|
|
13
13
|
def self.adapter
|
|
14
14
|
return @adapter if @adapter
|
|
15
|
+
|
|
15
16
|
self.adapter = Howitzer.mail_adapter.to_sym
|
|
16
17
|
@adapter
|
|
17
18
|
end
|
|
@@ -78,8 +79,8 @@ module Howitzer
|
|
|
78
79
|
def self.find_by_recipient(recipient, params = {})
|
|
79
80
|
if defined?(subject_value).nil? || subject_value.nil?
|
|
80
81
|
raise Howitzer::NoEmailSubjectError, "Please specify email subject. For example:\n" \
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
"class SomeEmail < Howitzer::Email\n" \
|
|
83
|
+
" subject ‘some subject text’\nend"
|
|
83
84
|
end
|
|
84
85
|
new(adapter.find(recipient, expand_subject(params), wait: wait_time_value))
|
|
85
86
|
end
|
data/lib/howitzer/exceptions.rb
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
# This module holds all custom howitzer exceptions
|
|
2
2
|
module Howitzer
|
|
3
|
-
CommunicationError = Class.new(StandardError)
|
|
4
|
-
ParseError = Class.new(StandardError)
|
|
5
|
-
InvalidApiKeyError = Class.new(StandardError)
|
|
6
|
-
BadElementParamsError = Class.new(StandardError)
|
|
7
|
-
NoValidationError = Class.new(StandardError)
|
|
8
|
-
UnknownValidationError = Class.new(StandardError)
|
|
9
|
-
EmailNotFoundError = Class.new(StandardError)
|
|
10
|
-
NoAttachmentsError = Class.new(StandardError)
|
|
11
|
-
DriverNotSpecifiedError = Class.new(StandardError)
|
|
12
|
-
UnknownDriverError = Class.new(StandardError)
|
|
13
|
-
CloudBrowserNotSpecifiedError = Class.new(StandardError)
|
|
14
|
-
SelBrowserNotSpecifiedError = Class.new(StandardError)
|
|
15
|
-
UnknownBrowserError = Class.new(StandardError)
|
|
16
|
-
IncorrectPageError = Class.new(StandardError)
|
|
17
|
-
AmbiguousPageMatchingError = Class.new(StandardError)
|
|
18
|
-
NoMailAdapterError = Class.new(StandardError)
|
|
19
|
-
NoPathForPageError = Class.new(StandardError)
|
|
20
|
-
NoEmailSubjectError = Class.new(StandardError)
|
|
21
|
-
NoDataError = Class.new(StandardError)
|
|
22
|
-
UndefinedElementError = Class.new(StandardError)
|
|
3
|
+
CommunicationError = Class.new(StandardError) # :nodoc:
|
|
4
|
+
ParseError = Class.new(StandardError) # :nodoc:
|
|
5
|
+
InvalidApiKeyError = Class.new(StandardError) # :nodoc:
|
|
6
|
+
BadElementParamsError = Class.new(StandardError) # :nodoc:
|
|
7
|
+
NoValidationError = Class.new(StandardError) # :nodoc:
|
|
8
|
+
UnknownValidationError = Class.new(StandardError) # :nodoc:
|
|
9
|
+
EmailNotFoundError = Class.new(StandardError) # :nodoc:
|
|
10
|
+
NoAttachmentsError = Class.new(StandardError) # :nodoc:
|
|
11
|
+
DriverNotSpecifiedError = Class.new(StandardError) # :nodoc:
|
|
12
|
+
UnknownDriverError = Class.new(StandardError) # :nodoc:
|
|
13
|
+
CloudBrowserNotSpecifiedError = Class.new(StandardError) # :nodoc:
|
|
14
|
+
SelBrowserNotSpecifiedError = Class.new(StandardError) # :nodoc:
|
|
15
|
+
UnknownBrowserError = Class.new(StandardError) # :nodoc:
|
|
16
|
+
IncorrectPageError = Class.new(StandardError) # :nodoc:
|
|
17
|
+
AmbiguousPageMatchingError = Class.new(StandardError) # :nodoc:
|
|
18
|
+
NoMailAdapterError = Class.new(StandardError) # :nodoc:
|
|
19
|
+
NoPathForPageError = Class.new(StandardError) # :nodoc:
|
|
20
|
+
NoEmailSubjectError = Class.new(StandardError) # :nodoc:
|
|
21
|
+
NoDataError = Class.new(StandardError) # :nodoc:
|
|
22
|
+
UndefinedElementError = Class.new(StandardError) # :nodoc:
|
|
23
|
+
UndefinedSexySettingError = Class.new(StandardError) # :nodoc:
|
|
23
24
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Howitzer
|
|
2
|
+
module GmailApi
|
|
3
|
+
# A GmailApi::Client object is used to communicate with the Gmail API.
|
|
4
|
+
class Client
|
|
5
|
+
def self.load_gmail_gem!
|
|
6
|
+
require 'gmail'
|
|
7
|
+
rescue LoadError
|
|
8
|
+
raise LoadError, "Unable to load `gmail` library, please add following code to your Gemfile:\n\ngem 'gmail'"
|
|
9
|
+
end
|
|
10
|
+
load_gmail_gem!
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
self.client = Gmail.connect(Howitzer.gmail_login, Howitzer.gmail_password)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Finds message according to given parameters
|
|
17
|
+
#
|
|
18
|
+
# @param recipient [String] this is recipient mail address for message filtering
|
|
19
|
+
# @param subject [String] this is subject of the message to filter particular message
|
|
20
|
+
# @return [Gmail::Message] gmail message object
|
|
21
|
+
|
|
22
|
+
def find_message(recipient, subject)
|
|
23
|
+
client.inbox.emails(to: recipient, subject: subject).last
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
attr_accessor :client
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/howitzer/log.rb
CHANGED
|
@@ -80,13 +80,13 @@ module Howitzer
|
|
|
80
80
|
Logger['ruby_log'].trace = true
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
# :nocov:
|
|
84
84
|
def log_without_formatting
|
|
85
85
|
self.base_formatter = blank_formatter
|
|
86
86
|
yield
|
|
87
87
|
self.base_formatter = default_formatter
|
|
88
88
|
end
|
|
89
|
-
|
|
89
|
+
# :nocov:
|
|
90
90
|
|
|
91
91
|
def console_log
|
|
92
92
|
StdoutOutputter.new(:console).tap { |o| o.only_at(INFO, DEBUG, WARN) }
|
|
@@ -96,13 +96,13 @@ module Howitzer
|
|
|
96
96
|
StderrOutputter.new(:error, 'level' => ERROR)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
# :nocov:
|
|
100
100
|
def blank_formatter
|
|
101
101
|
PatternFormatter.new(pattern: '%m')
|
|
102
102
|
end
|
|
103
|
-
|
|
103
|
+
# :nocov:
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
# :nocov:
|
|
106
106
|
def default_formatter
|
|
107
107
|
params = if Howitzer.hide_datetime_from_log
|
|
108
108
|
{ pattern: '[%l] %m' }
|
|
@@ -111,7 +111,7 @@ module Howitzer
|
|
|
111
111
|
end
|
|
112
112
|
PatternFormatter.new(params)
|
|
113
113
|
end
|
|
114
|
-
|
|
114
|
+
# :nocov:
|
|
115
115
|
|
|
116
116
|
def base_formatter=(formatter)
|
|
117
117
|
@logger.outputters.each { |outputter| outputter.formatter = formatter }
|