Use Node#value rather than Node#[] in specs

This commit is contained in:
Thomas Walpole 2016-08-04 12:06:31 -07:00
parent 232646ca97
commit 25e37be19a
4 changed files with 13 additions and 13 deletions

View File

@ -7,7 +7,7 @@ Capybara::SpecHelper.spec "#all" do
it "should find all elements using the given locator" do
expect(@session.all('//p').size).to eq(3)
expect(@session.all('//h1').first.text).to eq('This is a test')
expect(@session.all("//input[@id='test_field']").first[:value]).to eq('monkey')
expect(@session.all("//input[@id='test_field']").first.value).to eq('monkey')
end
it "should return an empty array when nothing was found" do
@ -28,7 +28,7 @@ Capybara::SpecHelper.spec "#all" do
context "with css selectors" do
it "should find all elements using the given selector" do
expect(@session.all(:css, 'h1').first.text).to eq('This is a test')
expect(@session.all(:css, "input[id='test_field']").first[:value]).to eq('monkey')
expect(@session.all(:css, "input[id='test_field']").first.value).to eq('monkey')
end
it "should find all elements when given a list of selectors" do
@ -39,7 +39,7 @@ Capybara::SpecHelper.spec "#all" do
context "with xpath selectors" do
it "should find the first element using the given locator" do
expect(@session.all(:xpath, '//h1').first.text).to eq('This is a test')
expect(@session.all(:xpath, "//input[@id='test_field']").first[:value]).to eq('monkey')
expect(@session.all(:xpath, "//input[@id='test_field']").first.value).to eq('monkey')
end
end
@ -47,7 +47,7 @@ Capybara::SpecHelper.spec "#all" do
before { Capybara.default_selector = :css }
it "should find the first element using the given locator" do
expect(@session.all('h1').first.text).to eq('This is a test')
expect(@session.all("input[id='test_field']").first[:value]).to eq('monkey')
expect(@session.all("input[id='test_field']").first.value).to eq('monkey')
end
end

View File

@ -21,7 +21,7 @@ Capybara::SpecHelper.spec '#find_button' do
context "with :exact option" do
it "should accept partial matches when false" do
expect(@session.find_button('What an Awesome', :exact => false)[:value]).to eq("awesome")
expect(@session.find_button('What an Awesome', :exact => false).value).to eq("awesome")
end
it "should not accept partial matches when true" do

View File

@ -10,7 +10,7 @@ Capybara::SpecHelper.spec '#find' do
it "should find the first element using the given locator" do
expect(@session.find('//h1').text).to eq('This is a test')
expect(@session.find("//input[@id='test_field']")[:value]).to eq('monkey')
expect(@session.find("//input[@id='test_field']").value).to eq('monkey')
end
it "should find the first element using the given locator and options" do
@ -79,7 +79,7 @@ Capybara::SpecHelper.spec '#find' do
context "with css selectors" do
it "should find the first element using the given locator" do
expect(@session.find(:css, 'h1').text).to eq('This is a test')
expect(@session.find(:css, "input[id='test_field']")[:value]).to eq('monkey')
expect(@session.find(:css, "input[id='test_field']").value).to eq('monkey')
end
it "should support pseudo selectors" do
@ -90,7 +90,7 @@ Capybara::SpecHelper.spec '#find' do
context "with xpath selectors" do
it "should find the first element using the given locator" do
expect(@session.find(:xpath, '//h1').text).to eq('This is a test')
expect(@session.find(:xpath, "//input[@id='test_field']")[:value]).to eq('monkey')
expect(@session.find(:xpath, "//input[@id='test_field']").value).to eq('monkey')
end
end
@ -197,7 +197,7 @@ Capybara::SpecHelper.spec '#find' do
before { Capybara.default_selector = :css }
it "should find the first element using the given locator" do
expect(@session.find('h1').text).to eq('This is a test')
expect(@session.find("input[id='test_field']")[:value]).to eq('monkey')
expect(@session.find("input[id='test_field']").value).to eq('monkey')
end
after { Capybara.default_selector = :xpath }
end

View File

@ -6,7 +6,7 @@ Capybara::SpecHelper.spec '#first' do
it "should find the first element using the given locator" do
expect(@session.first('//h1').text).to eq('This is a test')
expect(@session.first("//input[@id='test_field']")[:value]).to eq('monkey')
expect(@session.first("//input[@id='test_field']").value).to eq('monkey')
end
it "should return nil when nothing was found" do
@ -22,14 +22,14 @@ Capybara::SpecHelper.spec '#first' do
context "with css selectors" do
it "should find the first element using the given selector" do
expect(@session.first(:css, 'h1').text).to eq('This is a test')
expect(@session.first(:css, "input[id='test_field']")[:value]).to eq('monkey')
expect(@session.first(:css, "input[id='test_field']").value).to eq('monkey')
end
end
context "with xpath selectors" do
it "should find the first element using the given locator" do
expect(@session.first(:xpath, '//h1').text).to eq('This is a test')
expect(@session.first(:xpath, "//input[@id='test_field']")[:value]).to eq('monkey')
expect(@session.first(:xpath, "//input[@id='test_field']").value).to eq('monkey')
end
end
@ -37,7 +37,7 @@ Capybara::SpecHelper.spec '#first' do
before { Capybara.default_selector = :css }
it "should find the first element using the given locator" do
expect(@session.first('h1').text).to eq('This is a test')
expect(@session.first("input[id='test_field']")[:value]).to eq('monkey')
expect(@session.first("input[id='test_field']").value).to eq('monkey')
end
end