Skip to content

Commit f78afdb

Browse files
committed
rb - tests easier to run locally
1 parent 645d318 commit f78afdb

File tree

6 files changed

+191
-176
lines changed

6 files changed

+191
-176
lines changed

rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,35 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20+
require_relative '../spec_helper'
21+
2022
module Selenium
2123
module WebDriver
2224
module Chrome
2325

24-
describe Driver do
25-
it "should accept an array of custom command line arguments" do
26-
begin
27-
driver = Selenium::WebDriver.for :chrome, :args => ["--user-agent=foo;bar"]
28-
driver.navigate.to url_for("click_jacker.html")
26+
compliant_on :browser => :chrome do
27+
describe Driver do
28+
29+
it "should accept an array of custom command line arguments" do
30+
begin
31+
driver = Selenium::WebDriver.for :chrome, :args => ["--user-agent=foo;bar"]
32+
driver.navigate.to url_for("click_jacker.html")
2933

30-
ua = driver.execute_script "return window.navigator.userAgent"
31-
expect(ua).to eq("foo;bar")
32-
ensure
33-
driver.quit if driver
34+
ua = driver.execute_script "return window.navigator.userAgent"
35+
expect(ua).to eq("foo;bar")
36+
ensure
37+
driver.quit if driver
38+
end
3439
end
35-
end
3640

37-
it "should raise ArgumentError if :args is not an Array" do
38-
expect {
39-
Selenium::WebDriver.for(:chrome, :args => "--foo")
40-
}.to raise_error(ArgumentError)
41+
it "should raise ArgumentError if :args is not an Array" do
42+
expect {
43+
Selenium::WebDriver.for(:chrome, :args => "--foo")
44+
}.to raise_error(ArgumentError)
45+
end
4146
end
42-
end
43-
44-
end # Chrome
45-
end # WebDriver
46-
end # Selenium
4747

48+
end # Chrome
49+
end # WebDriver
50+
end # Selenium
51+
end

rb/spec/integration/selenium/webdriver/chrome/profile_spec.rb

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,65 +17,68 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20+
require_relative '../spec_helper'
21+
2022
module Selenium
2123
module WebDriver
2224
module Chrome
2325

24-
describe Profile do
25-
let(:profile) { Profile.new }
26+
compliant_on :browser => :chrome do
27+
describe Profile do
28+
let(:profile) { Profile.new }
2629

27-
# Won't work on ChromeDriver 2.0
28-
#
29-
# it "launches Chrome with a custom profile" do
30-
# profile['autofill.disabled'] = true
31-
#
32-
# begin
33-
# driver = WebDriver.for :chrome, :profile => profile
34-
# ensure
35-
# driver.quit if driver
36-
# end
37-
# end
30+
# Won't work on ChromeDriver 2.0
31+
#
32+
# it "launches Chrome with a custom profile" do
33+
# profile['autofill.disabled'] = true
34+
#
35+
# begin
36+
# driver = WebDriver.for :chrome, :profile => profile
37+
# ensure
38+
# driver.quit if driver
39+
# end
40+
# end
3841

39-
it "should be serializable to JSON" do
40-
profile['foo.boolean'] = true
42+
it "should be serializable to JSON" do
43+
profile['foo.boolean'] = true
4144

42-
new_profile = Profile.from_json(profile.to_json)
43-
expect(new_profile['foo.boolean']).to be true
44-
end
45+
new_profile = Profile.from_json(profile.to_json)
46+
expect(new_profile['foo.boolean']).to be true
47+
end
4548

46-
it "adds an extension" do
47-
ext_path = "/some/path.crx"
49+
it "adds an extension" do
50+
ext_path = "/some/path.crx"
4851

49-
expect(File).to receive(:file?).with(ext_path).and_return true
50-
expect(profile.add_extension(ext_path)).to eq([ext_path])
51-
end
52+
expect(File).to receive(:file?).with(ext_path).and_return true
53+
expect(profile.add_extension(ext_path)).to eq([ext_path])
54+
end
5255

53-
it "reads an extension as binary data" do
54-
ext_path = "/some/path.crx"
55-
expect(File).to receive(:file?).with(ext_path).and_return true
56+
it "reads an extension as binary data" do
57+
ext_path = "/some/path.crx"
58+
expect(File).to receive(:file?).with(ext_path).and_return true
5659

57-
profile.add_extension(ext_path)
60+
profile.add_extension(ext_path)
5861

59-
ext_file = double('file')
60-
expect(File).to receive(:open).with(ext_path, "rb").and_yield ext_file
61-
expect(ext_file).to receive(:read).and_return "test"
62+
ext_file = double('file')
63+
expect(File).to receive(:open).with(ext_path, "rb").and_yield ext_file
64+
expect(ext_file).to receive(:read).and_return "test"
6265

63-
expect(profile).to receive(:layout_on_disk).and_return "ignored"
64-
expect(Zipper).to receive(:zip).and_return "ignored"
66+
expect(profile).to receive(:layout_on_disk).and_return "ignored"
67+
expect(Zipper).to receive(:zip).and_return "ignored"
6568

66-
expect(profile.as_json()).to eq({
67-
'zip' => "ignored",
68-
'extensions' => [Base64.strict_encode64("test")]
69-
})
70-
end
69+
expect(profile.as_json()).to eq({
70+
'zip' => "ignored",
71+
'extensions' => [Base64.strict_encode64("test")]
72+
})
73+
end
7174

72-
it "raises an error if the extension doesn't exist" do
73-
expect {
74-
profile.add_extension("/not/likely/to/exist.crx")
75-
}.to raise_error
75+
it "raises an error if the extension doesn't exist" do
76+
expect {
77+
profile.add_extension("/not/likely/to/exist.crx")
78+
}.to raise_error
79+
end
7680
end
7781
end
78-
7982
end # Chrome
8083
end # WebDriver
8184
end # Selenium

rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20+
require_relative '../spec_helper'
21+
2022
module Selenium
2123
module WebDriver
2224
module Firefox
2325

24-
not_compliant_on :w3c => true do
26+
compliant_on :driver => :firefox do
2527
describe Driver do
2628
describe ".new" do
2729
it "should take a Firefox::Profile instance as argument" do

0 commit comments

Comments
 (0)