forked from rubycdp/ferrum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(tests): reorganize specs and unify naming
- Loading branch information
Showing
23 changed files
with
1,459 additions
and
1,351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ task default: :test | |
begin | ||
require "yard" | ||
YARD::Rake::YardocTask.new | ||
task docs: :yard | ||
rescue LoadError | ||
# nop | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# frozen_string_literal: true | ||
|
||
module Ferrum | ||
class Browser | ||
describe Xvfb, skip: !Binary.find("Xvfb") do | ||
let(:process) { xvfb_browser.process } | ||
let(:xvfb_browser) { Browser.new(default_options.merge(options)) } | ||
let(:default_options) { Hash(headless: true, xvfb: true) } | ||
|
||
context "headless" do | ||
context "with window_size" do | ||
let(:options) { Hash(window_size: [1400, 1400]) } | ||
|
||
it "allows to run tests configured to xvfb" do | ||
xvfb_browser.go_to(base_url) | ||
|
||
expect(xvfb_browser.body).to include("Hello world!") | ||
expect(process_alive?(process.xvfb.pid)).to be(true) | ||
expect(process.xvfb.screen_size).to eq("1400x1400x24") | ||
expect(process.xvfb.to_env).to eq("DISPLAY" => ":#{process.xvfb.display_id}") | ||
ensure | ||
xvfb_browser&.quit | ||
expect(process_alive?(process.xvfb.pid)).to be(false) | ||
end | ||
end | ||
|
||
context "without window_size" do | ||
let(:options) { {} } | ||
|
||
it "allows to run tests configured to xvfb" do | ||
xvfb_browser.go_to(base_url) | ||
|
||
expect(xvfb_browser.body).to include("Hello world!") | ||
expect(process_alive?(process.xvfb.pid)).to be(true) | ||
expect(process.xvfb.screen_size).to eq("1024x768x24") | ||
expect(process.xvfb.to_env).to eq("DISPLAY" => ":#{process.xvfb.display_id}") | ||
ensure | ||
xvfb_browser&.quit | ||
expect(process_alive?(process.xvfb.pid)).to be(false) | ||
end | ||
end | ||
end | ||
|
||
context "headful" do | ||
let(:options) { Hash(headless: false) } | ||
|
||
it "allows to run tests configured to xvfb" do | ||
xvfb_browser.go_to(base_url) | ||
|
||
expect(xvfb_browser.body).to include("Hello world!") | ||
expect(process_alive?(process.xvfb.pid)).to be(true) | ||
expect(process.xvfb.screen_size).to eq("1024x768x24") | ||
ensure | ||
xvfb_browser&.quit | ||
expect(process_alive?(process.xvfb.pid)).to be(false) | ||
end | ||
end | ||
|
||
def process_alive?(pid) | ||
return false unless pid | ||
|
||
::Process.kill(0, pid) == 1 | ||
rescue Errno::ESRCH | ||
false | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.