capybara-box 0.4.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -2
- data/README.md +30 -42
- data/lib/capybara-box.rb +6 -2
- data/lib/capybara-box/base.rb +55 -98
- data/lib/capybara-box/helper.rb +19 -0
- data/lib/capybara-box/screenshot.rb +45 -0
- data/lib/capybara-box/version.rb +1 -1
- metadata +11 -58
- data/spec/lib/capybara_box/base/add_argument_spec.rb +0 -35
- data/spec/lib/capybara_box/base/add_preference_spec.rb +0 -35
- data/spec/lib/capybara_box/base/apply_arguments_spec.rb +0 -33
- data/spec/lib/capybara_box/base/apply_bin_path_spec.rb +0 -34
- data/spec/lib/capybara_box/base/apply_preferences_spec.rb +0 -43
- data/spec/lib/capybara_box/base/apply_version_spec.rb +0 -37
- data/spec/lib/capybara_box/base/arguments_spec.rb +0 -72
- data/spec/lib/capybara_box/base/chrome_family_spec.rb +0 -23
- data/spec/lib/capybara_box/base/chrome_headless_spec.rb +0 -17
- data/spec/lib/capybara_box/base/chrome_spec.rb +0 -17
- data/spec/lib/capybara_box/base/configure_screenshot_spec.rb +0 -83
- data/spec/lib/capybara_box/base/configure_spec.rb +0 -33
- data/spec/lib/capybara_box/base/create_spec.rb +0 -89
- data/spec/lib/capybara_box/base/driver_options_spec.rb +0 -74
- data/spec/lib/capybara_box/base/driver_spec.rb +0 -97
- data/spec/lib/capybara_box/base/firefox_spec.rb +0 -17
- data/spec/lib/capybara_box/base/http_client_options_spec.rb +0 -24
- data/spec/lib/capybara_box/base/http_client_spec.rb +0 -11
- data/spec/lib/capybara_box/base/log_spec.rb +0 -43
- data/spec/lib/capybara_box/base/options_spec.rb +0 -43
- data/spec/lib/capybara_box/base/preferences_spec.rb +0 -63
- data/spec/lib/capybara_box/base/register_spec.rb +0 -17
- data/spec/lib/capybara_box/base/self_configure_spec.rb +0 -22
- data/spec/lib/capybara_box/base/version_spec.rb +0 -33
- data/spec/rails_helper.rb +0 -9
- data/spec/support/common.rb +0 -11
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe CapybaraBox::Base, '.http_client_options' do
|
4
|
-
context 'when :http_client_options is not given' do
|
5
|
-
subject { described_class.new }
|
6
|
-
|
7
|
-
it 'returns the http client options' do
|
8
|
-
expect(subject.http_client_options).to eq(
|
9
|
-
open_timeout: nil,
|
10
|
-
read_timeout: 120
|
11
|
-
)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'when :http_client_options is given' do
|
16
|
-
subject { described_class.new parameters }
|
17
|
-
|
18
|
-
let!(:parameters) { { http_client_options: { key: :value } } }
|
19
|
-
|
20
|
-
it 'is used' do
|
21
|
-
expect(subject.http_client_options).to eq(key: :value)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe CapybaraBox::Base, '.http_client' do
|
4
|
-
before do
|
5
|
-
allow(Selenium::WebDriver::Remote::Http::Default).to receive(:new).with(subject.http_client_options) { :client }
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'returns the default http client' do
|
9
|
-
expect(subject.http_client).to eq :client
|
10
|
-
end
|
11
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.shared_context 'log_disabled' do
|
4
|
-
context 'when is chrome' do
|
5
|
-
before { parameters[:browser] = :chrome }
|
6
|
-
|
7
|
-
it 'does not includes log config' do
|
8
|
-
expect(subject.driver_options[:driver_opts]).to be_nil
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'when is chrome headless' do
|
13
|
-
before { parameters[:browser] = :chrome_headless }
|
14
|
-
|
15
|
-
it 'does not includes log config' do
|
16
|
-
expect(subject.driver_options[:driver_opts]).to be_nil
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'when is firefox' do
|
21
|
-
before { parameters[:browser] = :firefox }
|
22
|
-
|
23
|
-
it 'does not includes log config' do
|
24
|
-
expect(subject.driver_options[:driver_opts]).to be_nil
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
RSpec.describe CapybaraBox::Base, '.log' do
|
30
|
-
subject { described_class.new parameters }
|
31
|
-
|
32
|
-
context 'when log is false' do
|
33
|
-
let!(:parameters) { { log: false } }
|
34
|
-
|
35
|
-
it_behaves_like 'log_disabled'
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when log is "false"' do
|
39
|
-
let!(:parameters) { { log: 'false' } }
|
40
|
-
|
41
|
-
it_behaves_like 'log_disabled'
|
42
|
-
end
|
43
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe CapybaraBox::Base, '.options' do
|
4
|
-
subject { described_class.configure parameters }
|
5
|
-
|
6
|
-
context 'when is chrome' do
|
7
|
-
let!(:parameters) { { browser: :chrome } }
|
8
|
-
|
9
|
-
let!(:options) do
|
10
|
-
instance_double(Selenium::WebDriver::Chrome::Options).as_null_object
|
11
|
-
end
|
12
|
-
|
13
|
-
before do
|
14
|
-
allow(Selenium::WebDriver::Chrome::Options).to receive(:new).with(no_args) { options }
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'returns a instance of chrome options' do
|
18
|
-
expect(subject.options).to eq options
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'when is chrome headless' do
|
23
|
-
let!(:parameters) { { browser: :chrome_headless } }
|
24
|
-
|
25
|
-
let!(:options) do
|
26
|
-
instance_double(Selenium::WebDriver::Chrome::Options).as_null_object
|
27
|
-
end
|
28
|
-
|
29
|
-
before do
|
30
|
-
allow(Selenium::WebDriver::Chrome::Options).to receive(:new).with(no_args) { options }
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'returns a instance of chrome options' do
|
34
|
-
expect(subject.options).to eq options
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when is firefox' do
|
39
|
-
let!(:parameters) { { browser: :firefox } }
|
40
|
-
|
41
|
-
specify { expect(subject.options).to be_nil }
|
42
|
-
end
|
43
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe CapybaraBox::Base, '.preferences' do
|
4
|
-
subject { described_class.new parameters }
|
5
|
-
|
6
|
-
let!(:chrome_family_preferences) do
|
7
|
-
{
|
8
|
-
credentials_enable_service: false,
|
9
|
-
|
10
|
-
profile: {
|
11
|
-
password_manager_enabled: false
|
12
|
-
}
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'when is chrome' do
|
17
|
-
let!(:parameters) { { browser: :chrome } }
|
18
|
-
|
19
|
-
it 'receives the right preferences' do
|
20
|
-
expect(subject.preferences).to eq chrome_family_preferences
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'and :preferences is given' do
|
24
|
-
before { parameters[:preferences] = { key: :value } }
|
25
|
-
|
26
|
-
it 'is used' do
|
27
|
-
expect(subject.preferences).to eq(key: :value)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'when is chrome headless' do
|
33
|
-
let!(:parameters) { { browser: :chrome_headless } }
|
34
|
-
|
35
|
-
it 'receives the right preferences' do
|
36
|
-
expect(subject.preferences).to eq chrome_family_preferences
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'and :preferences is given' do
|
40
|
-
before { parameters[:preferences] = { key: :value } }
|
41
|
-
|
42
|
-
it 'is used' do
|
43
|
-
expect(subject.preferences).to eq(key: :value)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'when is firefox' do
|
49
|
-
let!(:parameters) { { browser: :firefox } }
|
50
|
-
|
51
|
-
it 'receives the right preferences' do
|
52
|
-
expect(subject.preferences).to eq({})
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'and :preferences is given' do
|
56
|
-
before { parameters[:preferences] = { key: :value } }
|
57
|
-
|
58
|
-
it 'is used' do
|
59
|
-
expect(subject.preferences).to eq(key: :value)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe CapybaraBox::Base, '.register' do
|
4
|
-
subject { described_class.new }
|
5
|
-
|
6
|
-
let!(:app) { double }
|
7
|
-
|
8
|
-
before do
|
9
|
-
allow(Capybara).to receive(:register_driver).with(:name).and_yield app
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'register the driver with given name' do
|
13
|
-
expect(subject).to receive(:driver).with app
|
14
|
-
|
15
|
-
subject.register :name
|
16
|
-
end
|
17
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe CapybaraBox::Base, '#configure' do
|
4
|
-
let!(:parameters) { { key: :value } }
|
5
|
-
let!(:box) { instance_double(CapybaraBox::Base).as_null_object }
|
6
|
-
|
7
|
-
before do
|
8
|
-
allow(described_class).to receive(:new).with(parameters) { box }
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'creates the box with given parameters' do
|
12
|
-
expect(box).to receive :create
|
13
|
-
|
14
|
-
described_class.configure parameters
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'returns the created box' do
|
18
|
-
expect(described_class.configure(parameters)).to eq box
|
19
|
-
|
20
|
-
described_class.configure parameters
|
21
|
-
end
|
22
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe CapybaraBox::Base, '.version' do
|
4
|
-
subject { described_class.configure parameters }
|
5
|
-
|
6
|
-
context 'when version is given' do
|
7
|
-
let!(:parameters) { { version: '2.30' } }
|
8
|
-
|
9
|
-
context 'and browser is chrome' do
|
10
|
-
before { parameters[:browser] = :chrome }
|
11
|
-
|
12
|
-
it 'applies the version' do
|
13
|
-
expect(subject.version).to eq '2.30'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'and browser is chrome headless' do
|
18
|
-
before { parameters[:browser] = :chrome_headless }
|
19
|
-
|
20
|
-
it 'applies the version' do
|
21
|
-
expect(subject.version).to eq '2.30'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'and browser is not chrome headless' do
|
26
|
-
before { parameters[:browser] = :firefox }
|
27
|
-
|
28
|
-
it 'does not apply the version' do
|
29
|
-
expect(subject.version).to be_nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/spec/rails_helper.rb
DELETED