howitzer 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/spec/active_resource.rb
DELETED
File without changes
|
data/spec/config/default.yml
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
###########################################################
|
2
|
-
# LOGGER SETTINGS #
|
3
|
-
###########################################################
|
4
|
-
log_dir: "spec/log"
|
5
|
-
txt_log: log.txt
|
6
|
-
html_log: log.html
|
7
|
-
rawler_log: rawler_log.txt
|
8
|
-
selenium_server_log: selenium-server.log
|
9
|
-
required_clean_logs: true
|
10
|
-
hide_datetime_from_log: true
|
11
|
-
|
12
|
-
driver: selenium
|
13
|
-
|
14
|
-
###########################################################
|
15
|
-
# MAILGUN SETTINGS #
|
16
|
-
###########################################################
|
17
|
-
mailgun_key: mailgun_account_private_key
|
18
|
-
mailgun_domain: mailgun@test.domain
|
19
|
-
|
20
|
-
############################################################
|
21
|
-
# TIMEOUTS #
|
22
|
-
############################################################
|
23
|
-
timeout_tiny: 1
|
24
|
-
timeout_short: 2
|
25
|
-
timeout_small: 5
|
26
|
-
timeout_medium: 15
|
data/spec/support/boot_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'sexy_settings'
|
2
|
-
SexySettings.configure do |config|
|
3
|
-
config.path_to_default_settings = File.expand_path("default.yml", File.join(File.dirname(__FILE__), '..', 'config'))
|
4
|
-
config.path_to_custom_settings = File.expand_path("custom.yml", File.join(File.dirname(__FILE__), '..', 'config'))
|
5
|
-
end
|
6
|
-
|
7
|
-
def settings
|
8
|
-
SexySettings::Base.instance
|
9
|
-
end
|
10
|
-
|
11
|
-
def log
|
12
|
-
Howitzer::Log.instance
|
13
|
-
end
|
14
|
-
|
15
|
-
ENV['TEST_MODE'] = "TRUE"
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe 'Generators' do
|
4
|
-
let(:destination) { Howitzer::BaseGenerator.destination }
|
5
|
-
let(:output) { StringIO.new }
|
6
|
-
subject { file_tree_info(destination) }
|
7
|
-
before do
|
8
|
-
Howitzer::BaseGenerator.logger = output
|
9
|
-
generator_name.new
|
10
|
-
end
|
11
|
-
after { FileUtils.rm_r(destination) }
|
12
|
-
|
13
|
-
describe 'PagesGenerator' do
|
14
|
-
let(:generator_name) { Howitzer::PagesGenerator }
|
15
|
-
let(:expected_result) do
|
16
|
-
[
|
17
|
-
{:name=> '/pages', :is_directory=>true},
|
18
|
-
{:name=> '/pages/example_menu.rb', :is_directory=>false, :size=>template_file_size('pages', 'example_menu.rb')},
|
19
|
-
{:name=> '/pages/example_page.rb', :is_directory=>false, :size=>template_file_size('pages', 'example_page.rb')}
|
20
|
-
]
|
21
|
-
end
|
22
|
-
it { is_expected.to eql(expected_result) }
|
23
|
-
describe 'output' do
|
24
|
-
let(:expected_output) do
|
25
|
-
" * PageOriented pattern structure generation ...
|
26
|
-
Added 'pages/example_page.rb' file
|
27
|
-
Added 'pages/example_menu.rb' file\n"
|
28
|
-
end
|
29
|
-
subject { output.string }
|
30
|
-
it { is_expected.to eql(expected_output) }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'howitzer/capybara/dsl_ex'
|
3
|
-
|
4
|
-
RSpec.describe Howitzer::Capybara::DslEx do
|
5
|
-
let(:test_page_klass) do
|
6
|
-
Class.new do
|
7
|
-
include Howitzer::Capybara::DslEx
|
8
|
-
extend Howitzer::Capybara::DslEx
|
9
|
-
end
|
10
|
-
end
|
11
|
-
let(:test_page) { test_page_klass.new }
|
12
|
-
|
13
|
-
describe '#find' do
|
14
|
-
context 'when string argument with block' do
|
15
|
-
subject { test_page.find('foo'){ 'bar' } }
|
16
|
-
it do
|
17
|
-
expect(test_page.page).to receive(:find).with('foo').and_yield.once
|
18
|
-
subject
|
19
|
-
end
|
20
|
-
end
|
21
|
-
context 'when first hash argument and second hash' do
|
22
|
-
subject { test_page.find({xpath: '//bar'}, {with: 'foo'}) }
|
23
|
-
it do
|
24
|
-
expect(test_page.page).to receive(:find).with(:xpath, '//bar', {:with=> 'foo'}).once
|
25
|
-
subject
|
26
|
-
end
|
27
|
-
end
|
28
|
-
context 'when array argument' do
|
29
|
-
subject { test_page.find([:xpath, '//bar']) }
|
30
|
-
it do
|
31
|
-
expect(test_page.page).to receive(:find).with(:xpath, '//bar').once
|
32
|
-
subject
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '.find' do
|
38
|
-
context 'when string argument with block' do
|
39
|
-
subject { test_page_klass.find('foo'){ 'bar' } }
|
40
|
-
it do
|
41
|
-
expect(test_page.page).to receive(:find).with('foo').and_yield.once
|
42
|
-
subject
|
43
|
-
end
|
44
|
-
end
|
45
|
-
context 'when first hash argument and second hash' do
|
46
|
-
subject { test_page_klass.find({xpath: '//bar'}, {with: 'foo'}) }
|
47
|
-
it do
|
48
|
-
expect(test_page.page).to receive(:find).with(:xpath, '//bar', {:with=> 'foo'}).once
|
49
|
-
subject
|
50
|
-
end
|
51
|
-
end
|
52
|
-
context 'when array argument' do
|
53
|
-
subject { test_page_klass.find([:xpath, '//bar']) }
|
54
|
-
it do
|
55
|
-
expect(test_page.page).to receive(:find).with(:xpath, '//bar').once
|
56
|
-
subject
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,441 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'howitzer/capybara/settings'
|
4
|
-
|
5
|
-
RSpec.describe 'CapybaraSettings' do
|
6
|
-
it 'supports deprecated module name' do
|
7
|
-
expect { CapybaraSettings }.to_not raise_error
|
8
|
-
expect(CapybaraSettings).to eq(Capybara::Settings)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
RSpec.describe 'Capybara::Settings' do
|
13
|
-
let(:log) { double('log') }
|
14
|
-
let(:test_object) { double('test_object').extend(Capybara::Settings) }
|
15
|
-
before do
|
16
|
-
allow(log).to receive(:error).and_return( true )
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '.base_ff_profile_settings' do
|
20
|
-
subject { Capybara::Settings.base_ff_profile_settings }
|
21
|
-
before do
|
22
|
-
allow(::Selenium::WebDriver::Firefox::Profile).to receive(:new) { Hash.new }
|
23
|
-
allow(settings).to receive(:app_host) { 'localhost' }
|
24
|
-
end
|
25
|
-
|
26
|
-
it do
|
27
|
-
is_expected.to eq(
|
28
|
-
'network.http.phishy-userpass-length' => 255,
|
29
|
-
'browser.safebrowsing.malware.enabled' => false,
|
30
|
-
'network.automatic-ntlm-auth.allow-non-fqdn' => true,
|
31
|
-
'network.ntlm.send-lm-response' => true,
|
32
|
-
'network.automatic-ntlm-auth.trusted-uris' => 'localhost'
|
33
|
-
)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '.define_driver' do
|
38
|
-
subject { Capybara::Settings.define_driver }
|
39
|
-
context 'when selenium driver' do
|
40
|
-
before do
|
41
|
-
allow(settings).to receive(:driver).and_return('selenium')
|
42
|
-
allow(settings).to receive(:sel_browser).and_return('chrome')
|
43
|
-
allow(Capybara::Settings).to receive(:ff_browser?).and_return(false)
|
44
|
-
end
|
45
|
-
it do
|
46
|
-
expect(Capybara.default_driver).to be(:selenium)
|
47
|
-
expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'when selenium dev driver' do
|
52
|
-
let(:profile) { Hash.new }
|
53
|
-
before do
|
54
|
-
allow(::Selenium::WebDriver::Firefox::Profile).to receive(:new) { profile }
|
55
|
-
allow(settings).to receive(:app_host) { 'localhost' }
|
56
|
-
allow(settings).to receive(:driver).and_return('selenium_dev')
|
57
|
-
allow(settings).to receive(:sel_browser).and_return('firefox')
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when extension is found' do
|
61
|
-
before { allow(profile).to receive(:add_extension).and_return('') }
|
62
|
-
it do
|
63
|
-
expect(Capybara.default_driver).to be(:selenium)
|
64
|
-
expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
|
65
|
-
end
|
66
|
-
it do
|
67
|
-
expect(subject.call.options[:profile]).to eq(
|
68
|
-
'network.http.phishy-userpass-length' => 255,
|
69
|
-
'browser.safebrowsing.malware.enabled' => false,
|
70
|
-
'network.automatic-ntlm-auth.allow-non-fqdn' => true,
|
71
|
-
'network.ntlm.send-lm-response' => true,
|
72
|
-
'network.automatic-ntlm-auth.trusted-uris' => 'localhost',
|
73
|
-
'extensions.firebug.currentVersion' => 'Last',
|
74
|
-
'extensions.firebug.previousPlacement' => 1,
|
75
|
-
'extensions.firebug.onByDefault' => true,
|
76
|
-
'extensions.firebug.defaultPanelName' => 'firepath',
|
77
|
-
'extensions.firebug.script.enableSites' => true,
|
78
|
-
'extensions.firebug.net.enableSites' => true,
|
79
|
-
'extensions.firebug.console.enableSites' => true
|
80
|
-
)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'when webkit driver' do
|
86
|
-
before do
|
87
|
-
allow(settings).to receive(:driver).and_return('webkit')
|
88
|
-
allow(Capybara::Settings).to receive(:require).with('capybara-webkit').and_return(true)
|
89
|
-
end
|
90
|
-
it { is_expected.to be true }
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'when poltergeist driver' do
|
94
|
-
before do
|
95
|
-
allow(settings).to receive(:driver).and_return('poltergeist')
|
96
|
-
allow(settings).to receive(:pjs_ignore_js_errors).and_return(false)
|
97
|
-
end
|
98
|
-
it do
|
99
|
-
expect(subject.call).to be_an_instance_of(Capybara::Poltergeist::Driver)
|
100
|
-
expect(subject.call.options).to eq(
|
101
|
-
js_errors: !settings.pjs_ignore_js_errors,
|
102
|
-
phantomjs_options: ['--ignore-ssl-errors=no']
|
103
|
-
)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context 'when phantomjs driver' do
|
108
|
-
before do
|
109
|
-
allow(settings).to receive(:driver).and_return('phantomjs')
|
110
|
-
allow(settings).to receive(:pjs_ignore_js_errors).and_return(false)
|
111
|
-
end
|
112
|
-
it do
|
113
|
-
expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
|
114
|
-
expect(subject.call.options[:browser]).to eq(:phantomjs)
|
115
|
-
expect(subject.call.options[:desired_capabilities][:javascript_enabled]).not_to eq(settings.pjs_ignore_js_errors)
|
116
|
-
expect(subject.call.options[:args]).to eq(["--ignore-ssl-errors=no"])
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'when sauce driver' do
|
121
|
-
let(:driver) { Object.new }
|
122
|
-
before do
|
123
|
-
allow(settings).to receive(:driver).and_return('sauce')
|
124
|
-
allow(settings).to receive(:sl_browser_name).and_return('firefox')
|
125
|
-
allow(driver).to receive_message_chain(:browser, :file_detector=)
|
126
|
-
allow(Capybara::Selenium::Driver).to receive(:new).and_return(driver)
|
127
|
-
end
|
128
|
-
it { expect(subject.call).to eql(driver) }
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'when testingbot driver' do
|
132
|
-
let(:driver) { Object.new }
|
133
|
-
before do
|
134
|
-
allow(settings).to receive(:driver).and_return('testingbot')
|
135
|
-
allow(settings).to receive(:tb_browser_name).and_return('firefox')
|
136
|
-
allow(driver).to receive_message_chain(:browser, :file_detector=)
|
137
|
-
allow(Capybara::Selenium::Driver).to receive(:new).and_return(driver)
|
138
|
-
end
|
139
|
-
it { expect(subject.call).to eql(driver) }
|
140
|
-
end
|
141
|
-
|
142
|
-
context 'when selenium_grid driver' do
|
143
|
-
before { allow(settings).to receive(:driver).and_return('selenium_grid') }
|
144
|
-
|
145
|
-
context "and ie browser" do
|
146
|
-
before { allow(Capybara::Settings).to receive(:ie_browser?).and_return(true) }
|
147
|
-
it do
|
148
|
-
expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
|
149
|
-
expect(subject.call.options[:desired_capabilities][:browser_name]).to eq('internet explorer')
|
150
|
-
expect(subject.call.options[:desired_capabilities][:platform]).to eq(:windows)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
context "and firefox browser" do
|
155
|
-
before do
|
156
|
-
allow(Capybara::Settings).to receive(:ie_browser?).and_return(false)
|
157
|
-
allow(Capybara::Settings).to receive(:ff_browser?).and_return(true)
|
158
|
-
end
|
159
|
-
it do
|
160
|
-
expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
|
161
|
-
expect(subject.call.options[:desired_capabilities][:browser_name]).to eq('firefox')
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
context "and chrome browser" do
|
166
|
-
before do
|
167
|
-
allow(Capybara::Settings).to receive(:ie_browser?).and_return(false)
|
168
|
-
allow(Capybara::Settings).to receive(:ff_browser?).and_return(false)
|
169
|
-
allow(Capybara::Settings).to receive(:chrome_browser?).and_return(true)
|
170
|
-
end
|
171
|
-
it do
|
172
|
-
expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
|
173
|
-
expect(subject.call.options[:desired_capabilities][:browser_name]).to eq('chrome')
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
context "and safari browser" do
|
178
|
-
before do
|
179
|
-
allow(Capybara::Settings).to receive(:ie_browser?).and_return(false)
|
180
|
-
allow(Capybara::Settings).to receive(:ff_browser?).and_return(false)
|
181
|
-
allow(Capybara::Settings).to receive(:chrome_browser?).and_return(false)
|
182
|
-
allow(Capybara::Settings).to receive(:opera_browser?).and_return(false)
|
183
|
-
allow(Capybara::Settings).to receive(:safari_browser?).and_return(true)
|
184
|
-
end
|
185
|
-
it do
|
186
|
-
expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
|
187
|
-
expect(subject.call.options[:desired_capabilities][:browser_name]).to eq('safari')
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
context "and incorrect browser" do
|
192
|
-
before do
|
193
|
-
allow(Capybara::Settings).to receive(:ie_browser?).and_return(false)
|
194
|
-
allow(Capybara::Settings).to receive(:ff_browser?).and_return(false)
|
195
|
-
allow(Capybara::Settings).to receive(:chrome_browser?).and_return(false)
|
196
|
-
allow(Capybara::Settings).to receive(:opera_browser?).and_return(false)
|
197
|
-
allow(Capybara::Settings).to receive(:safari_browser?).and_return(false)
|
198
|
-
it do
|
199
|
-
expect { subject }.to raise_error(RuntimeError, "Unknown '#{settings.sel_browser}' sel_browser. Check your settings, it should be one of [:ie, :iexplore, :ff, :firefox, :chrome, :opera, safari]")
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
context 'when browserstack driver' do
|
206
|
-
let(:driver) { Object.new }
|
207
|
-
before do
|
208
|
-
allow(settings).to receive(:driver).and_return('browserstack')
|
209
|
-
allow(settings).to receive(:bs_browser_name).and_return('firefox')
|
210
|
-
allow(driver).to receive_message_chain(:browser, :file_detector=)
|
211
|
-
allow(Capybara::Selenium::Driver).to receive(:new).and_return(driver)
|
212
|
-
end
|
213
|
-
it { expect(subject.call).to eql(driver) }
|
214
|
-
end
|
215
|
-
|
216
|
-
context 'when incorrect driver' do
|
217
|
-
before do
|
218
|
-
allow(settings).to receive(:driver).and_return('caramba')
|
219
|
-
end
|
220
|
-
it do
|
221
|
-
expect { subject }.to raise_error(RuntimeError, "Unknown '#{settings.driver}' driver. Check your settings, it should be one of [selenium, selenium_grid, selenium_dev, webkit, poltergeist, phantomjs, sauce, testingbot, browserstack]")
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
describe '#sauce_resource_path' do
|
227
|
-
subject { test_object.sauce_resource_path(name) }
|
228
|
-
let (:name) { 'test_name' }
|
229
|
-
before do
|
230
|
-
allow(settings).to receive(:sl_user) { 'vlad' }
|
231
|
-
allow(settings).to receive(:sl_api_key) { '11111' }
|
232
|
-
allow(test_object).to receive(:session_id) { '12341234' }
|
233
|
-
end
|
234
|
-
it { is_expected.to eql('https://vlad:11111@saucelabs.com/rest/vlad/jobs/12341234/results/test_name') }
|
235
|
-
end
|
236
|
-
describe '.sauce_resource_path' do
|
237
|
-
subject { Capybara::Settings.sauce_resource_path(name) }
|
238
|
-
let (:name) { 'test_name' }
|
239
|
-
before do
|
240
|
-
allow(settings).to receive(:sl_user) { 'vlad' }
|
241
|
-
allow(settings).to receive(:sl_api_key) { '11111' }
|
242
|
-
allow(Capybara::Settings).to receive(:session_id) { '12341234' }
|
243
|
-
end
|
244
|
-
|
245
|
-
it { is_expected.to eql('https://vlad:11111@saucelabs.com/rest/vlad/jobs/12341234/results/test_name') }
|
246
|
-
end
|
247
|
-
|
248
|
-
describe '#update_sauce_job_status' do
|
249
|
-
subject { test_object.update_sauce_job_status }
|
250
|
-
before do
|
251
|
-
allow(settings).to receive(:sl_user) { 'vlad1' }
|
252
|
-
allow(settings).to receive(:sl_api_key) { '22222' }
|
253
|
-
allow(test_object).to receive(:session_id) { '12341234' }
|
254
|
-
stub_const('RestClient', double)
|
255
|
-
end
|
256
|
-
|
257
|
-
it do
|
258
|
-
expect(RestClient).to receive(:put).with('http://vlad1:22222@saucelabs.com/rest/v1/vlad1/jobs/12341234', '{}', {content_type: :json, accept: :json}).once
|
259
|
-
subject
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
describe '.update_sauce_resource_path' do
|
264
|
-
subject { Capybara::Settings.update_sauce_job_status }
|
265
|
-
before do
|
266
|
-
allow(settings).to receive(:sl_user) { 'vlad1' }
|
267
|
-
allow(settings).to receive(:sl_api_key) { '22222' }
|
268
|
-
allow(Capybara::Settings).to receive(:session_id) { '12341234' }
|
269
|
-
stub_const('RestClient', double)
|
270
|
-
end
|
271
|
-
|
272
|
-
it do
|
273
|
-
expect(RestClient).to receive(:put).with('http://vlad1:22222@saucelabs.com/rest/v1/vlad1/jobs/12341234', '{}', {content_type: :json, accept: :json}).once
|
274
|
-
subject
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
describe '#suite_name' do
|
279
|
-
subject { test_object.suite_name }
|
280
|
-
before do
|
281
|
-
allow(settings).to receive(:sl_browser_name) { 'ie' }
|
282
|
-
end
|
283
|
-
|
284
|
-
context 'when environment present' do
|
285
|
-
before { ENV['RAKE_TASK'] = rake_task }
|
286
|
-
context 'when includes rspec' do
|
287
|
-
let(:rake_task) { 'rspec:bvt' }
|
288
|
-
it { is_expected.to eql('BVT IE')}
|
289
|
-
end
|
290
|
-
context 'when includes spec' do
|
291
|
-
let(:rake_task) { 'spec:bvt' }
|
292
|
-
it { is_expected.to eql('BVT IE')}
|
293
|
-
end
|
294
|
-
|
295
|
-
context 'when includes cucumber' do
|
296
|
-
let(:rake_task) { 'cucumber:bvt' }
|
297
|
-
it { is_expected.to eql('BVT IE')}
|
298
|
-
end
|
299
|
-
context 'when not includes rpsec and cucumber' do
|
300
|
-
let(:rake_task) { 'unknown' }
|
301
|
-
it { is_expected.to eql('UNKNOWN IE')}
|
302
|
-
end
|
303
|
-
context 'when includes only cucumber' do
|
304
|
-
let(:rake_task) { 'cucumber' }
|
305
|
-
it { is_expected.to eql('ALL IE')}
|
306
|
-
end
|
307
|
-
end
|
308
|
-
context 'when environment empty' do
|
309
|
-
before { ENV['RAKE_TASK'] = nil }
|
310
|
-
it { is_expected.to eql('CUSTOM IE')}
|
311
|
-
end
|
312
|
-
end
|
313
|
-
|
314
|
-
describe '.suite_name' do
|
315
|
-
subject { Capybara::Settings.suite_name }
|
316
|
-
before do
|
317
|
-
allow(settings).to receive(:sl_browser_name) { 'ie' }
|
318
|
-
end
|
319
|
-
|
320
|
-
context 'when environment present' do
|
321
|
-
before { ENV['RAKE_TASK'] = rake_task }
|
322
|
-
context 'when includes rspec' do
|
323
|
-
let(:rake_task) { 'rspec:bvt' }
|
324
|
-
it { is_expected.to eql('BVT IE')}
|
325
|
-
end
|
326
|
-
context 'when includes spec' do
|
327
|
-
let(:rake_task) { 'spec:bvt' }
|
328
|
-
it { is_expected.to eql('BVT IE')}
|
329
|
-
end
|
330
|
-
|
331
|
-
context 'when includes cucumber' do
|
332
|
-
let(:rake_task) { 'cucumber:bvt' }
|
333
|
-
it { is_expected.to eql('BVT IE')}
|
334
|
-
end
|
335
|
-
context 'when not includes rpsec and cucumber' do
|
336
|
-
let(:rake_task) { 'unknown' }
|
337
|
-
it { is_expected.to eql('UNKNOWN IE')}
|
338
|
-
end
|
339
|
-
context 'when includes only cucumber' do
|
340
|
-
let(:rake_task) { 'cucumber' }
|
341
|
-
it { is_expected.to eql('ALL IE')}
|
342
|
-
end
|
343
|
-
end
|
344
|
-
context 'when environment empty' do
|
345
|
-
before { ENV['RAKE_TASK'] = nil }
|
346
|
-
it { is_expected.to eql('CUSTOM IE')}
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
describe '#session_id' do
|
351
|
-
subject { test_object.session_id }
|
352
|
-
before do
|
353
|
-
browser = double
|
354
|
-
current_session = double
|
355
|
-
driver = double
|
356
|
-
instance_variable = double
|
357
|
-
allow(Capybara).to receive(:current_session){current_session}
|
358
|
-
allow(current_session).to receive(:driver){driver}
|
359
|
-
allow(driver).to receive(:browser){browser}
|
360
|
-
allow(browser).to receive(:instance_variable_get).with(:@bridge){ instance_variable }
|
361
|
-
allow(instance_variable).to receive(:session_id){ 'test'}
|
362
|
-
end
|
363
|
-
|
364
|
-
it { is_expected.to eql('test') }
|
365
|
-
end
|
366
|
-
|
367
|
-
describe '.session_id' do
|
368
|
-
subject { Capybara::Settings.session_id }
|
369
|
-
before do
|
370
|
-
browser = double
|
371
|
-
current_session = double
|
372
|
-
driver = double
|
373
|
-
instance_variable = double
|
374
|
-
allow(Capybara).to receive(:current_session){current_session}
|
375
|
-
allow(current_session).to receive(:driver){driver}
|
376
|
-
allow(driver).to receive(:browser){browser}
|
377
|
-
allow(browser).to receive(:instance_variable_get).with(:@bridge){ instance_variable }
|
378
|
-
allow(instance_variable).to receive(:session_id){ 'test'}
|
379
|
-
end
|
380
|
-
|
381
|
-
it { is_expected.to eql('test') }
|
382
|
-
end
|
383
|
-
|
384
|
-
describe '#rake_task_name' do
|
385
|
-
subject { test_object.rake_task_name }
|
386
|
-
before { ENV['RAKE_TASK'] = rake_task }
|
387
|
-
context 'when includes rspec' do
|
388
|
-
let(:rake_task) { 'rspec:bvt' }
|
389
|
-
it { is_expected.to eq('BVT') }
|
390
|
-
end
|
391
|
-
context 'when includes cucumber' do
|
392
|
-
let(:rake_task) { 'cucumber:bvt' }
|
393
|
-
it { is_expected.to eq('BVT') }
|
394
|
-
end
|
395
|
-
context 'when includes spec' do
|
396
|
-
let(:rake_task) { 'spec:bvt' }
|
397
|
-
it { is_expected.to eq('BVT') }
|
398
|
-
end
|
399
|
-
context 'when includes only cucumber' do
|
400
|
-
let(:rake_task) { 'cucumber' }
|
401
|
-
it { is_expected.to eq('') }
|
402
|
-
end
|
403
|
-
context 'when includes unknown task' do
|
404
|
-
let(:rake_task) { 'unknown' }
|
405
|
-
it { is_expected.to eq('UNKNOWN') }
|
406
|
-
end
|
407
|
-
context 'when environment is empty' do
|
408
|
-
let(:rake_task) { nil }
|
409
|
-
it { is_expected.to eq('') }
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
413
|
-
describe '.rake_task_name' do
|
414
|
-
subject { Capybara::Settings.rake_task_name }
|
415
|
-
before { ENV['RAKE_TASK'] = rake_task }
|
416
|
-
context 'when includes rspec' do
|
417
|
-
let(:rake_task) { 'rspec:bvt' }
|
418
|
-
it { is_expected.to eq('BVT') }
|
419
|
-
end
|
420
|
-
context 'when includes cucumber' do
|
421
|
-
let(:rake_task) { 'cucumber:bvt' }
|
422
|
-
it { is_expected.to eq('BVT') }
|
423
|
-
end
|
424
|
-
context 'when includes spec' do
|
425
|
-
let(:rake_task) { 'spec:bvt' }
|
426
|
-
it { is_expected.to eq('BVT') }
|
427
|
-
end
|
428
|
-
context 'when includes only cucumber' do
|
429
|
-
let(:rake_task) { 'cucumber' }
|
430
|
-
it { is_expected.to eq('') }
|
431
|
-
end
|
432
|
-
context 'when includes unknown task' do
|
433
|
-
let(:rake_task) { 'unknown' }
|
434
|
-
it { is_expected.to eq('UNKNOWN') }
|
435
|
-
end
|
436
|
-
context 'when environment is empty' do
|
437
|
-
let(:rake_task) { nil }
|
438
|
-
it { is_expected.to eq('') }
|
439
|
-
end
|
440
|
-
end
|
441
|
-
end
|