1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

remove conditionals for no longer supported RSpec versions

This commit is contained in:
Thomas Walpole 2018-01-02 18:13:39 -08:00
parent b5e5fd308f
commit c7874b3f7f
5 changed files with 77 additions and 94 deletions

View file

@ -131,7 +131,6 @@ Capybara::SpecHelper.spec '#has_no_selector?' do
end
it "should accept a filter block" do
skip "RSpec < 3 doesn't pass the block along to the matcher for the Builtin::Has matcher" if rspec2?
expect(@session).to have_no_selector(:css, "a#foo") { |el| el[:id] != "foo" }
end

View file

@ -108,10 +108,6 @@ module Capybara
def marionette?(session)
session.driver.respond_to?(:marionette?, true) && session.driver.send(:marionette?)
end
def rspec2?
!defined?(::RSpec::Expectations::Version) || (Gem::Version.new(RSpec::Expectations::Version::STRING) < Gem::Version.new('3.0'))
end
end
end

View file

@ -834,97 +834,95 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
end
end
if RSpec::Version::STRING.to_f >= 3.0
context "compounding", requires: [:js] do
before(:each) do
@session = session
@session.visit('/with_js')
@el = @session.find(:css, '#reload-me')
context "compounding", requires: [:js] do
before(:each) do
@session = session
@session.visit('/with_js')
@el = @session.find(:css, '#reload-me')
end
context "#and" do
it "should run 'concurrently'" do
Capybara.using_wait_time(2) do
matcher = have_text('this is not there').and have_text('neither is this')
expect(Benchmark.realtime do
expect {
expect(@el).to matcher
}.to raise_error RSpec::Expectations::ExpectationNotMetError
end).to be_between(2,3)
end
end
context "#and" do
it "should run 'concurrently'" do
Capybara.using_wait_time(2) do
matcher = have_text('this is not there').and have_text('neither is this')
expect(Benchmark.realtime do
expect {
expect(@el).to matcher
}.to raise_error RSpec::Expectations::ExpectationNotMetError
end).to be_between(2,3)
end
it "should run 'concurrently' and retry" do
@session.click_link('reload-link')
@session.using_wait_time(2) do
expect(Benchmark.realtime do
expect {
expect(@el).to have_text('waiting to be reloaded').and(have_text('has been reloaded'))
}.to raise_error RSpec::Expectations::ExpectationNotMetError, /expected to find text "waiting to be reloaded" in "has been reloaded"/
end).to be_between(2,3)
end
end
it "should run 'concurrently' and retry" do
it "should ignore :wait options" do
@session.using_wait_time(2) do
matcher = have_text('this is not there', wait: 5).and have_text('neither is this', wait: 6)
expect(Benchmark.realtime do
expect {
expect(@el).to matcher
}.to raise_error RSpec::Expectations::ExpectationNotMetError
end).to be_between(2,3)
end
end
it "should work on the session" do
@session.using_wait_time(2) do
@session.click_link('reload-link')
@session.using_wait_time(2) do
expect(Benchmark.realtime do
expect {
expect(@el).to have_text('waiting to be reloaded').and(have_text('has been reloaded'))
}.to raise_error RSpec::Expectations::ExpectationNotMetError, /expected to find text "waiting to be reloaded" in "has been reloaded"/
end).to be_between(2,3)
end
expect(@session).to have_selector(:css, 'h1', text: 'FooBar').and have_text('has been reloaded')
end
end
end
it "should ignore :wait options" do
@session.using_wait_time(2) do
matcher = have_text('this is not there', wait: 5).and have_text('neither is this', wait: 6)
expect(Benchmark.realtime do
expect {
expect(@el).to matcher
}.to raise_error RSpec::Expectations::ExpectationNotMetError
end).to be_between(2,3)
end
end
context "#and_then" do
it "should run sequentially" do
@session.click_link('reload-link')
expect(@el).to have_text('waiting to be reloaded').and_then have_text('has been reloaded')
end
end
it "should work on the session" do
@session.using_wait_time(2) do
@session.click_link('reload-link')
expect(@session).to have_selector(:css, 'h1', text: 'FooBar').and have_text('has been reloaded')
end
context "#or" do
it "should run 'concurrently'" do
@session.using_wait_time(3) do
expect(Benchmark.realtime do
expect(@el).to have_text('has been reloaded').or have_text('waiting to be reloaded')
end).to be < 1
end
end
context "#and_then" do
it "should run sequentially" do
it "should retry" do
@session.using_wait_time(3) do
expect(Benchmark.realtime do
expect {
expect(@el).to have_text('has been reloaded').or have_text('random stuff')
}.to raise_error RSpec::Expectations::ExpectationNotMetError
end).to be > 3
end
end
it "should ignore :wait options" do
@session.using_wait_time(2) do
expect(Benchmark.realtime do
expect {
expect(@el).to have_text('this is not there', wait: 10).or have_text('neither is this', wait: 15)
}.to raise_error RSpec::Expectations::ExpectationNotMetError
end).to be_between(2,3)
end
end
it "should work on the session" do
@session.using_wait_time(2) do
@session.click_link('reload-link')
expect(@el).to have_text('waiting to be reloaded').and_then have_text('has been reloaded')
end
end
context "#or" do
it "should run 'concurrently'" do
@session.using_wait_time(3) do
expect(Benchmark.realtime do
expect(@el).to have_text('has been reloaded').or have_text('waiting to be reloaded')
end).to be < 1
end
end
it "should retry" do
@session.using_wait_time(3) do
expect(Benchmark.realtime do
expect {
expect(@el).to have_text('has been reloaded').or have_text('random stuff')
}.to raise_error RSpec::Expectations::ExpectationNotMetError
end).to be > 3
end
end
it "should ignore :wait options" do
@session.using_wait_time(2) do
expect(Benchmark.realtime do
expect {
expect(@el).to have_text('this is not there', wait: 10).or have_text('neither is this', wait: 15)
}.to raise_error RSpec::Expectations::ExpectationNotMetError
end).to be_between(2,3)
end
end
it "should work on the session" do
@session.using_wait_time(2) do
@session.click_link('reload-link')
expect(@session).to have_selector(:css, 'h1', text: 'Not on the page').or have_text('has been reloaded')
end
expect(@session).to have_selector(:css, 'h1', text: 'Not on the page').or have_text('has been reloaded')
end
end
end

View file

@ -48,8 +48,6 @@ RSpec.describe 'capybara/rspec', :type => :feature do
end
it "allows access to the RSpec matcher" do
skip "RSpec < 3 doesn't have an `all` matcher" if rspec2?
visit('/with_html')
expect(["test1", "test2"]).to all(be_a(String))
end
@ -64,7 +62,6 @@ RSpec.describe 'capybara/rspec', :type => :feature do
end
it "allows access to the RSpec matcher" do
skip "RSpec version doesn't have a 'within' matcher" unless ::RSpec::Matchers.instance_methods.include?(:within)
visit('/with_html')
# This reads terribly, but must call #within
expect(find(:css, 'span.number').text.to_i).to within(1).of(41)
@ -90,8 +87,6 @@ RSpec.describe 'capybara/rspec', :type => :other do
end
it "allows access to the RSpec matcher" do
skip "RSpec < 3 doesn't have an `all` matcher" if rspec2?
@test_class_instance.visit('/with_html')
expect(["test1", "test2"]).to @test_class_instance.all(be_a(String))
end
@ -106,7 +101,6 @@ RSpec.describe 'capybara/rspec', :type => :other do
end
it "allows access to the RSpec matcher" do
skip "RSpec version doesn't have a 'within' matcher" unless ::RSpec::Matchers.instance_methods.include?(:within)
@test_class_instance.visit('/with_html')
# This reads terribly, but must call #within
expect(@test_class_instance.find(:css, 'span.number').text.to_i).to @test_class_instance.within(1).of(41)

View file

@ -7,7 +7,3 @@ RSpec.configure do |config|
config.filter_run_including focus_: true unless ENV['TRAVIS']
config.run_all_when_everything_filtered = true
end
def rspec2?
!defined?(::RSpec::Expectations::Version) || (Gem::Version.new(RSpec::Expectations::Version::STRING) < Gem::Version.new('3.0'))
end