Use let instead of tap
This commit is contained in:
parent
b43fadc163
commit
cdd3184ae3
|
@ -67,86 +67,87 @@ Capybara::SpecHelper.spec "#all" do
|
|||
end
|
||||
end
|
||||
|
||||
{ :count => {
|
||||
:success => 4,
|
||||
:failure => 5
|
||||
}, :minimum => {
|
||||
:success => 0,
|
||||
:failure => 5
|
||||
}, :maximum => {
|
||||
:success => 4,
|
||||
:failure => 0
|
||||
}, :between => {
|
||||
:success => 2..7,
|
||||
:failure => 0..3
|
||||
}}.tap do |options|
|
||||
context 'with element count filters' do
|
||||
context ':count' do
|
||||
it 'should succeed when the number of elements founds matches the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :count => options[:count][:success]) }.to_not raise_error
|
||||
end
|
||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :count => options[:count][:failure]) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
end
|
||||
context ':minimum' do
|
||||
it 'should succeed when the number of elements founds matches the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :minimum => options[:minimum][:success]) }.to_not raise_error
|
||||
end
|
||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :minimum => options[:minimum][:failure]) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
end
|
||||
context ':maximum' do
|
||||
it 'should succeed when the number of elements founds matches the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :maximum => options[:maximum][:success]) }.to_not raise_error
|
||||
end
|
||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :maximum => options[:maximum][:failure]) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
end
|
||||
context ':between' do
|
||||
it 'should succeed when the number of elements founds matches the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :between => options[:between][:success]) }.to_not raise_error
|
||||
end
|
||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :between => options[:between][:failure]) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
end
|
||||
context 'with element count filters' do
|
||||
let(:options) {
|
||||
{ :count => {
|
||||
:success => 4,
|
||||
:failure => 5
|
||||
}, :minimum => {
|
||||
:success => 0,
|
||||
:failure => 5
|
||||
}, :maximum => {
|
||||
:success => 4,
|
||||
:failure => 0
|
||||
}, :between => {
|
||||
:success => 2..7,
|
||||
:failure => 0..3
|
||||
} } }
|
||||
|
||||
context 'with multiple count filters' do
|
||||
it 'ignores other filters when :count is specified' do
|
||||
o = {:count => options[:count][:success],
|
||||
:minimum => options[:minimum][:failure],
|
||||
:maximum => options[:maximum][:failure],
|
||||
:between => options[:between][:failure]}
|
||||
expect { @session.all(:css, 'h1, p', o) }.to_not raise_error
|
||||
context ':count' do
|
||||
it 'should succeed when the number of elements founds matches the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :count => options[:count][:success]) }.to_not raise_error
|
||||
end
|
||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :count => options[:count][:failure]) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
end
|
||||
context ':minimum' do
|
||||
it 'should succeed when the number of elements founds matches the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :minimum => options[:minimum][:success]) }.to_not raise_error
|
||||
end
|
||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :minimum => options[:minimum][:failure]) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
end
|
||||
context ':maximum' do
|
||||
it 'should succeed when the number of elements founds matches the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :maximum => options[:maximum][:success]) }.to_not raise_error
|
||||
end
|
||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :maximum => options[:maximum][:failure]) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
end
|
||||
context ':between' do
|
||||
it 'should succeed when the number of elements founds matches the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :between => options[:between][:success]) }.to_not raise_error
|
||||
end
|
||||
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
||||
expect { @session.all(:css, 'h1, p', :between => options[:between][:failure]) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with multiple count filters' do
|
||||
it 'ignores other filters when :count is specified' do
|
||||
o = {:count => options[:count][:success],
|
||||
:minimum => options[:minimum][:failure],
|
||||
:maximum => options[:maximum][:failure],
|
||||
:between => options[:between][:failure]}
|
||||
expect { @session.all(:css, 'h1, p', o) }.to_not raise_error
|
||||
end
|
||||
context 'with no :count expectation' do
|
||||
it 'fails if :minimum is not met' do
|
||||
o = {:minimum => options[:minimum][:failure],
|
||||
:maximum => options[:maximum][:success],
|
||||
:between => options[:between][:success]}
|
||||
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
context 'with no :count expectation' do
|
||||
it 'fails if :minimum is not met' do
|
||||
o = {:minimum => options[:minimum][:failure],
|
||||
:maximum => options[:maximum][:success],
|
||||
:between => options[:between][:success]}
|
||||
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
it 'fails if :maximum is not met' do
|
||||
o = {:minimum => options[:minimum][:success],
|
||||
:maximum => options[:maximum][:failure],
|
||||
:between => options[:between][:success]}
|
||||
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
it 'fails if :between is not met' do
|
||||
o = {:minimum => options[:minimum][:success],
|
||||
:maximum => options[:maximum][:success],
|
||||
:between => options[:between][:failure]}
|
||||
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
it 'succeeds if all combineable expectations are met' do
|
||||
o = {:minimum => options[:minimum][:success],
|
||||
:maximum => options[:maximum][:success],
|
||||
:between => options[:between][:success]}
|
||||
expect { @session.all(:css, 'h1, p', o) }.to_not raise_error
|
||||
end
|
||||
it 'fails if :maximum is not met' do
|
||||
o = {:minimum => options[:minimum][:success],
|
||||
:maximum => options[:maximum][:failure],
|
||||
:between => options[:between][:success]}
|
||||
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
it 'fails if :between is not met' do
|
||||
o = {:minimum => options[:minimum][:success],
|
||||
:maximum => options[:maximum][:success],
|
||||
:between => options[:between][:failure]}
|
||||
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
||||
end
|
||||
it 'succeeds if all combineable expectations are met' do
|
||||
o = {:minimum => options[:minimum][:success],
|
||||
:maximum => options[:maximum][:success],
|
||||
:between => options[:between][:success]}
|
||||
expect { @session.all(:css, 'h1, p', o) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue