mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Fix Rubocop Issues
This commit is contained in:
parent
fbe8257fa6
commit
7ca1cdc828
11 changed files with 51 additions and 18 deletions
|
@ -128,6 +128,7 @@ Capybara::SpecHelper.spec '#all' do
|
||||||
it 'should succeed when the number of elements founds matches the expectation' do
|
it 'should succeed when the number of elements founds matches the expectation' do
|
||||||
expect { @session.all(:css, 'h1, p', count: 4) }.not_to raise_error
|
expect { @session.all(:css, 'h1, p', count: 4) }.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||||
expect { @session.all(:css, 'h1, p', count: 5) }.to raise_error(Capybara::ExpectationNotMet)
|
expect { @session.all(:css, 'h1, p', count: 5) }.to raise_error(Capybara::ExpectationNotMet)
|
||||||
end
|
end
|
||||||
|
@ -137,6 +138,7 @@ Capybara::SpecHelper.spec '#all' do
|
||||||
it 'should succeed when the number of elements founds matches the expectation' do
|
it 'should succeed when the number of elements founds matches the expectation' do
|
||||||
expect { @session.all(:css, 'h1, p', minimum: 0) }.not_to raise_error
|
expect { @session.all(:css, 'h1, p', minimum: 0) }.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||||
expect { @session.all(:css, 'h1, p', minimum: 5) }.to raise_error(Capybara::ExpectationNotMet)
|
expect { @session.all(:css, 'h1, p', minimum: 5) }.to raise_error(Capybara::ExpectationNotMet)
|
||||||
end
|
end
|
||||||
|
@ -146,6 +148,7 @@ Capybara::SpecHelper.spec '#all' do
|
||||||
it 'should succeed when the number of elements founds matches the expectation' do
|
it 'should succeed when the number of elements founds matches the expectation' do
|
||||||
expect { @session.all(:css, 'h1, p', maximum: 4) }.not_to raise_error
|
expect { @session.all(:css, 'h1, p', maximum: 4) }.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||||
expect { @session.all(:css, 'h1, p', maximum: 0) }.to raise_error(Capybara::ExpectationNotMet)
|
expect { @session.all(:css, 'h1, p', maximum: 0) }.to raise_error(Capybara::ExpectationNotMet)
|
||||||
end
|
end
|
||||||
|
@ -155,6 +158,7 @@ Capybara::SpecHelper.spec '#all' do
|
||||||
it 'should succeed when the number of elements founds matches the expectation' do
|
it 'should succeed when the number of elements founds matches the expectation' do
|
||||||
expect { @session.all(:css, 'h1, p', between: 2..7) }.not_to raise_error
|
expect { @session.all(:css, 'h1, p', between: 2..7) }.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||||
expect { @session.all(:css, 'h1, p', between: 0..3) }.to raise_error(Capybara::ExpectationNotMet)
|
expect { @session.all(:css, 'h1, p', between: 0..3) }.to raise_error(Capybara::ExpectationNotMet)
|
||||||
end
|
end
|
||||||
|
@ -175,6 +179,7 @@ Capybara::SpecHelper.spec '#all' do
|
||||||
between: 0..3 }
|
between: 0..3 }
|
||||||
expect { @session.all(:css, 'h1, p', o) }.not_to raise_error
|
expect { @session.all(:css, 'h1, p', o) }.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with no :count expectation' do
|
context 'with no :count expectation' do
|
||||||
it 'fails if :minimum is not met' do
|
it 'fails if :minimum is not met' do
|
||||||
o = { minimum: 5,
|
o = { minimum: 5,
|
||||||
|
@ -182,18 +187,21 @@ Capybara::SpecHelper.spec '#all' do
|
||||||
between: 2..7 }
|
between: 2..7 }
|
||||||
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails if :maximum is not met' do
|
it 'fails if :maximum is not met' do
|
||||||
o = { minimum: 0,
|
o = { minimum: 0,
|
||||||
maximum: 0,
|
maximum: 0,
|
||||||
between: 2..7 }
|
between: 2..7 }
|
||||||
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails if :between is not met' do
|
it 'fails if :between is not met' do
|
||||||
o = { minimum: 0,
|
o = { minimum: 0,
|
||||||
maximum: 4,
|
maximum: 4,
|
||||||
between: 0..3 }
|
between: 0..3 }
|
||||||
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds if all combineable expectations are met' do
|
it 'succeeds if all combineable expectations are met' do
|
||||||
o = { minimum: 0,
|
o = { minimum: 0,
|
||||||
maximum: 4,
|
maximum: 4,
|
||||||
|
|
|
@ -159,6 +159,7 @@ Capybara::SpecHelper.spec '#assert_text' do
|
||||||
between: 0..4 }
|
between: 0..4 }
|
||||||
expect { @session.assert_text('Header', o) }.not_to raise_error
|
expect { @session.assert_text('Header', o) }.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with no :count expectation' do
|
context 'with no :count expectation' do
|
||||||
it 'fails if :minimum is not met' do
|
it 'fails if :minimum is not met' do
|
||||||
o = { minimum: 6,
|
o = { minimum: 6,
|
||||||
|
@ -166,18 +167,21 @@ Capybara::SpecHelper.spec '#assert_text' do
|
||||||
between: 2..7 }
|
between: 2..7 }
|
||||||
expect { @session.assert_text('Header', o) }.to raise_error(Capybara::ExpectationNotMet)
|
expect { @session.assert_text('Header', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails if :maximum is not met' do
|
it 'fails if :maximum is not met' do
|
||||||
o = { minimum: 0,
|
o = { minimum: 0,
|
||||||
maximum: 0,
|
maximum: 0,
|
||||||
between: 2..7 }
|
between: 2..7 }
|
||||||
expect { @session.assert_text('Header', o) }.to raise_error(Capybara::ExpectationNotMet)
|
expect { @session.assert_text('Header', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails if :between is not met' do
|
it 'fails if :between is not met' do
|
||||||
o = { minimum: 0,
|
o = { minimum: 0,
|
||||||
maximum: 5,
|
maximum: 5,
|
||||||
between: 0..4 }
|
between: 0..4 }
|
||||||
expect { @session.assert_text('Header', o) }.to raise_error(Capybara::ExpectationNotMet)
|
expect { @session.assert_text('Header', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds if all combineable expectations are met' do
|
it 'succeeds if all combineable expectations are met' do
|
||||||
o = { minimum: 0,
|
o = { minimum: 0,
|
||||||
maximum: 5,
|
maximum: 5,
|
||||||
|
|
|
@ -275,14 +275,17 @@ Capybara::SpecHelper.spec '#find' do
|
||||||
@session.find(:css, '.multiple', match: :one)
|
@session.find(:css, '.multiple', match: :one)
|
||||||
end.to raise_error(Capybara::Ambiguous)
|
end.to raise_error(Capybara::Ambiguous)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error even if there the match is exact and the others are inexact' do
|
it 'raises an error even if there the match is exact and the others are inexact' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], exact: false, match: :one)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], exact: false, match: :one)
|
||||||
end.to raise_error(Capybara::Ambiguous)
|
end.to raise_error(Capybara::Ambiguous)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the element if there is only one' do
|
it 'returns the element if there is only one' do
|
||||||
expect(@session.find(:css, '.singular', match: :one).text).to eq('singular')
|
expect(@session.find(:css, '.singular', match: :one).text).to eq('singular')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error if there is no match' do
|
it 'raises an error if there is no match' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:css, '.does-not-exist', match: :one)
|
@session.find(:css, '.does-not-exist', match: :one)
|
||||||
|
@ -294,6 +297,7 @@ Capybara::SpecHelper.spec '#find' do
|
||||||
it 'returns the first matched element' do
|
it 'returns the first matched element' do
|
||||||
expect(@session.find(:css, '.multiple', match: :first).text).to eq('multiple one')
|
expect(@session.find(:css, '.multiple', match: :first).text).to eq('multiple one')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error if there is no match' do
|
it 'raises an error if there is no match' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:css, '.does-not-exist', match: :first)
|
@session.find(:css, '.does-not-exist', match: :first)
|
||||||
|
@ -308,19 +312,23 @@ Capybara::SpecHelper.spec '#find' do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :smart, exact: false)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :smart, exact: false)
|
||||||
end.to raise_error(Capybara::Ambiguous)
|
end.to raise_error(Capybara::Ambiguous)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'finds a single exact match when there also are inexact matches' do
|
it 'finds a single exact match when there also are inexact matches' do
|
||||||
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :smart, exact: false)
|
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :smart, exact: false)
|
||||||
expect(result.text).to eq('almost singular')
|
expect(result.text).to eq('almost singular')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error when there are multiple inexact matches' do
|
it 'raises an error when there are multiple inexact matches' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :smart, exact: false)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :smart, exact: false)
|
||||||
end.to raise_error(Capybara::Ambiguous)
|
end.to raise_error(Capybara::Ambiguous)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'finds a single inexact match' do
|
it 'finds a single inexact match' do
|
||||||
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :smart, exact: false)
|
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :smart, exact: false)
|
||||||
expect(result.text).to eq('almost singular but not quite')
|
expect(result.text).to eq('almost singular but not quite')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error if there is no match' do
|
it 'raises an error if there is no match' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :smart, exact: false)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :smart, exact: false)
|
||||||
|
@ -334,20 +342,24 @@ Capybara::SpecHelper.spec '#find' do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :smart, exact: true)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :smart, exact: true)
|
||||||
end.to raise_error(Capybara::Ambiguous)
|
end.to raise_error(Capybara::Ambiguous)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'finds a single exact match when there also are inexact matches' do
|
it 'finds a single exact match when there also are inexact matches' do
|
||||||
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :smart, exact: true)
|
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :smart, exact: true)
|
||||||
expect(result.text).to eq('almost singular')
|
expect(result.text).to eq('almost singular')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error when there are multiple inexact matches' do
|
it 'raises an error when there are multiple inexact matches' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :smart, exact: true)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :smart, exact: true)
|
||||||
end.to raise_error(Capybara::ElementNotFound)
|
end.to raise_error(Capybara::ElementNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error when there is a single inexact matches' do
|
it 'raises an error when there is a single inexact matches' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :smart, exact: true)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :smart, exact: true)
|
||||||
end.to raise_error(Capybara::ElementNotFound)
|
end.to raise_error(Capybara::ElementNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error if there is no match' do
|
it 'raises an error if there is no match' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :smart, exact: true)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :smart, exact: true)
|
||||||
|
@ -362,18 +374,22 @@ Capybara::SpecHelper.spec '#find' do
|
||||||
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :prefer_exact, exact: false)
|
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :prefer_exact, exact: false)
|
||||||
expect(result.text).to eq('multiple one')
|
expect(result.text).to eq('multiple one')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'finds a single exact match when there also are inexact matches' do
|
it 'finds a single exact match when there also are inexact matches' do
|
||||||
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :prefer_exact, exact: false)
|
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :prefer_exact, exact: false)
|
||||||
expect(result.text).to eq('almost singular')
|
expect(result.text).to eq('almost singular')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'picks the first one when there are multiple inexact matches' do
|
it 'picks the first one when there are multiple inexact matches' do
|
||||||
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :prefer_exact, exact: false)
|
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :prefer_exact, exact: false)
|
||||||
expect(result.text).to eq('almost singular but not quite')
|
expect(result.text).to eq('almost singular but not quite')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'finds a single inexact match' do
|
it 'finds a single inexact match' do
|
||||||
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :prefer_exact, exact: false)
|
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :prefer_exact, exact: false)
|
||||||
expect(result.text).to eq('almost singular but not quite')
|
expect(result.text).to eq('almost singular but not quite')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error if there is no match' do
|
it 'raises an error if there is no match' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :prefer_exact, exact: false)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :prefer_exact, exact: false)
|
||||||
|
@ -386,20 +402,24 @@ Capybara::SpecHelper.spec '#find' do
|
||||||
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :prefer_exact, exact: true)
|
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :prefer_exact, exact: true)
|
||||||
expect(result.text).to eq('multiple one')
|
expect(result.text).to eq('multiple one')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'finds a single exact match when there also are inexact matches' do
|
it 'finds a single exact match when there also are inexact matches' do
|
||||||
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :prefer_exact, exact: true)
|
result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :prefer_exact, exact: true)
|
||||||
expect(result.text).to eq('almost singular')
|
expect(result.text).to eq('almost singular')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error if there are multiple inexact matches' do
|
it 'raises an error if there are multiple inexact matches' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :prefer_exact, exact: true)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :prefer_exact, exact: true)
|
||||||
end.to raise_error(Capybara::ElementNotFound)
|
end.to raise_error(Capybara::ElementNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error if there is a single inexact match' do
|
it 'raises an error if there is a single inexact match' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :prefer_exact, exact: true)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :prefer_exact, exact: true)
|
||||||
end.to raise_error(Capybara::ElementNotFound)
|
end.to raise_error(Capybara::ElementNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises an error if there is no match' do
|
it 'raises an error if there is no match' do
|
||||||
expect do
|
expect do
|
||||||
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :prefer_exact, exact: true)
|
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :prefer_exact, exact: true)
|
||||||
|
|
|
@ -137,7 +137,7 @@ RSpec.describe Capybara::Result do
|
||||||
expect(result.instance_variable_get('@result_cache').size).to eq 4
|
expect(result.instance_variable_get('@result_cache').size).to eq 4
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#each' do
|
describe '#each' do
|
||||||
it 'lazily evaluates' do
|
it 'lazily evaluates' do
|
||||||
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
||||||
results = []
|
results = []
|
||||||
|
|
|
@ -81,6 +81,7 @@ xfeature 'if xfeature aliases to pending then' do
|
||||||
scenario "this should be 'temporarily disabled with xfeature'" do
|
scenario "this should be 'temporarily disabled with xfeature'" do
|
||||||
# dummy
|
# dummy
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "this also should be 'temporarily disabled with xfeature'" do
|
scenario "this also should be 'temporarily disabled with xfeature'" do
|
||||||
# dummy
|
# dummy
|
||||||
end
|
end
|
||||||
|
|
|
@ -857,7 +857,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
|
||||||
session.visit('/with_js')
|
session.visit('/with_js')
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#and' do
|
describe '#and' do
|
||||||
it "should run 'concurrently'" do
|
it "should run 'concurrently'" do
|
||||||
Capybara.using_wait_time(2) do
|
Capybara.using_wait_time(2) do
|
||||||
matcher = have_text('this is not there').and have_text('neither is this')
|
matcher = have_text('this is not there').and have_text('neither is this')
|
||||||
|
@ -899,14 +899,14 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#and_then' do
|
describe '#and_then' do
|
||||||
it 'should run sequentially' do
|
it 'should run sequentially' do
|
||||||
session.click_link('reload-link')
|
session.click_link('reload-link')
|
||||||
expect(el).to have_text('waiting to be reloaded').and_then have_text('has been reloaded')
|
expect(el).to have_text('waiting to be reloaded').and_then have_text('has been reloaded')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#or' do
|
describe '#or' do
|
||||||
it "should run 'concurrently'" do
|
it "should run 'concurrently'" do
|
||||||
session.using_wait_time(3) do
|
session.using_wait_time(3) do
|
||||||
expect(Benchmark.realtime do
|
expect(Benchmark.realtime do
|
||||||
|
|
|
@ -43,7 +43,7 @@ RSpec.describe 'capybara/rspec' do
|
||||||
expect(Capybara.current_driver).to eq(:culerity)
|
expect(Capybara.current_driver).to eq(:culerity)
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#all' do
|
describe '#all' do
|
||||||
it 'allows access to the Capybara finder' do
|
it 'allows access to the Capybara finder' do
|
||||||
visit('/with_html')
|
visit('/with_html')
|
||||||
found = all(:css, 'h2') { |element| element[:class] == 'head' }
|
found = all(:css, 'h2') { |element| element[:class] == 'head' }
|
||||||
|
@ -57,7 +57,7 @@ RSpec.describe 'capybara/rspec' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#within' do
|
describe '#within' do
|
||||||
it 'allows access to the Capybara scoper' do
|
it 'allows access to the Capybara scoper' do
|
||||||
visit('/with_html')
|
visit('/with_html')
|
||||||
expect do
|
expect do
|
||||||
|
@ -82,7 +82,7 @@ RSpec.describe 'capybara/rspec' do
|
||||||
end.new
|
end.new
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#all' do
|
describe '#all' do
|
||||||
it 'allows access to the Capybara finder' do
|
it 'allows access to the Capybara finder' do
|
||||||
test_class_instance.visit('/with_html')
|
test_class_instance.visit('/with_html')
|
||||||
expect(test_class_instance.all(:css, 'h2.head').size).to eq(5)
|
expect(test_class_instance.all(:css, 'h2.head').size).to eq(5)
|
||||||
|
@ -95,7 +95,7 @@ RSpec.describe 'capybara/rspec' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#within' do
|
describe '#within' do
|
||||||
it 'allows access to the Capybara scoper' do
|
it 'allows access to the Capybara scoper' do
|
||||||
test_class_instance.visit('/with_html')
|
test_class_instance.visit('/with_html')
|
||||||
expect do
|
expect do
|
||||||
|
|
|
@ -182,7 +182,7 @@ RSpec.describe Capybara::Selenium::Driver do
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.describe Capybara::Selenium::Node do
|
RSpec.describe Capybara::Selenium::Node do
|
||||||
context '#click' do
|
describe '#click' do
|
||||||
it 'warns when attempting on a table row' do
|
it 'warns when attempting on a table row' do
|
||||||
session = TestSessions::SeleniumFirefox
|
session = TestSessions::SeleniumFirefox
|
||||||
session.visit('/tables')
|
session.visit('/tables')
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
RSpec.describe Capybara::Session do
|
RSpec.describe Capybara::Session do
|
||||||
context '#new' do
|
describe '#new' do
|
||||||
it 'should raise an error if passed non-existent driver' do
|
it 'should raise an error if passed non-existent driver' do
|
||||||
expect do
|
expect do
|
||||||
described_class.new(:quox, TestApp).driver
|
described_class.new(:quox, TestApp).driver
|
||||||
|
|
|
@ -6,7 +6,7 @@ require 'selenium-webdriver'
|
||||||
RSpec.shared_examples 'Capybara::Node' do |session, _mode|
|
RSpec.shared_examples 'Capybara::Node' do |session, _mode|
|
||||||
let(:session) { session }
|
let(:session) { session }
|
||||||
|
|
||||||
context '#content_editable?' do
|
describe '#content_editable?' do
|
||||||
it 'returns true when the element is content editable' do
|
it 'returns true when the element is content editable' do
|
||||||
session.visit('/with_js')
|
session.visit('/with_js')
|
||||||
expect(session.find(:css, '#existing_content_editable').base.content_editable?).to be true
|
expect(session.find(:css, '#existing_content_editable').base.content_editable?).to be true
|
||||||
|
@ -19,7 +19,7 @@ RSpec.shared_examples 'Capybara::Node' do |session, _mode|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#send_keys' do
|
describe '#send_keys' do
|
||||||
it 'should process space' do
|
it 'should process space' do
|
||||||
session.visit('/form')
|
session.visit('/form')
|
||||||
session.find(:css, '#address1_city').send_keys('ocean', [:shift, :space, 'side'])
|
session.find(:css, '#address1_city').send_keys('ocean', [:shift, :space, 'side'])
|
||||||
|
@ -27,7 +27,7 @@ RSpec.shared_examples 'Capybara::Node' do |session, _mode|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#visible?' do
|
describe '#visible?' do
|
||||||
let(:bridge) do
|
let(:bridge) do
|
||||||
session.driver.browser.send(:bridge)
|
session.driver.browser.send(:bridge)
|
||||||
end
|
end
|
||||||
|
|
|
@ -72,7 +72,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#fill_in_with empty string and no options' do
|
describe '#fill_in_with empty string and no options' do
|
||||||
it 'should trigger change when clearing a field' do
|
it 'should trigger change when clearing a field' do
|
||||||
pending "safaridriver doesn't trigger change for clear" if safari?(session)
|
pending "safaridriver doesn't trigger change for clear" if safari?(session)
|
||||||
session.visit('/with_js')
|
session.visit('/with_js')
|
||||||
|
@ -83,7 +83,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#fill_in with { :clear => :backspace } fill_option', requires: [:js] do
|
describe '#fill_in with { :clear => :backspace } fill_option', requires: [:js] do
|
||||||
before do
|
before do
|
||||||
# Firefox has an issue with change events if the main window doesn't think it's focused
|
# Firefox has an issue with change events if the main window doesn't think it's focused
|
||||||
session.execute_script('window.focus()')
|
session.execute_script('window.focus()')
|
||||||
|
@ -150,7 +150,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#fill_in with { clear: :none } fill_options' do
|
describe '#fill_in with { clear: :none } fill_options' do
|
||||||
it 'should append to content in a field' do
|
it 'should append to content in a field' do
|
||||||
pending 'Safari overwrites by default - need to figure out a workaround' if safari?(session)
|
pending 'Safari overwrites by default - need to figure out a workaround' if safari?(session)
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#fill_in with Date' do
|
describe '#fill_in with Date' do
|
||||||
before do
|
before do
|
||||||
session.visit('/form')
|
session.visit('/form')
|
||||||
session.find(:css, '#form_date').execute_script <<-JS
|
session.find(:css, '#form_date').execute_script <<-JS
|
||||||
|
@ -194,7 +194,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#fill_in with { clear: Array } fill_options' do
|
describe '#fill_in with { clear: Array } fill_options' do
|
||||||
it 'should pass the array through to the element' do
|
it 'should pass the array through to the element' do
|
||||||
# this is mainly for use with [[:control, 'a'], :backspace] - however since that is platform dependant I'm testing with something less useful
|
# this is mainly for use with [[:control, 'a'], :backspace] - however since that is platform dependant I'm testing with something less useful
|
||||||
session.visit('/form')
|
session.visit('/form')
|
||||||
|
|
Loading…
Reference in a new issue