Skip to content

Commit dd422b8

Browse files
committed
rb: Switch to RSpec expect syntax
1 parent 87730e4 commit dd422b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1003
-1003
lines changed

rb/selenium-webdriver.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
2727
s.add_runtime_dependency "childprocess", ["~> 0.5"]
2828
s.add_runtime_dependency "websocket", ["~> 1.0"]
2929

30-
s.add_development_dependency "rspec", ["~> 2.99.0"]
30+
s.add_development_dependency "rspec", ["~> 3.0"]
3131
s.add_development_dependency "rack", ["~> 1.0"]
3232
s.add_development_dependency "ci_reporter", ["~> 1.6", ">= 1.6.2"]
3333
s.add_development_dependency "webmock", ["~> 1.7", ">= 1.7.5"]

rb/spec/integration/selenium/client/api/backward_compatible_api_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@
2323
it "provides legacy driver methods" do
2424
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/test_click_page1.html"
2525

26-
page.get_title.should eql("Click Page 1")
27-
page.get_text("link").index("Click here for next page").should_not be_nil
26+
expect(page.get_title).to eql("Click Page 1")
27+
expect(page.get_text("link").index("Click here for next page")).not_to be_nil
2828

2929
links = page.get_all_links
30-
links.length.should > 3
31-
links[3].should eql("linkToAnchorOnThisPage")
30+
expect(links.length).to be > 3
31+
expect(links[3]).to eql("linkToAnchorOnThisPage")
3232

3333
page.click "link"
3434
page.wait_for_page_to_load 5000
35-
page.get_location.should =~ %r"/selenium-server/org/openqa/selenium/tests/html/test_click_page2.html"
35+
expect(page.get_location).to match(%r"/selenium-server/org/openqa/selenium/tests/html/test_click_page2.html")
3636

3737
page.click "previousPage"
3838
page.wait_for_page_to_load 5000
39-
page.get_location.should =~ %r"/selenium-server/org/openqa/selenium/tests/html/test_click_page1.html"
39+
expect(page.get_location).to match(%r"/selenium-server/org/openqa/selenium/tests/html/test_click_page1.html")
4040
end
4141
end

rb/spec/integration/selenium/client/api/click_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,37 @@
2222
describe "Click Instrumentation" do
2323
it "clicks" do
2424
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/test_click_page1.html"
25-
page.text_content("link").should eql("Click here for next page")
25+
expect(page.text_content("link")).to eql("Click here for next page")
2626

2727
page.click "link", :wait_for => :page
28-
page.title.should eql("Click Page Target")
28+
expect(page.title).to eql("Click Page Target")
2929

3030
page.click "previousPage", :wait_for => :page
31-
page.title.should eql("Click Page 1")
31+
expect(page.title).to eql("Click Page 1")
3232

3333
page.click "linkWithEnclosedImage", :wait_for => :page
34-
page.title.should eql("Click Page Target")
34+
expect(page.title).to eql("Click Page Target")
3535

3636
page.click "previousPage", :wait_for => :page
3737
page.click "enclosedImage", :wait_for => :page
38-
page.title.should eql("Click Page Target")
38+
expect(page.title).to eql("Click Page Target")
3939

4040
page.click "previousPage", :wait_for => :page
4141
page.click "extraEnclosedImage", :wait_for => :page
42-
page.title.should eql("Click Page Target")
42+
expect(page.title).to eql("Click Page Target")
4343

4444
page.click "previousPage", :wait_for => :page
4545
page.click "linkToAnchorOnThisPage"
46-
page.title.should eql("Click Page 1")
46+
expect(page.title).to eql("Click Page 1")
4747

4848
page.click "linkWithOnclickReturnsFalse"
49-
page.title.should eql("Click Page 1")
49+
expect(page.title).to eql("Click Page 1")
5050
end
5151

5252
it "double clicks" do
5353
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/test_click_page1.html"
5454
page.double_click "doubleClickable"
5555

56-
page.get_alert.should eql("double clicked!")
56+
expect(page.get_alert).to eql("double clicked!")
5757
end
5858
end

rb/spec/integration/selenium/client/api/cookie_spec.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,35 @@
2424
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/path1/cookie1.html"
2525
page.delete_all_visible_cookies
2626

27-
page.cookies.should be_empty
27+
expect(page.cookies).to be_empty
2828

2929
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/path2/cookie2.html"
3030
page.delete_all_visible_cookies
3131

32-
page.cookies.should be_empty
32+
expect(page.cookies).to be_empty
3333
end
3434

3535
it "can set cookies" do
3636
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/path1/cookie1.html"
3737
page.create_cookie "addedCookieForPath1=new value1"
3838
page.create_cookie "addedCookieForPath2=new value2", :path => "/selenium-server/org/openqa/selenium/tests/html/path2/", :max_age => 60
3939
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/path1/cookie1.html"
40-
page.cookies.should =~ /addedCookieForPath1=new value1/
40+
expect(page.cookies).to match(/addedCookieForPath1=new value1/)
4141

42-
page.cookie?("addedCookieForPath1").should be true
43-
page.cookie("addedCookieForPath1").should eql("new value1")
44-
page.cookie?("testCookie").should be false
45-
page.cookie?("addedCookieForPath2").should be false
42+
expect(page.cookie?("addedCookieForPath1")).to be true
43+
expect(page.cookie("addedCookieForPath1")).to eql("new value1")
44+
expect(page.cookie?("testCookie")).to be false
45+
expect(page.cookie?("addedCookieForPath2")).to be false
4646

4747
page.delete_cookie "addedCookieForPath1", "/selenium-server/org/openqa/selenium/tests/html/path1/"
48-
page.cookies.should be_empty
48+
expect(page.cookies).to be_empty
4949

5050
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/path2/cookie2.html"
51-
page.cookie("addedCookieForPath2").should eql("new value2")
52-
page.cookie?("addedCookieForPath1").should be false
51+
expect(page.cookie("addedCookieForPath2")).to eql("new value2")
52+
expect(page.cookie?("addedCookieForPath1")).to be false
5353

5454
page.delete_cookie "addedCookieForPath2", "/selenium-server/org/openqa/selenium/tests/html/path2/"
5555
page.delete_cookie "addedCookieForPath2"
56-
page.cookies.should be_empty
56+
expect(page.cookies).to be_empty
5757
end
5858
end

rb/spec/integration/selenium/client/api/element_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
describe "Element API" do
2323
it "can detect element presence" do
2424
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/test_element_present.html"
25-
page.element?('aLink').should be true
25+
expect(page.element?('aLink')).to be true
2626

2727
page.click 'removeLinkAfterAWhile', :wait_for => :no_element, :element => "aLink"
28-
page.element?('aLink').should be false
28+
expect(page.element?('aLink')).to be false
2929

3030
page.click 'addLinkAfterAWhile', :wait_for => :element, :element => "aLink"
31-
page.element?('aLink').should be true
31+
expect(page.element?('aLink')).to be true
3232
end
3333
end

rb/spec/integration/selenium/client/api/highlight_located_element_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
page.execution_delay = 1000
2626
page.highlight_located_element = true
2727
begin
28-
page.text("calculator-result").should be_empty
28+
expect(page.text("calculator-result")).to be_empty
2929

3030
page.type "calculator-expression", "2 + 2"
3131
page.click "calculator-button" , :wait_for => :ajax, :javascript_framework => :jquery
3232

33-
page.value("calculator-result").should eql("4")
33+
expect(page.value("calculator-result")).to eql("4")
3434
ensure
3535
page.highlight_located_element = false
3636
end

rb/spec/integration/selenium/client/api/screenshot_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
describe "Screenshot" do
2323
it "can capture html for current page" do
2424
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/test_click_page1.html"
25-
page.get_html_source.should =~ /<head>/
25+
expect(page.get_html_source).to match(/<head>/)
2626
end
2727

2828
# Raising Java Error on Windows
@@ -32,10 +32,10 @@
3232
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/test_click_page1.html"
3333
page.capture_screenshot tempfile
3434

35-
File.exists?(tempfile).should be true
35+
expect(File.exists?(tempfile)).to be true
3636
File.open(tempfile, "rb") do |io|
3737
magic = io.read(4)
38-
magic.should == "\211PNG"
38+
expect(magic).to eq("\211PNG")
3939
end
4040
end
4141

@@ -45,6 +45,6 @@
4545
encodedImage = page.capture_screenshot_to_string
4646
pngImage = Base64.decode64(encodedImage)
4747

48-
pngImage.should =~ /^\211PNG/n
48+
expect(pngImage).to match(/^\211PNG/n)
4949
end
5050
end

rb/spec/integration/selenium/client/api/select_window_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@
2424
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/test_select_window.html"
2525
page.click "popupPage", :wait_for => :popup, :window => "myPopupWindow", :select => true
2626

27-
page.location.should =~ %r{/tests/html/test_select_window_popup.html}
28-
page.title.should =~ /Select Window Popup/
29-
page.all_window_names.size.should eql(2)
30-
page.all_window_names.include?("myPopupWindow").should be true
27+
expect(page.location).to match(%r{/tests/html/test_select_window_popup.html})
28+
expect(page.title).to match(/Select Window Popup/)
29+
expect(page.all_window_names.size).to eql(2)
30+
expect(page.all_window_names.include?("myPopupWindow")).to be true
3131

3232
page.close
3333
page.select_window "null"
3434

35-
page.location.should =~ %r{/tests/html/test_select_window.html}
35+
expect(page.location).to match(%r{/tests/html/test_select_window.html})
3636

3737
page.click "popupPage", :wait_for => :popup, :window => "myPopupWindow"
3838
page.select_window "title=Select Window Popup"
3939

40-
page.location.should =~ %r{/tests/html/test_select_window_popup.html}
40+
expect(page.location).to match(%r{/tests/html/test_select_window_popup.html})
4141

4242
page.close
4343
page.select_window "null"
@@ -47,7 +47,7 @@
4747
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/test_select_window.html"
4848
page.click "popupAnonymous", :wait_for => :popup, :window => "anonymouspopup", :select => true
4949

50-
page.location.should =~ %r{/tests/html/test_select_window_popup.html}
50+
expect(page.location).to match(%r{/tests/html/test_select_window_popup.html})
5151

5252
page.click "closePage"
5353
page.select_window "null"
@@ -57,7 +57,7 @@
5757
page.open "http://localhost:4444/selenium-server/org/openqa/selenium/tests/html/test_select_window.html"
5858
page.click "popupAnonymous", :wait_for => :popup, :window => "anonymouspopup", :select => true
5959

60-
page.location.should =~ %r{/tests/html/test_select_window_popup.html}
60+
expect(page.location).to match(%r{/tests/html/test_select_window_popup.html})
6161

6262
page.click "closePage2"
6363
page.select_window "null"

rb/spec/integration/selenium/client/api/wait_for_ajax_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@
2323
describe "Prototype" do
2424
it "blocks until AJAX request is complete" do
2525
page.open "http://localhost:4567/prototype.html"
26-
page.text("calculator-result").should be_empty
26+
expect(page.text("calculator-result")).to be_empty
2727
page.type "calculator-expression", "2 + 2"
2828
page.click "calculator-button", :wait_for => :ajax
2929

30-
page.value("calculator-result").should eql("4")
30+
expect(page.value("calculator-result")).to eql("4")
3131
end
3232
end
3333

3434
describe "jQuery" do
3535
it "blocks until AJAX request is complete" do
3636
page.open "http://localhost:4567/jquery.html"
3737

38-
page.text("calculator-result").should be_empty
38+
expect(page.text("calculator-result")).to be_empty
3939

4040
page.type "calculator-expression", "2 + 2"
4141
page.click "calculator-button" , :wait_for => :ajax, :javascript_framework => :jquery
4242

43-
page.value("calculator-result").should eql("4")
43+
expect(page.value("calculator-result")).to eql("4")
4444
end
4545
end
4646
end

rb/spec/integration/selenium/client/api/wait_for_field_value_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@
2323
it "blocks until field is updated" do
2424
page.open "http://localhost:4567/jquery.html"
2525

26-
page.text("calculator-result").should be_empty
26+
expect(page.text("calculator-result")).to be_empty
2727

2828
page.type "calculator-expression", "2 + 2"
2929
page.click "calculator-button", :wait_for => :value,
3030
:element => "calculator-result",
3131
:value => "4"
3232

33-
page.value("calculator-result").should eql("4")
33+
expect(page.value("calculator-result")).to eql("4")
3434
end
3535

3636

3737
it "times out when field is never properly updated" do
3838
page.open "http://localhost:4567/jquery.html"
3939

40-
page.text("calculator-result").should be_empty
40+
expect(page.text("calculator-result")).to be_empty
4141
page.type "calculator-expression", "2 + 2"
4242

4343
should_timeout do
@@ -53,13 +53,13 @@
5353
it "blocks until field is updated" do
5454
page.open "http://localhost:4567/jquery.html"
5555

56-
page.text("calculator-result").should be_empty
56+
expect(page.text("calculator-result")).to be_empty
5757
page.type "calculator-expression", "2 + 2"
5858
page.click "calculator-button", :wait_for => :no_value,
5959
:element => "calculator-result",
6060
:value => ""
6161

62-
page.value("calculator-result").should eql("4")
62+
expect(page.value("calculator-result")).to eql("4")
6363
end
6464

6565
it "times out when field is never properly updated" do

0 commit comments

Comments
 (0)