Skip to content

Commit

Permalink
Cleanup + get rid of some RSpec deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jarib committed Aug 29, 2014
1 parent 8bb31a9 commit f39c6d7
Show file tree
Hide file tree
Showing 28 changed files with 90 additions and 88 deletions.
16 changes: 8 additions & 8 deletions rb/selenium-webdriver.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ Gem::Specification.new do |s|
s.files = Dir[root + '/**/*'].reject { |e| e =~ /ruby\.iml|build\.desc/ }.map { |e| e.sub(root + '/', '') }
s.require_paths = ["lib"]

s.add_runtime_dependency("multi_json", ["~> 1.0"])
s.add_runtime_dependency("rubyzip", ["~> 1.0"])
s.add_runtime_dependency("childprocess", ["~> 0.5"])
s.add_runtime_dependency("websocket", ["~> 1.0"])
s.add_runtime_dependency "multi_json", ["~> 1.0"]
s.add_runtime_dependency "rubyzip", ["~> 1.0"]
s.add_runtime_dependency "childprocess", ["~> 0.5"]
s.add_runtime_dependency "websocket", ["~> 1.0"]

s.add_development_dependency("rspec", ["~> 2.0"])
s.add_development_dependency("rack", ["~> 1.0"])
s.add_development_dependency("ci_reporter", ["~> 1.6", ">= 1.6.2"])
s.add_development_dependency("webmock", ["~> 1.7", ">= 1.7.5"])
s.add_development_dependency "rspec", ["~> 2.99.0"]
s.add_development_dependency "rack", ["~> 1.0"]
s.add_development_dependency "ci_reporter", ["~> 1.6", ">= 1.6.2"]
s.add_development_dependency "webmock", ["~> 1.7", ">= 1.7.5"]
end
8 changes: 4 additions & 4 deletions rb/spec/integration/selenium/client/api/cookie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/path1/cookie1.html"
page.cookies.should =~ /addedCookieForPath1=new value1/

page.cookie?("addedCookieForPath1").should be_true
page.cookie?("addedCookieForPath1").should be true
page.cookie("addedCookieForPath1").should eql("new value1")
page.cookie?("testCookie").should be_false
page.cookie?("addedCookieForPath2").should be_false
page.cookie?("testCookie").should be false
page.cookie?("addedCookieForPath2").should be false

page.delete_cookie "addedCookieForPath1", "/selenium-server/org/openqa/selenium/tests/html/path1/"
page.cookies.should be_empty

page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/path2/cookie2.html"
page.cookie("addedCookieForPath2").should eql("new value2")
page.cookie?("addedCookieForPath1").should be_false
page.cookie?("addedCookieForPath1").should be false

page.delete_cookie "addedCookieForPath2", "/selenium-server/org/openqa/selenium/tests/html/path2/"
page.delete_cookie "addedCookieForPath2"
Expand Down
6 changes: 3 additions & 3 deletions rb/spec/integration/selenium/client/api/element_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
describe "Element API" do
it "can detect element presence" do
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/test_element_present.html"
page.element?('aLink').should be_true
page.element?('aLink').should be true

page.click 'removeLinkAfterAWhile', :wait_for => :no_element, :element => "aLink"
page.element?('aLink').should be_false
page.element?('aLink').should be false

page.click 'addLinkAfterAWhile', :wait_for => :element, :element => "aLink"
page.element?('aLink').should be_true
page.element?('aLink').should be true
end
end
4 changes: 2 additions & 2 deletions rb/spec/integration/selenium/client/api/screenshot_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/test_click_page1.html"
page.capture_screenshot tempfile

File.exists?(tempfile).should be_true
File.exists?(tempfile).should be true
File.open(tempfile, "rb") do |io|
magic = io.read(4)
magic.should == "\211PNG"
Expand All @@ -28,4 +28,4 @@

pngImage.should =~ /^\211PNG/n
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
page.location.should =~ %r{/tests/html/test_select_window_popup.html}
page.title.should =~ /Select Window Popup/
page.all_window_names.size.should eql(2)
page.all_window_names.include?("myPopupWindow").should be_true
page.all_window_names.include?("myPopupWindow").should be true

page.close
page.select_window "null"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module Chrome
profile['foo.boolean'] = true

new_profile = Profile.from_json(profile.to_json)
new_profile['foo.boolean'].should be_true
new_profile['foo.boolean'].should be true
end

it "adds an extension" do
Expand Down
6 changes: 3 additions & 3 deletions rb/spec/integration/selenium/webdriver/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

begin
driver.save_screenshot path
File.exist?(path).should be_true # sic
File.exist?(path).should be true # sic
File.size(path).should > 0
ensure
File.delete(path) if File.exist?(path)
Expand Down Expand Up @@ -126,7 +126,7 @@
describe "many elements" do
it "should find by class name" do
driver.navigate.to url_for("xhtmlTest.html")
driver.find_elements(:class, "nameC").should have(2).things
expect(driver.find_elements(:class, "nameC").size).to eq(2)
end

it "should find by css selector" do
Expand All @@ -138,7 +138,7 @@
driver.navigate.to url_for("nestedElements.html")
element = driver.find_element(:name, "form2")
children = element.find_elements(:name, "selectomatic")
children.should have(2).items
expect(children.size).to eq(2)
end
end

Expand Down
4 changes: 2 additions & 2 deletions rb/spec/integration/selenium/webdriver/error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
rescued = true
end

rescued.should be_true
rescued.should be true
ex.backtrace.first.should include("[remote server]")
end
end
end
end
4 changes: 2 additions & 2 deletions rb/spec/integration/selenium/webdriver/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module WebDriver

cookies = driver.manage.all_cookies

cookies.should have(1).things
expect(cookies.size).to eq(1)
cookies.first[:name].should == "foo"
cookies.first[:value].should == "bar"
end
Expand Down Expand Up @@ -73,4 +73,4 @@ module WebDriver

end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def custom_extension_installed?(driver)

it 'should start without custom extension by default' do
driver = create_driver
custom_extension_installed?(driver).should be_false
custom_extension_installed?(driver).should be false
end

it 'should start with custom extension if requested' do
driver = create_driver(true)
custom_extension_installed?(driver).should be_true
custom_extension_installed?(driver).should be true
end
end

Expand Down
2 changes: 1 addition & 1 deletion rb/spec/integration/selenium/webdriver/touch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ module Selenium::WebDriver::DriverExtensions
driver.touch.single_tap(e).perform

same_page = driver.execute_script "return document.latch"
same_page.should be_true
same_page.should be true
end
end

Expand Down
28 changes: 14 additions & 14 deletions rb/spec/unit/selenium/client/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ class BaseClient
it "sets highlight_located_element_by_default" do
client = BaseClient.new :highlight_located_element => true

client.highlight_located_element_by_default.should be_true
client.highlight_located_element_by_default.should be true
end

it "sets highlight_located_element_by_default to false by default" do
client = BaseClient.new :host => :a_host
client.highlight_located_element_by_default.should be_false
client.highlight_located_element_by_default.should be false
end
end

Expand All @@ -74,7 +74,7 @@ class BaseClient
end

it "sets highlight_located_element_by_default to false by default" do
BaseClient.new.highlight_located_element_by_default.should be_false
BaseClient.new.highlight_located_element_by_default.should be false
end
end

Expand Down Expand Up @@ -172,7 +172,7 @@ class BaseClient

client.start_new_browser_session

client.session_started?.should be_true
client.session_started?.should be true
end

it "returns false when session has been stopped" do
Expand All @@ -184,54 +184,54 @@ class BaseClient
client.start_new_browser_session
client.stop

client.session_started?.should be_false
client.session_started?.should be false
end
end

describe "chrome_backend?" do
it "returns true when the browser string is *firefox" do
client = BaseClient.new :host, 24, "*firefox", :url
client.chrome_backend?.should be_true
client.chrome_backend?.should be true
end

it "returns false when the browser string is *iexplore" do
client = BaseClient.new :host, 24, "*iexplore", :url
client.chrome_backend?.should be_false
client.chrome_backend?.should be false
end

it "returns false when the browser string is *safari" do
client = BaseClient.new :host, 24, "*safari", :url
client.chrome_backend?.should be_false
client.chrome_backend?.should be false
end

it "returns false when the browser string is *opera" do
client = BaseClient.new :host, 24, "*opera", :url
client.chrome_backend?.should be_false
client.chrome_backend?.should be false
end

it "returns true when the browser string is *chrome" do
client = BaseClient.new :host, 24, "*chrome", :url
client.chrome_backend?.should be_true
client.chrome_backend?.should be true
end

it "returns true when the browser string is *firefox2" do
client = BaseClient.new :host, 24, "*firefox2", :url
client.chrome_backend?.should be_true
client.chrome_backend?.should be true
end

it "returns true when the browser string is *firefox3" do
client = BaseClient.new :host, 24, "*firefox3", :url
client.chrome_backend?.should be_true
client.chrome_backend?.should be true
end

it "returns false when the browser string is *firefoxproxy" do
client = BaseClient.new :host, 24, "*firefoxproxy", :url
client.chrome_backend?.should be_false
client.chrome_backend?.should be false
end

it "returns false when the browser string is *pifirefox" do
client = BaseClient.new :host, 24, "*pifirefox", :url
client.chrome_backend?.should be_false
client.chrome_backend?.should be false
end
end

Expand Down
8 changes: 4 additions & 4 deletions rb/spec/unit/selenium/rake/task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

task.port.should == 4444
task.timeout.should == 30
task.background.should be_true
task.log.should be_true
task.background.should be true
task.log.should be true
task.opts.should == []
end

Expand Down Expand Up @@ -55,8 +55,8 @@

task.port.should == 5555
task.timeout.should == 120
task.background.should be_false
task.log.should be_false
task.background.should be false
task.log.should be false
task.opts.should == ["-some", "args"]
end

Expand Down
2 changes: 1 addition & 1 deletion rb/spec/unit/selenium/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
server = Selenium::Server.new("selenium-server-test.jar")
server.port.should == 4444
server.timeout.should == 30
server.background.should be_false
server.background.should be false
server.log.should be_nil

server.port = 1234
Expand Down
2 changes: 1 addition & 1 deletion rb/spec/unit/selenium/webdriver/android/bridge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Android
custom_caps = Remote::Capabilities.new
custom_caps['foo'] = 'bar'

http.should_receive(:call).with do |_, _, payload|
expect(http).to receive(:call) do |_, _, payload|
payload[:desiredCapabilities]['foo'].should == 'bar'
resp
end
Expand Down
24 changes: 12 additions & 12 deletions rb/spec/unit/selenium/webdriver/chrome/bridge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ module Chrome
it "sets the nativeEvents capability" do
Bridge.new(:http_client => http, :native_events => true)

caps['chromeOptions']['nativeEvents'].should be_true
caps['chrome.nativeEvents'].should be_true
caps['chromeOptions']['nativeEvents'].should be true
caps['chrome.nativeEvents'].should be true
end

it "sets the args capability" do
Expand All @@ -42,15 +42,15 @@ module Chrome
it "sets the chrome.verbose capability" do
Bridge.new(:http_client => http, :verbose => true)

caps['chromeOptions']['verbose'].should be_true
caps['chrome.verbose'].should be_true
caps['chromeOptions']['verbose'].should be true
caps['chrome.verbose'].should be true
end

it "sets the chrome.detach capability" do
Bridge.new(:http_client => http) # true by default

caps['chromeOptions']['detach'].should be_true
caps['chrome.detach'].should be_true
caps['chromeOptions']['detach'].should be true
caps['chrome.detach'].should be true
end

it "sets the prefs capability" do
Expand All @@ -63,15 +63,15 @@ module Chrome
it "lets the user override chrome.detach" do
Bridge.new(:http_client => http, :detach => false)

caps['chromeOptions']['detach'].should be_false
caps['chrome.detach'].should be_false
caps['chromeOptions']['detach'].should be false
caps['chrome.detach'].should be false
end

it "lets the user override chrome.noWebsiteTestingDefaults" do
Bridge.new(:http_client => http, :no_website_testing_defaults => true)

caps['chromeOptions']['noWebsiteTestingDefaults'].should be_true
caps['chrome.noWebsiteTestingDefaults'].should be_true
caps['chromeOptions']['noWebsiteTestingDefaults'].should be true
caps['chrome.noWebsiteTestingDefaults'].should be true
end

it "uses the user-provided server URL if given" do
Expand Down Expand Up @@ -105,7 +105,7 @@ module Chrome
custom_caps = Remote::Capabilities.new
custom_caps['chromeOptions'] = {'foo' => 'bar'}

http.should_receive(:call).with do |_, _, payload|
expect(http).to receive(:call) do |_, _, payload|
payload[:desiredCapabilities]['chromeOptions'].should include('foo' => 'bar')
resp
end
Expand All @@ -117,7 +117,7 @@ module Chrome
custom_caps = Remote::Capabilities.new
custom_caps['chromeOptions'] = {'args' => %w[foo bar]}

http.should_receive(:call).with do |_, _, payload|
expect(http).to receive(:call) do |_, _, payload|
payload[:desiredCapabilities]['chromeOptions']['args'].should == ['baz']
resp
end
Expand Down
8 changes: 5 additions & 3 deletions rb/spec/unit/selenium/webdriver/chrome/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ module Chrome
Platform.stub(:assert_executable).with("/some/path")
Chrome.driver_path = "/some/path"

ChildProcess.should_receive(:build).
with { |*args| args.first.should == "/some/path" }.
and_return(mock_process)
expect(ChildProcess).to receive(:build) do |*args|
args.first.should == "/some/path"
mock_process
end


Service.default_service
end
Expand Down
Loading

0 comments on commit f39c6d7

Please sign in to comment.