howitzer 2.1.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +44 -1
- data/LICENSE +1 -1
- data/README.md +19 -17
- data/generators/base_generator.rb +5 -7
- data/generators/config/config_generator.rb +3 -4
- data/generators/config/templates/boot.rb +2 -2
- data/generators/config/templates/capybara.rb +4 -5
- data/generators/config/templates/default.yml +21 -11
- data/generators/config/templates/drivers/browserstack.rb +31 -4
- data/generators/config/templates/drivers/crossbrowsertesting.rb +9 -11
- data/generators/config/templates/drivers/headless_chrome.rb +1 -1
- data/generators/config/templates/drivers/headless_firefox.rb +23 -0
- data/generators/config/templates/drivers/lambdatest.rb +30 -0
- data/generators/config/templates/drivers/sauce.rb +30 -2
- data/generators/config/templates/drivers/selenium.rb +1 -1
- data/generators/config/templates/drivers/selenium_grid.rb +3 -3
- data/generators/config/templates/drivers/testingbot.rb +29 -2
- data/generators/cucumber/templates/cuke_sniffer.rake +2 -2
- data/generators/cucumber/templates/env.rb +8 -0
- data/generators/cucumber/templates/hooks.rb +9 -3
- data/generators/cucumber/templates/transformers.rb +1 -1
- data/generators/prerequisites/templates/factory_bot.rb +2 -1
- data/generators/root/root_generator.rb +1 -1
- data/generators/root/templates/Gemfile.erb +4 -10
- data/generators/rspec/templates/spec_helper.rb +6 -5
- data/generators/turnip/templates/spec_helper.rb +6 -5
- data/generators/web/templates/example_page.rb +1 -1
- data/lib/howitzer/cache.rb +20 -19
- data/lib/howitzer/capybara_helpers.rb +59 -14
- data/lib/howitzer/email.rb +3 -2
- data/lib/howitzer/exceptions.rb +21 -21
- data/lib/howitzer/gmail_api/client.rb +13 -4
- data/lib/howitzer/log.rb +6 -6
- data/lib/howitzer/mail_adapters/gmail.rb +3 -0
- data/lib/howitzer/mail_adapters/mailgun.rb +3 -1
- data/lib/howitzer/mail_adapters/mailtrap.rb +3 -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 +1 -1
- 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 +4 -2
- data/lib/howitzer/web/page.rb +14 -14
- data/lib/howitzer/web/page_dsl.rb +18 -6
- 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 +40 -0
- metadata +31 -157
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.rubocop.yml +0 -51
- data/.ruby-gemset +0 -1
- data/.travis.yml +0 -7
- data/Gemfile +0 -14
- data/ISSUE_TEMPLATE.md +0 -16
- data/MAINTENANCE.md +0 -32
- data/Rakefile +0 -38
- data/features/cli_help.feature +0 -31
- data/features/cli_new.feature +0 -389
- data/features/cli_unknown.feature +0 -17
- data/features/cli_update.feature +0 -218
- data/features/cli_version.feature +0 -14
- data/features/step_definitions/common_steps.rb +0 -34
- data/features/support/env.rb +0 -1
- data/generators/config/templates/drivers/phantomjs.rb +0 -19
- data/generators/config/templates/drivers/poltergeist.rb +0 -11
- data/generators/config/templates/drivers/webkit.rb +0 -6
- 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 -39
- data/lib/howitzer/mail_adapters/debugmail.rb +0 -0
- data/spec/config/custom.yml +0 -9
- data/spec/spec_helper.rb +0 -73
- data/spec/support/generator_helper.rb +0 -21
- data/spec/support/logger_helper.rb +0 -13
- 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 -283
- data/spec/unit/generators/config_generator_spec.rb +0 -59
- 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 -75
- 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 -697
- data/spec/unit/lib/email_spec.rb +0 -186
- data/spec/unit/lib/gmail_api/client_spec.rb +0 -26
- data/spec/unit/lib/howitzer_spec.rb +0 -69
- 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/gmail_spec.rb +0 -128
- data/spec/unit/lib/mail_adapters/mailgun_spec.rb +0 -158
- data/spec/unit/lib/mail_adapters/mailtrap_spec.rb +0 -130
- data/spec/unit/lib/mailgun_api/client_spec.rb +0 -80
- 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/mailtrap_api/client_spec.rb +0 -67
- 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 -203
- data/spec/unit/lib/web/page_dsl_spec.rb +0 -74
- data/spec/unit/lib/web/page_spec.rb +0 -378
- 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
data/features/support/env.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'aruba/cucumber'
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# :phantomjs driver
|
2
|
-
|
3
|
-
Capybara.register_driver :phantomjs do |app|
|
4
|
-
caps = {
|
5
|
-
javascript_enabled: !Howitzer.phantom_ignore_js_errors
|
6
|
-
}
|
7
|
-
caps['phantomjs.page.settings.userAgent'] = "WebKit #{Howitzer.user_agent}" if Howitzer.user_agent.present?
|
8
|
-
Capybara::Selenium::Driver.new(
|
9
|
-
app, browser: :phantomjs,
|
10
|
-
desired_capabilities: caps,
|
11
|
-
driver_opts: {
|
12
|
-
args: ["--ignore-ssl-errors=#{Howitzer.phantom_ignore_ssl_errors ? 'yes' : 'no'}"]
|
13
|
-
}
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
Capybara::Screenshot.class_eval do
|
18
|
-
register_driver :phantomjs, ®istered_drivers[:selenium]
|
19
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# :poltergeist driver
|
2
|
-
|
3
|
-
CapybaraHelpers.load_driver_gem!(:poltergeist, 'capybara/poltergeist', 'poltergeist')
|
4
|
-
|
5
|
-
Capybara.register_driver :poltergeist do |app|
|
6
|
-
Capybara::Poltergeist::Driver.new(
|
7
|
-
app,
|
8
|
-
js_errors: !Howitzer.phantom_ignore_js_errors,
|
9
|
-
phantomjs_options: ["--ignore-ssl-errors=#{Howitzer.phantom_ignore_ssl_errors ? 'yes' : 'no'}"]
|
10
|
-
)
|
11
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
.idea/
|
2
|
-
custom.yml
|
3
|
-
bin/
|
4
|
-
log/
|
5
|
-
eylogs/
|
6
|
-
spec/results/
|
7
|
-
spec/sandbox/
|
8
|
-
tmp/
|
9
|
-
*.swp
|
10
|
-
*.orig
|
11
|
-
.rakeTasks
|
12
|
-
.bundle
|
13
|
-
.DS_STORE
|
14
|
-
.DS_Store
|
15
|
-
*.xml
|
16
|
-
*.log
|
17
|
-
*.pem
|
18
|
-
build-number.txt
|
19
|
-
sauce_connect.log*
|
20
|
-
*.*~
|
21
|
-
capybara-*.html
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# See full list of defaults here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
2
|
-
# To see all cops used see here: https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
|
3
|
-
|
4
|
-
AllCops:
|
5
|
-
TargetRubyVersion: 2.3
|
6
|
-
Include:
|
7
|
-
- Rakefile
|
8
|
-
- Gemfile
|
9
|
-
|
10
|
-
LineLength:
|
11
|
-
Max: 120
|
12
|
-
|
13
|
-
Layout/CaseIndentation:
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
Style/EmptyElse:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Lint/AmbiguousRegexpLiteral:
|
20
|
-
Enabled: false
|
21
|
-
|
22
|
-
Lint/AmbiguousBlockAssociation:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
Style/CaseEquality:
|
26
|
-
Enabled: false
|
27
|
-
|
28
|
-
Documentation:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
Style/FrozenStringLiteralComment:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
Metrics/ModuleLength:
|
35
|
-
Max: 150
|
@@ -1 +0,0 @@
|
|
1
|
-
-r turnip/rspec
|
data/howitzer.gemspec
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require File.expand_path('../lib/howitzer/version', __FILE__)
|
2
|
-
|
3
|
-
Gem::Specification.new do |gem|
|
4
|
-
gem.author = 'Roman Parashchenko'
|
5
|
-
gem.email = 'howitzer@strongqa.com'
|
6
|
-
gem.description = 'Howitzer uses the best practices and design patterns allowing to generate a test project in' \
|
7
|
-
' less than 5 minutes. It has out-of-the-box configurations for parallel cross-browser testing in the cloud.'
|
8
|
-
gem.summary = 'Ruby based framework for acceptance testing'
|
9
|
-
gem.homepage = 'http://strongqa.github.io/howitzer/'
|
10
|
-
gem.license = 'MIT'
|
11
|
-
|
12
|
-
gem.bindir = 'bin'
|
13
|
-
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
14
|
-
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
15
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
-
gem.name = 'howitzer'
|
17
|
-
gem.require_paths = ['lib']
|
18
|
-
gem.version = Howitzer::VERSION
|
19
|
-
gem.required_ruby_version = '>= 2.2.2'
|
20
|
-
|
21
|
-
gem.add_runtime_dependency 'activesupport', '~>5.0'
|
22
|
-
gem.add_runtime_dependency 'capybara', ['>= 2.1', '< 3.0']
|
23
|
-
gem.add_runtime_dependency 'colorize'
|
24
|
-
gem.add_runtime_dependency 'gli'
|
25
|
-
gem.add_runtime_dependency 'gmail'
|
26
|
-
gem.add_runtime_dependency 'launchy'
|
27
|
-
gem.add_runtime_dependency 'log4r', '~>1.1.10'
|
28
|
-
gem.add_runtime_dependency 'nokogiri', '~> 1.6' if gem.platform.to_s =~ /mswin|mingw/
|
29
|
-
gem.add_runtime_dependency 'rake'
|
30
|
-
gem.add_runtime_dependency 'rspec', '~>3.2'
|
31
|
-
gem.add_runtime_dependency 'rspec-wait'
|
32
|
-
gem.add_runtime_dependency 'selenium-webdriver', ['>= 3.4.1', '< 4.0']
|
33
|
-
gem.add_runtime_dependency 'sexy_settings'
|
34
|
-
|
35
|
-
gem.add_development_dependency('aruba')
|
36
|
-
gem.add_development_dependency('ffaker')
|
37
|
-
gem.add_development_dependency('fuubar')
|
38
|
-
gem.add_development_dependency('yard')
|
39
|
-
end
|
File without changes
|
data/spec/config/custom.yml
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
require 'simplecov'
|
4
|
-
require 'coveralls'
|
5
|
-
Coveralls.wear!
|
6
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
7
|
-
[
|
8
|
-
SimpleCov::Formatter::HTMLFormatter,
|
9
|
-
Coveralls::SimpleCov::Formatter
|
10
|
-
]
|
11
|
-
)
|
12
|
-
|
13
|
-
SimpleCov.start do
|
14
|
-
add_filter '/spec/'
|
15
|
-
add_filter '/config/'
|
16
|
-
add_filter do |source_file|
|
17
|
-
source_file.lines.count < 5
|
18
|
-
end
|
19
|
-
add_group 'generators', '/generators'
|
20
|
-
add_group 'lib', '/lib'
|
21
|
-
end
|
22
|
-
|
23
|
-
require 'tmpdir'
|
24
|
-
require 'ffaker'
|
25
|
-
require 'capybara'
|
26
|
-
require 'json'
|
27
|
-
require 'capybara/dsl'
|
28
|
-
require 'active_support'
|
29
|
-
require 'active_support/deprecation'
|
30
|
-
require 'active_support/deprecation/method_wrappers'
|
31
|
-
require 'active_support/core_ext'
|
32
|
-
require 'repeater'
|
33
|
-
require 'sexy_settings'
|
34
|
-
require 'fake_web'
|
35
|
-
|
36
|
-
SexySettings.configure do |config|
|
37
|
-
config.path_to_default_settings = File.expand_path(
|
38
|
-
'default.yml',
|
39
|
-
File.join(__dir__, '..', 'generators', 'config', 'templates')
|
40
|
-
)
|
41
|
-
config.path_to_custom_settings = File.expand_path(
|
42
|
-
'custom.yml',
|
43
|
-
File.join(__dir__, 'config')
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
puts SexySettings::Base.instance.as_formatted_text
|
48
|
-
|
49
|
-
require 'howitzer'
|
50
|
-
require 'howitzer/exceptions'
|
51
|
-
|
52
|
-
def project_path
|
53
|
-
File.expand_path(File.join(__dir__, '..'))
|
54
|
-
end
|
55
|
-
|
56
|
-
def lib_path
|
57
|
-
File.join(project_path, 'lib')
|
58
|
-
end
|
59
|
-
|
60
|
-
def generators_path
|
61
|
-
File.join(project_path, 'generators')
|
62
|
-
end
|
63
|
-
|
64
|
-
def log_path
|
65
|
-
File.join(project_path, 'spec/log')
|
66
|
-
end
|
67
|
-
|
68
|
-
Dir[File.join(__dir__, 'support', '**', '*.rb')].each { |f| require f }
|
69
|
-
|
70
|
-
RSpec.configure do |config|
|
71
|
-
config.include Howitzer::GeneratorHelper
|
72
|
-
config.disable_monkey_patching!
|
73
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require_relative '../../generators/base_generator'
|
3
|
-
|
4
|
-
module Howitzer
|
5
|
-
module GeneratorHelper
|
6
|
-
def file_tree_info(root)
|
7
|
-
Dir["#{root}/**/.*", "#{root}/**/*"].sort_by { |name| name.sub(root, '') }.map do |name|
|
8
|
-
hash = { name: name.sub(root, ''), is_directory: File.directory?(name) }
|
9
|
-
hash[:size] = File.stat(name).size unless hash[:is_directory]
|
10
|
-
hash
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def template_file_size(root_directory, file)
|
15
|
-
File.size(File.join(generators_path, root_directory, 'templates', file))
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
Howitzer::BaseGenerator.logger = StringIO.new
|
20
|
-
Howitzer::BaseGenerator.destination = Dir.mktmpdir
|
21
|
-
Dir[File.join(generators_path, '**', '*_generator.rb')].each { |f| require f }
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.shared_examples :capybara_context_holder do
|
4
|
-
describe '#capybara_context' do
|
5
|
-
let(:web_page_class) do
|
6
|
-
klass = described_class
|
7
|
-
Class.new do
|
8
|
-
include klass
|
9
|
-
end
|
10
|
-
end
|
11
|
-
subject { web_page_class.new.capybara_context }
|
12
|
-
context 'when parent class has the method' do
|
13
|
-
before do
|
14
|
-
web_page_class.class_eval do
|
15
|
-
def capybara_scopes
|
16
|
-
@_scopes ||= [true]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
it 'should execute parent method' do
|
21
|
-
is_expected.to eq(true)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
context 'when parent class does not have the method' do
|
25
|
-
it 'should raise error' do
|
26
|
-
expect { subject }.to raise_error(
|
27
|
-
NotImplementedError,
|
28
|
-
"Please define 'capybara_scopes' method for class holder"
|
29
|
-
)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.shared_examples :capybara_methods_proxy do
|
4
|
-
let(:session) { double(:session) }
|
5
|
-
before do
|
6
|
-
allow(Capybara).to receive(:current_session) { session }
|
7
|
-
allow(Howitzer).to receive(:driver) { driver_name }
|
8
|
-
allow(session).to receive(:current_url) { 'google.com' }
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#driver' do
|
12
|
-
it 'should proxy #driver method' do
|
13
|
-
expect(session).to receive(:driver).once
|
14
|
-
reciever.driver
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#text' do
|
19
|
-
it 'should proxy #text method' do
|
20
|
-
expect(session).to receive(:text).once
|
21
|
-
reciever.text
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'when capybara session method' do
|
26
|
-
it 'should proxy method' do
|
27
|
-
expect(session).to receive(:visit).once
|
28
|
-
reciever.visit
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'when capybara modal method' do
|
33
|
-
it 'should proxy method' do
|
34
|
-
expect(session).to receive(:dismiss_prompt).with(:some_text).once
|
35
|
-
reciever.dismiss_prompt(:some_text)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#click_alert_box' do
|
40
|
-
subject { reciever.click_alert_box(flag_value) }
|
41
|
-
context 'when flag true and correct driver specified' do
|
42
|
-
let(:flag_value) { true }
|
43
|
-
let(:page) { double }
|
44
|
-
let(:alert) { double }
|
45
|
-
let(:driver) { double }
|
46
|
-
let(:browser) { double }
|
47
|
-
let(:switch_to) { double }
|
48
|
-
let(:driver_name) { 'selenium' }
|
49
|
-
it do
|
50
|
-
expect(session).to receive(:driver).ordered.and_return(driver)
|
51
|
-
expect(driver).to receive(:browser).ordered.and_return(browser)
|
52
|
-
expect(browser).to receive(:switch_to).ordered.and_return(switch_to)
|
53
|
-
expect(switch_to).to receive(:alert).ordered.and_return(alert)
|
54
|
-
expect(alert).to receive(:accept).once
|
55
|
-
subject
|
56
|
-
end
|
57
|
-
end
|
58
|
-
context 'when flag false and correct driver specified' do
|
59
|
-
let(:flag_value) { false }
|
60
|
-
let(:page) { double }
|
61
|
-
let(:alert) { double }
|
62
|
-
let(:driver) { double }
|
63
|
-
let(:browser) { double }
|
64
|
-
let(:switch_to) { double }
|
65
|
-
let(:driver_name) { 'selenium' }
|
66
|
-
it do
|
67
|
-
expect(session).to receive(:driver).ordered.and_return(driver)
|
68
|
-
expect(driver).to receive(:browser).ordered.and_return(browser)
|
69
|
-
expect(browser).to receive(:switch_to).ordered.and_return(switch_to)
|
70
|
-
expect(switch_to).to receive(:alert).ordered.and_return(alert)
|
71
|
-
expect(alert).to receive(:dismiss).once
|
72
|
-
subject
|
73
|
-
end
|
74
|
-
end
|
75
|
-
context 'when flag true and wrong driver specified' do
|
76
|
-
let(:flag_value) { true }
|
77
|
-
let(:page) { double }
|
78
|
-
let(:driver_name) { 'ff' }
|
79
|
-
it do
|
80
|
-
expect(session).to receive(:evaluate_script).with('window.confirm = function() { return true; }')
|
81
|
-
subject
|
82
|
-
end
|
83
|
-
end
|
84
|
-
context 'when flag false and wrong driver specified' do
|
85
|
-
let(:driver_name) { 'ff' }
|
86
|
-
let(:flag_value) { false }
|
87
|
-
let(:page) { double }
|
88
|
-
it do
|
89
|
-
expect(session).to receive(:evaluate_script).with('window.confirm = function() { return false; }')
|
90
|
-
subject
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
RSpec.shared_examples :dynamic_section_methods do
|
3
|
-
let(:web_page_object) { web_page_class.new }
|
4
|
-
|
5
|
-
describe '#name_section' do
|
6
|
-
let(:capybara_element) { double }
|
7
|
-
subject { web_page_object.send("#{section_name}_section") }
|
8
|
-
before { expect(session).to receive(:find).with(*finder_args).once.and_return(capybara_element) }
|
9
|
-
it { is_expected.to be_a(section_class) }
|
10
|
-
end
|
11
|
-
describe '#name_sections' do
|
12
|
-
subject { web_page_object.send("#{section_name}_sections") }
|
13
|
-
let(:capybara_element1) { double }
|
14
|
-
let(:capybara_element2) { double }
|
15
|
-
before do
|
16
|
-
expect(session).to receive(:all).with(*finder_args).once.and_return([capybara_element1, capybara_element2])
|
17
|
-
end
|
18
|
-
it 'should return collection of sections' do
|
19
|
-
res = subject
|
20
|
-
expect(res.size).to eq(2)
|
21
|
-
expect(res.first).to be_a(section_class)
|
22
|
-
expect(res.last).to be_a(section_class)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
describe '#has_name_section?' do
|
26
|
-
subject { web_page_object.send("has_#{section_name}_section?") }
|
27
|
-
before { expect(session).to receive(:has_selector?).with(*finder_args).once.and_return(true) }
|
28
|
-
it { is_expected.to eq(true) }
|
29
|
-
end
|
30
|
-
describe '#has_no_name_element?' do
|
31
|
-
subject { web_page_object.send("has_no_#{section_name}_section?") }
|
32
|
-
before { expect(session).to receive(:has_no_selector?).with(*finder_args).once.and_return(true) }
|
33
|
-
it { is_expected.to eq(true) }
|
34
|
-
end
|
35
|
-
end
|
@@ -1,242 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.shared_examples :element_dsl do
|
4
|
-
describe '.element' do
|
5
|
-
context 'when regular capybara params' do
|
6
|
-
before do
|
7
|
-
klass.class_eval do
|
8
|
-
element :foo, :xpath, '//a'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
it 'should create private :foo_element instance method' do
|
12
|
-
expect(klass_object.private_methods(false)).to include(:foo_element)
|
13
|
-
end
|
14
|
-
it 'should create private :foo_elements instance method' do
|
15
|
-
expect(klass_object.private_methods(false)).to include(:foo_elements)
|
16
|
-
end
|
17
|
-
it 'should create private :wait_for_foo_element instance method' do
|
18
|
-
expect(klass_object.private_methods(false)).to include(:wait_for_foo_element)
|
19
|
-
end
|
20
|
-
it 'should create public :has_foo_element? instance method' do
|
21
|
-
expect(klass_object.public_methods(false)).to include(:has_foo_element?)
|
22
|
-
end
|
23
|
-
it 'should create public :has_no_foo_element? instance method' do
|
24
|
-
expect(klass_object.public_methods(false)).to include(:has_no_foo_element?)
|
25
|
-
end
|
26
|
-
it 'should be protected class method' do
|
27
|
-
expect { klass.element :bar }.to raise_error(NoMethodError)
|
28
|
-
expect(klass.protected_methods(true)).to include(:element)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
context 'when 1 param is proc' do
|
32
|
-
before do
|
33
|
-
klass.class_eval do
|
34
|
-
element :foo, :xpath, ->(title) { "//a[.='#{title}']" }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
it 'should create private :foo_element instance method' do
|
38
|
-
expect(klass_object.private_methods(false)).to include(:foo_element)
|
39
|
-
end
|
40
|
-
it 'should create private :foo_elements instance method' do
|
41
|
-
expect(klass_object.private_methods(false)).to include(:foo_elements)
|
42
|
-
end
|
43
|
-
it 'should create private :wait_for_foo_element instance method' do
|
44
|
-
expect(klass_object.private_methods(false)).to include(:wait_for_foo_element)
|
45
|
-
end
|
46
|
-
it 'should create public :has_foo_element? instance method' do
|
47
|
-
expect(klass_object.public_methods(false)).to include(:has_foo_element?)
|
48
|
-
end
|
49
|
-
it 'should create public :has_no_foo_element? instance method' do
|
50
|
-
expect(klass_object.public_methods(false)).to include(:has_no_foo_element?)
|
51
|
-
end
|
52
|
-
it 'should be protected class method' do
|
53
|
-
expect { klass.element :bar }.to raise_error(NoMethodError)
|
54
|
-
expect(klass.protected_methods(true)).to include(:element)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
context 'when 2 params are proc' do
|
58
|
-
subject do
|
59
|
-
klass.class_eval do
|
60
|
-
element :foo, -> { puts 1 }, ->(title) { "//a[.='#{title}']" }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
it 'should generate error' do
|
64
|
-
expect { subject.element :bar }.to raise_error(
|
65
|
-
Howitzer::BadElementParamsError,
|
66
|
-
'Using more than 1 proc in arguments is forbidden'
|
67
|
-
)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe 'dynamic_methods' do
|
73
|
-
let(:web_page_object) { web_page_class.new }
|
74
|
-
let(:kontext) { double(:kontext) }
|
75
|
-
before do
|
76
|
-
allow(Capybara).to receive(:current_session) { kontext }
|
77
|
-
klass.class_eval do
|
78
|
-
element :foo, :xpath,
|
79
|
-
->(title, name) { "//a[.='#{title}']/*[@name='#{name}']" }, text: 'original', match: :first
|
80
|
-
element :bar, '.someclass', text: 'origin', match: :first
|
81
|
-
element :top_panel, '.top', text: 'origin', match: :first
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe '#name_element' do
|
86
|
-
context 'when simple selector' do
|
87
|
-
subject { klass_object.send(:bar_element, text: 'new', wait: 10) }
|
88
|
-
after { subject }
|
89
|
-
it do
|
90
|
-
expect(klass_object.capybara_context).to receive(:find)
|
91
|
-
.with('.someclass', wait: 10, text: 'new', match: :first)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
context 'when lambda selector' do
|
95
|
-
subject { klass_object.send(:foo_element, 'Hello', 'super', text: 'new', wait: 10) }
|
96
|
-
after { subject }
|
97
|
-
it do
|
98
|
-
expect(klass_object.capybara_context).to receive(:find)
|
99
|
-
.with(:xpath, "//a[.='Hello']/*[@name='super']", wait: 10, text: 'new', match: :first)
|
100
|
-
end
|
101
|
-
|
102
|
-
context 'when several execution with different data' do
|
103
|
-
it 'does not cache previous data' do
|
104
|
-
expect(klass_object.capybara_context).to receive(:find)
|
105
|
-
.with(:xpath, "//a[.='Hello']/*[@name='super']", wait: 10, text: 'new', match: :first).at_least(:once)
|
106
|
-
klass_object.send(:foo_element, 'Hello', 'super', text: 'new', wait: 10)
|
107
|
-
|
108
|
-
expect(klass_object.capybara_context).to receive(:find)
|
109
|
-
.with(:xpath, "//a[.='Bye']/*[@name='puper']", wait: 15, text: 'new', match: :first).at_least(:once)
|
110
|
-
klass_object.send(:foo_element, 'Bye', 'puper', text: 'new', wait: 15)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
describe '#name_elements' do
|
116
|
-
after { subject }
|
117
|
-
context 'when simple selector' do
|
118
|
-
subject { klass_object.send(:bar_elements, text: 'new', wait: 10) }
|
119
|
-
it do
|
120
|
-
expect(klass_object.capybara_context).to receive(:all)
|
121
|
-
.with('.someclass', wait: 10, text: 'new', match: :first)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
context 'when lambda selector' do
|
125
|
-
subject { klass_object.send(:foo_elements, 'Hello', 'super', text: 'new', wait: 10) }
|
126
|
-
it do
|
127
|
-
expect(
|
128
|
-
klass_object.capybara_context
|
129
|
-
).to receive(:all).with(:xpath, "//a[.='Hello']/*[@name='super']", wait: 10, text: 'new', match: :first)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
describe '#wait_for_name_element' do
|
134
|
-
context 'when simple selector' do
|
135
|
-
subject { klass_object.send(:wait_for_bar_element, text: 'new', wait: 10) }
|
136
|
-
it do
|
137
|
-
expect(klass_object.capybara_context).to receive(:find)
|
138
|
-
.with('.someclass', wait: 10, text: 'new', match: :first)
|
139
|
-
is_expected.to eq(nil)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
context 'when lambda selector' do
|
143
|
-
subject { klass_object.send(:wait_for_foo_element, 'Hello', 'super', text: 'new', wait: 10) }
|
144
|
-
it do
|
145
|
-
expect(
|
146
|
-
klass_object.capybara_context
|
147
|
-
).to receive(:find).with(:xpath, "//a[.='Hello']/*[@name='super']", wait: 10, text: 'new', match: :first)
|
148
|
-
is_expected.to eq(nil)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
describe '#within_name_element' do
|
153
|
-
let(:within_scope) { double }
|
154
|
-
after { subject }
|
155
|
-
context 'not nested' do
|
156
|
-
context 'when simple selector' do
|
157
|
-
subject do
|
158
|
-
klass_object.instance_eval do
|
159
|
-
within_bar_element(wait: 5, text: 'new') do
|
160
|
-
foo_element('Hello', 'super', wait: 10, text: 'new')
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
it do
|
165
|
-
expect(klass_object.capybara_context).to receive(:find)
|
166
|
-
.with('.someclass', wait: 5, text: 'new', match: :first) { within_scope }
|
167
|
-
expect(within_scope).to receive(:find)
|
168
|
-
.with(:xpath, "//a[.='Hello']/*[@name='super']", wait: 10, text: 'new', match: :first)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
context 'when lambda selector' do
|
172
|
-
subject do
|
173
|
-
klass_object.instance_eval do
|
174
|
-
within_foo_element('Hello', 'super', wait: 10, text: 'new') do
|
175
|
-
bar_element(wait: 10, text: 'new')
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
it do
|
180
|
-
expect(klass_object.capybara_context).to receive(:find)
|
181
|
-
.with(:xpath, "//a[.='Hello']/*[@name='super']", wait: 10, text: 'new', match: :first) { within_scope }
|
182
|
-
expect(within_scope).to receive(:find).with('.someclass', wait: 10, text: 'new', match: :first)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
context 'nested' do
|
187
|
-
let(:nested_within_scope) { double }
|
188
|
-
subject do
|
189
|
-
klass_object.instance_eval do
|
190
|
-
within_top_panel_element(wait: 10, text: 'new') do
|
191
|
-
within_bar_element(wait: 10, text: 'new') do
|
192
|
-
foo_element('Hello', 'super', wait: 10, text: 'new')
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
it do
|
198
|
-
expect(klass_object.capybara_context).to receive(:find)
|
199
|
-
.with('.top', wait: 10, text: 'new', match: :first) { within_scope }
|
200
|
-
expect(within_scope).to receive(:find)
|
201
|
-
.with('.someclass', wait: 10, text: 'new', match: :first) { nested_within_scope }
|
202
|
-
expect(nested_within_scope).to receive(:find)
|
203
|
-
.with(:xpath, "//a[.='Hello']/*[@name='super']", wait: 10, text: 'new', match: :first)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
describe '#has_name_element?' do
|
208
|
-
after { subject }
|
209
|
-
context 'when simple selector' do
|
210
|
-
subject { klass_object.send(:has_bar_element?, wait: 10, text: 'new') }
|
211
|
-
it do
|
212
|
-
expect(klass_object.capybara_context).to receive(:has_selector?)
|
213
|
-
.with('.someclass', wait: 10, text: 'new', match: :first)
|
214
|
-
end
|
215
|
-
end
|
216
|
-
context 'when lambda selector' do
|
217
|
-
subject { klass_object.send(:has_foo_element?, 'Hello', 'super', wait: 10, text: 'new') }
|
218
|
-
it do
|
219
|
-
expect(klass_object.capybara_context).to receive(:has_selector?)
|
220
|
-
.with(:xpath, "//a[.='Hello']/*[@name='super']", wait: 10, text: 'new', match: :first)
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
224
|
-
describe '#has_no_name_element?' do
|
225
|
-
after { subject }
|
226
|
-
context 'when simple selector' do
|
227
|
-
subject { klass_object.send(:has_no_bar_element?, wait: 10, text: 'new') }
|
228
|
-
it do
|
229
|
-
expect(klass_object.capybara_context).to receive(:has_no_selector?)
|
230
|
-
.with('.someclass', wait: 10, text: 'new', match: :first)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
context 'when lambda selector' do
|
234
|
-
subject { klass_object.send(:has_no_foo_element?, 'Hello', 'super', wait: 10, text: 'new', match: :first) }
|
235
|
-
it do
|
236
|
-
expect(klass_object.capybara_context).to receive(:has_no_selector?)
|
237
|
-
.with(:xpath, "//a[.='Hello']/*[@name='super']", wait: 10, text: 'new', match: :first)
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|