Skip to content
This repository has been archived by the owner on Jun 6, 2018. It is now read-only.

Commit

Permalink
Update to Ruby 2.0
Browse files Browse the repository at this point in the history
* Use Ruby 1.9 hash style
* Use %i symbol array shorthand
* Change Watir API usage from (:how, what) to (how: what)
  • Loading branch information
p0deje committed May 26, 2015
1 parent 4d7dfbf commit 429b7f9
Show file tree
Hide file tree
Showing 95 changed files with 2,037 additions and 2,038 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Expand Up @@ -26,7 +26,7 @@ WatirSpec::Implementation do |imp|
imp.name = :awesome

imp.browser_class = AwesomeWatir::Browser
imp.browser_args = [:some => 'option']
imp.browser_args = [some: 'option']
end

WatirSpec.persistent_browser = false # defaults to true, but can be disabled if needed
Expand Down
36 changes: 18 additions & 18 deletions alert_spec.rb
Expand Up @@ -14,11 +14,11 @@
describe '#text' do
it 'returns text of alert' do
not_compliant_on :watir_classic do
browser.button(:id => 'alert').click
browser.button(id: 'alert').click
end

deviates_on :watir_classic do
browser.button(:id => 'alert').click_no_wait
browser.button(id: 'alert').click_no_wait
end

expect(browser.alert.text).to include('ok')
Expand All @@ -32,11 +32,11 @@

it 'returns true if alert is present' do
not_compliant_on :watir_classic do
browser.button(:id => 'alert').click
browser.button(id: 'alert').click
end

deviates_on :watir_classic do
browser.button(:id => 'alert').click_no_wait
browser.button(id: 'alert').click_no_wait
end

browser.wait_until(10) { browser.alert.exists? }
Expand All @@ -46,11 +46,11 @@
describe '#ok' do
it 'closes alert' do
not_compliant_on :watir_classic do
browser.button(:id => 'alert').click
browser.button(id: 'alert').click
end

deviates_on :watir_classic do
browser.button(:id => 'alert').click_no_wait
browser.button(id: 'alert').click_no_wait
end

browser.alert.ok
Expand All @@ -61,11 +61,11 @@
describe '#close' do
it 'closes alert' do
not_compliant_on :watir_classic do
browser.button(:id => 'alert').click
browser.button(id: 'alert').click
end

deviates_on :watir_classic do
browser.button(:id => 'alert').click_no_wait
browser.button(id: 'alert').click_no_wait
end

browser.alert.when_present.close
Expand All @@ -75,7 +75,7 @@

describe 'when_present' do
it 'waits until alert is present and goes on' do
browser.button(:id => 'timeout-alert').click
browser.button(id: 'timeout-alert').click
browser.alert.when_present.close

expect(browser.alert).to_not exist
Expand All @@ -93,30 +93,30 @@
describe '#ok' do
it 'accepts confirm' do
not_compliant_on :watir_classic do
browser.button(:id => 'confirm').click
browser.button(id: 'confirm').click
end

deviates_on :watir_classic do
browser.button(:id => 'confirm').click_no_wait
browser.button(id: 'confirm').click_no_wait
end

browser.alert.ok
expect(browser.button(:id => 'confirm').value).to eq "true"
expect(browser.button(id: 'confirm').value).to eq "true"
end
end

describe '#close' do
it 'cancels confirm' do
not_compliant_on :watir_classic do
browser.button(:id => 'confirm').click
browser.button(id: 'confirm').click
end

deviates_on :watir_classic do
browser.button(:id => 'confirm').click_no_wait
browser.button(id: 'confirm').click_no_wait
end

browser.alert.when_present.close
expect(browser.button(:id => 'confirm').value).to eq "false"
expect(browser.button(id: 'confirm').value).to eq "false"
end
end
end
Expand All @@ -125,16 +125,16 @@
describe '#set' do
it 'enters text to prompt' do
not_compliant_on :watir_classic do
browser.button(:id => 'prompt').click
browser.button(id: 'prompt').click
end

deviates_on :watir_classic do
browser.button(:id => 'prompt').click_no_wait
browser.button(id: 'prompt').click_no_wait
end

browser.alert.set 'My Name'
browser.alert.ok
expect(browser.button(:id => 'prompt').value).to eq 'My Name'
expect(browser.button(id: 'prompt').value).to eq 'My Name'
end
end
end
Expand Down
46 changes: 23 additions & 23 deletions area_spec.rb
Expand Up @@ -10,67 +10,67 @@
# Exists method
describe "#exist?" do
it "returns true if the area exists" do
expect(browser.area(:id, "NCE")).to exist
expect(browser.area(:id, /NCE/)).to exist
expect(browser.area(:title, "Tables")).to exist
expect(browser.area(:title, /Tables/)).to exist
expect(browser.area(id: "NCE")).to exist
expect(browser.area(id: /NCE/)).to exist
expect(browser.area(title: "Tables")).to exist
expect(browser.area(title: /Tables/)).to exist

not_compliant_on :internet_explorer do
expect(browser.area(:href, "tables.html")).to exist
expect(browser.area(href: "tables.html")).to exist
end

expect(browser.area(:href, /tables/)).to exist
expect(browser.area(href: /tables/)).to exist

expect(browser.area(:index, 0)).to exist
expect(browser.area(:xpath, "//area[@id='NCE']")).to exist
expect(browser.area(index: 0)).to exist
expect(browser.area(xpath: "//area[@id='NCE']")).to exist
end

it "returns the first area if given no args" do
expect(browser.area).to exist
end

it "returns false if the area doesn't exist" do
expect(browser.area(:id, "no_such_id")).to_not exist
expect(browser.area(:id, /no_such_id/)).to_not exist
expect(browser.area(:title, "no_such_title")).to_not exist
expect(browser.area(:title, /no_such_title/)).to_not exist
expect(browser.area(id: "no_such_id")).to_not exist
expect(browser.area(id: /no_such_id/)).to_not exist
expect(browser.area(title: "no_such_title")).to_not exist
expect(browser.area(title: /no_such_title/)).to_not exist

expect(browser.area(:href, "no-tables.html")).to_not exist
expect(browser.area(:href, /no-tables/)).to_not exist
expect(browser.area(href: "no-tables.html")).to_not exist
expect(browser.area(href: /no-tables/)).to_not exist

expect(browser.area(:index, 1337)).to_not exist
expect(browser.area(:xpath, "//area[@id='no_such_id']")).to_not exist
expect(browser.area(index: 1337)).to_not exist
expect(browser.area(xpath: "//area[@id='no_such_id']")).to_not exist
end

it "raises TypeError when 'what' argument is invalid" do
expect { browser.area(:id, 3.14).exists? }.to raise_error(TypeError)
expect { browser.area(id: 3.14).exists? }.to raise_error(TypeError)
end

it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
expect { browser.area(:no_such_how, 'some_value').exists? }.to raise_error(Watir::Exception::MissingWayOfFindingObjectException)
expect { browser.area(no_such_how: 'some_value').exists? }.to raise_error(Watir::Exception::MissingWayOfFindingObjectException)
end
end

# Attribute methods
describe "#id" do
it "returns the id attribute" do
expect(browser.area(:index, 0).id).to eq "NCE"
expect(browser.area(index: 0).id).to eq "NCE"
end

it "returns an empty string if the element exists and the attribute doesn't" do
expect(browser.area(:index, 2).id).to eq ''
expect(browser.area(index: 2).id).to eq ''
end

it "raises UnknownObjectException if the area doesn't exist" do
expect { browser.area(:id, "no_such_id").id }.to raise_error(Watir::Exception::UnknownObjectException)
expect { browser.area(:index, 1337).id }.to raise_error(Watir::Exception::UnknownObjectException)
expect { browser.area(id: "no_such_id").id }.to raise_error(Watir::Exception::UnknownObjectException)
expect { browser.area(index: 1337).id }.to raise_error(Watir::Exception::UnknownObjectException)
end

end

describe "#respond_to?" do
it "returns true for all attribute methods" do
expect(browser.area(:index, 0)).to respond_to(:id)
expect(browser.area(index: 0)).to respond_to(:id)
end
end

Expand Down
6 changes: 3 additions & 3 deletions areas_spec.rb
Expand Up @@ -10,7 +10,7 @@
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
describe "with selectors" do
it "returns the matching elements" do
expect(browser.areas(:alt => "Tables").to_a).to eq [browser.area(:alt => "Tables")]
expect(browser.areas(alt: "Tables").to_a).to eq [browser.area(alt: "Tables")]
end
end
end
Expand All @@ -32,8 +32,8 @@
count = 0

browser.areas.each_with_index do |a, index|
expect(a.id).to eq browser.area(:index, index).id
expect(a.title).to eq browser.area(:index, index).title
expect(a.id).to eq browser.area(index: index).id
expect(a.title).to eq browser.area(index: index).title

count += 1
end
Expand Down

0 comments on commit 429b7f9

Please sign in to comment.