mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
remove conditionals for no longer supported versions of gems/rubies
This commit is contained in:
parent
b3685183d2
commit
05945bf2d9
15 changed files with 78 additions and 159 deletions
19
.travis.yml
19
.travis.yml
|
@ -36,25 +36,6 @@ matrix:
|
|||
- gemfile: Gemfile
|
||||
rvm: 2.4.3
|
||||
env: HEADLESS=true
|
||||
- gemfile: gemfiles/Gemfile.ruby-20
|
||||
env:
|
||||
- CAPYBARA_LEGACY_FF=true
|
||||
rvm: 2.0.0
|
||||
addons:
|
||||
firefox: 47.0.1
|
||||
apt:
|
||||
packages:
|
||||
- awesome
|
||||
- gemfile: gemfiles/Gemfile.base-versions
|
||||
env:
|
||||
- CAPYBARA_LEGACY_FF=true
|
||||
- SKIP_WINDOW=true
|
||||
rvm: 1.9.3
|
||||
addons:
|
||||
firefox: 47.0.1
|
||||
apt:
|
||||
packages:
|
||||
- awesome
|
||||
- gemfile: gemfiles/Gemfile.beta-versions
|
||||
rvm: 2.5.0
|
||||
env: CAPYBARA_FF=true
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# Version 3.0.0
|
||||
Release date: unreleased
|
||||
|
||||
# Version 2.17.0
|
||||
Release date: 2018-01-02
|
||||
|
||||
|
|
|
@ -71,15 +71,13 @@ GitHub): http://groups.google.com/group/ruby-capybara
|
|||
|
||||
## <a name="setup"></a>Setup
|
||||
|
||||
Capybara requires Ruby 1.9.3 or later. To install, add this line to your
|
||||
Capybara requires Ruby 2.0.0 or later. To install, add this line to your
|
||||
`Gemfile` and run `bundle install`:
|
||||
|
||||
```ruby
|
||||
gem 'capybara'
|
||||
```
|
||||
|
||||
**Note:** If using Ruby < 2.0 you will also need to limit the version of rack to < 2.0
|
||||
|
||||
If the application that you are testing is a Rails app, add this line to your test helper file:
|
||||
|
||||
```ruby
|
||||
|
|
|
@ -7,7 +7,7 @@ require 'capybara/version'
|
|||
Gem::Specification.new do |s|
|
||||
s.name = "capybara"
|
||||
s.version = Capybara::VERSION
|
||||
s.required_ruby_version = ">= 1.9.3"
|
||||
s.required_ruby_version = ">= 2.0.0"
|
||||
s.license = "MIT"
|
||||
|
||||
s.authors = ["Thomas Walpole", "Jonas Nicklas"]
|
||||
|
@ -21,24 +21,22 @@ Gem::Specification.new do |s|
|
|||
s.rubygems_version = "1.3.6"
|
||||
s.summary = "Capybara aims to simplify the process of integration testing Rack applications, such as Rails, Sinatra or Merb"
|
||||
|
||||
s.add_runtime_dependency("nokogiri", [">= 1.3.3"])
|
||||
s.add_runtime_dependency("mini_mime", [">= 0.1.3"])
|
||||
s.add_runtime_dependency("rack", [">= 1.0.0"])
|
||||
s.add_runtime_dependency("rack-test", [">= 0.5.4"])
|
||||
s.add_runtime_dependency("nokogiri", [">= 1.6.7"])
|
||||
s.add_runtime_dependency("mime-types", [">= 3.0"])
|
||||
s.add_runtime_dependency("rack", [">= 1.6.0"])
|
||||
s.add_runtime_dependency("rack-test", [">= 0.6.3"])
|
||||
s.add_runtime_dependency("xpath", [">= 2.0", "< 4.0"])
|
||||
s.add_runtime_dependency("addressable")
|
||||
|
||||
s.add_development_dependency("selenium-webdriver", [">= 2.0", "< 4.0", "!=3.4.1"])
|
||||
s.add_development_dependency("sinatra", [">= 0.9.4"])
|
||||
s.add_development_dependency("rspec", [">= 2.2.0"])
|
||||
s.add_development_dependency("selenium-webdriver", [">= 3.0", "< 4.0", "!=3.4.1"])
|
||||
s.add_development_dependency("sinatra", [">= 1.4.0"])
|
||||
s.add_development_dependency("rspec", [">= 3.4.0"])
|
||||
s.add_development_dependency("launchy", [">= 2.0.4"])
|
||||
s.add_development_dependency("yard", [">= 0.5.8"])
|
||||
s.add_development_dependency("fuubar", [">= 0.0.1"])
|
||||
s.add_development_dependency("cucumber", [">= 0.10.5"])
|
||||
s.add_development_dependency("minitest")
|
||||
s.add_development_dependency("cucumber", [">= 2.3.0"])
|
||||
s.add_development_dependency("rake")
|
||||
s.add_development_dependency("puma")
|
||||
s.add_development_dependency("pry")
|
||||
s.add_development_dependency("erubi") # dependency specification needed by rbx
|
||||
|
||||
if RUBY_ENGINE == 'rbx' then
|
||||
|
|
|
@ -5,13 +5,13 @@ gemspec :path => '..'
|
|||
|
||||
gem 'xpath', '~> 2.1.0'
|
||||
|
||||
gem 'rack', '= 1.3.0' # cannot go lower because referer tests need aa7ce77cd0
|
||||
gem 'rack-test', '= 0.5.4'
|
||||
gem 'nokogiri', '= 1.3.3'
|
||||
gem 'rspec', '= 2.2.0'
|
||||
gem 'cucumber', '= 0.10.5'
|
||||
gem 'tins', '= 1.6.0' # 1.7.0 requires ruby 2.0
|
||||
gem 'addressable', '< 2.4.0' # 2.4.0 allows require 'addressable' previous don't
|
||||
gem 'rack', '~> 1.6.0'
|
||||
gem 'rack-test', '= 0.6.3'
|
||||
gem 'nokogiri', '= 1.6.7'
|
||||
gem 'rspec', '= 3.4.0'
|
||||
gem 'cucumber', '= 2.3.0'
|
||||
gem 'mime-types', '= 3.0'
|
||||
gem 'addressable', '2.4.0'
|
||||
gem 'json', '< 2.0'
|
||||
gem 'rake', '< 11.0'
|
||||
|
||||
|
|
|
@ -3,12 +3,7 @@ require 'capybara/dsl'
|
|||
|
||||
Capybara.app = Rack::Builder.new do
|
||||
map "/" do
|
||||
if Gem::Version.new(Rails.version) >= Gem::Version.new("3.0")
|
||||
run Rails.application
|
||||
else # Rails 2
|
||||
use Rails::Rack::Static
|
||||
run ActionController::Dispatcher.new
|
||||
end
|
||||
run Rails.application
|
||||
end
|
||||
end.to_app
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ module Capybara
|
|||
def initialize(elements, query)
|
||||
@elements = elements
|
||||
@result_cache = []
|
||||
@results_enum = lazy_select_elements { |node| query.matches_filters?(node) }
|
||||
@results_enum = @elements.lazy_select_elements { |node| query.matches_filters?(node) }
|
||||
@query = query
|
||||
end
|
||||
|
||||
|
@ -138,14 +138,8 @@ module Capybara
|
|||
# https://github.com/jruby/jruby/issues/4212
|
||||
if RUBY_PLATFORM == 'java'
|
||||
@elements.select(&block).to_enum # non-lazy evaluation
|
||||
elsif @elements.respond_to? :lazy #Ruby 2.0+
|
||||
@elements.lazy.select(&block)
|
||||
else
|
||||
Enumerator.new do |yielder|
|
||||
@elements.each do |val|
|
||||
yielder.yield(val) if block.call(val)
|
||||
end
|
||||
end
|
||||
@elements.lazy.select(&block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,56 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
if RSpec::Core::Version::STRING.to_f >= 3.0
|
||||
RSpec.shared_context "Capybara Features", capybara_feature: true do
|
||||
instance_eval do
|
||||
alias background before
|
||||
alias given let
|
||||
alias given! let!
|
||||
end
|
||||
end
|
||||
|
||||
# ensure shared_context is included if default shared_context_metadata_behavior is changed
|
||||
if RSpec::Core::Version::STRING.to_f >= 3.5
|
||||
RSpec.configure do |config|
|
||||
config.include_context "Capybara Features", capybara_feature: true
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.alias_example_group_to :feature, capybara_feature: true, type: :feature
|
||||
config.alias_example_group_to :xfeature, capybara_feature: true, type: :feature, skip: "Temporarily disabled with xfeature"
|
||||
config.alias_example_group_to :ffeature, capybara_feature: true, type: :feature, focus: true
|
||||
config.alias_example_to :scenario
|
||||
config.alias_example_to :xscenario, skip: "Temporarily disabled with xscenario"
|
||||
config.alias_example_to :fscenario, focus: true
|
||||
end
|
||||
else
|
||||
module Capybara
|
||||
module Features
|
||||
def self.included(base)
|
||||
base.instance_eval do
|
||||
alias :background :before
|
||||
alias :scenario :it
|
||||
alias :xscenario :xit
|
||||
alias :given :let
|
||||
alias :given! :let!
|
||||
alias :feature :describe
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.feature(*args, &block)
|
||||
options = if args.last.is_a?(Hash) then args.pop else {} end
|
||||
options[:capybara_feature] = true
|
||||
options[:type] = :feature
|
||||
options[:caller] ||= caller
|
||||
args.push(options)
|
||||
|
||||
#call describe on RSpec in case user has expose_dsl_globally set to false
|
||||
RSpec.describe(*args, &block)
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include(Capybara::Features, capybara_feature: true)
|
||||
RSpec.shared_context "Capybara Features", capybara_feature: true do
|
||||
instance_eval do
|
||||
alias background before
|
||||
alias given let
|
||||
alias given! let!
|
||||
end
|
||||
end
|
||||
|
||||
# ensure shared_context is included if default shared_context_metadata_behavior is changed
|
||||
if RSpec::Core::Version::STRING.to_f >= 3.5
|
||||
RSpec.configure do |config|
|
||||
config.include_context "Capybara Features", capybara_feature: true
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.alias_example_group_to :feature, capybara_feature: true, type: :feature
|
||||
config.alias_example_group_to :xfeature, capybara_feature: true, type: :feature, skip: "Temporarily disabled with xfeature"
|
||||
config.alias_example_group_to :ffeature, capybara_feature: true, type: :feature, focus: true
|
||||
config.alias_example_to :scenario
|
||||
config.alias_example_to :xscenario, skip: "Temporarily disabled with xscenario"
|
||||
config.alias_example_to :fscenario, focus: true
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
module Capybara
|
||||
module RSpecMatchers
|
||||
class Matcher
|
||||
if defined?(::RSpec::Expectations::Version) && (Gem::Version.new(RSpec::Expectations::Version::STRING) >= Gem::Version.new('3.0'))
|
||||
if defined?(::RSpec::Expectations::Version)
|
||||
require 'capybara/rspec/compound'
|
||||
include ::Capybara::RSpecMatchers::Compound
|
||||
end
|
||||
|
@ -265,9 +265,8 @@ module Capybara
|
|||
def match_selector(*args, &optional_filter_block)
|
||||
MatchSelector.new(*args, &optional_filter_block)
|
||||
end
|
||||
# defined_negated_matcher was added in RSpec 3.1 - it's syntactic sugar only since a user can do
|
||||
# expect(page).not_to match_selector, so not sure we really need to support not_match_selector for prior to RSpec 3.1
|
||||
::RSpec::Matchers.define_negated_matcher :not_match_selector, :match_selector if defined?(::RSpec::Expectations::Version) && (Gem::Version.new(RSpec::Expectations::Version::STRING) >= Gem::Version.new('3.1'))
|
||||
|
||||
::RSpec::Matchers.define_negated_matcher :not_match_selector, :match_selector
|
||||
|
||||
|
||||
# RSpec matcher for whether elements(s) matching a given xpath selector exist
|
||||
|
|
|
@ -103,4 +103,4 @@ Capybara::SpecHelper.spec '#not_matches_selector?' do
|
|||
expect(@element.not_matches_xpath?("//span", text: "42")).to be false
|
||||
expect(@element.not_matches_xpath?("//span", text: "Doesnotexist")).to be true
|
||||
end
|
||||
end if Gem::Version.new(RSpec::Expectations::Version::STRING) >= Gem::Version.new('3.1')
|
||||
end
|
||||
|
|
|
@ -102,26 +102,14 @@ Capybara::SpecHelper.spec "node" do
|
|||
expect(@session.first('//input').value).to eq('')
|
||||
end
|
||||
|
||||
it "should not set if the text field is readonly" do
|
||||
expect(@session.first('//input[@readonly]').value).to eq('should not change')
|
||||
@session.first('//input[@readonly]').set('changed')
|
||||
expect(@session.first('//input[@readonly]').value).to eq('should not change')
|
||||
it "should raise if the text field is readonly" do
|
||||
expect { @session.first('//input[@readonly]').set('changed') }.to raise_error(Capybara::ReadOnlyElementError)
|
||||
end
|
||||
|
||||
it "should raise if the text field is readonly" do
|
||||
expect(@session.first('//input[@readonly]').set('changed')).to raise_error(Capybara::ReadOnlyElementError)
|
||||
end if Capybara::VERSION.to_f > 3.0
|
||||
|
||||
it "should not set if the textarea is readonly" do
|
||||
expect(@session.first('//textarea[@readonly]').value).to eq('textarea should not change')
|
||||
@session.first('//textarea[@readonly]').set('changed')
|
||||
expect(@session.first('//textarea[@readonly]').value).to eq('textarea should not change')
|
||||
expect { @session.first('//textarea[@readonly]').set('changed') }.to raise_error(Capybara::ReadOnlyElementError)
|
||||
end
|
||||
|
||||
it "should raise if the text field is readonly" do
|
||||
expect(@session.first('//textarea[@readonly]').set('changed')).to raise_error(Capybara::ReadOnlyElementError)
|
||||
end if Capybara::VERSION.to_f > 3.0
|
||||
|
||||
context "with a contenteditable element", requires: [:js] do
|
||||
it 'should allow me to change the contents' do
|
||||
@session.visit('/with_js')
|
||||
|
|
|
@ -77,19 +77,17 @@ feature "Capybara's feature DSL with driver", :driver => :culerity do
|
|||
end
|
||||
end
|
||||
|
||||
if RSpec::Core::Version::STRING.to_f >= 3.0
|
||||
xfeature "if xfeature aliases to pending then" do
|
||||
scenario "this should be 'temporarily disabled with xfeature'" do; end
|
||||
scenario "this also should be 'temporarily disabled with xfeature'" do; end
|
||||
xfeature "if xfeature aliases to pending then" do
|
||||
scenario "this should be 'temporarily disabled with xfeature'" do; end
|
||||
scenario "this also should be 'temporarily disabled with xfeature'" do; end
|
||||
end
|
||||
|
||||
ffeature "if ffeature aliases focused tag then" do
|
||||
scenario "scenario inside this feature has metatag focus tag" do |example|
|
||||
expect(example.metadata[:focus]).to eq true
|
||||
end
|
||||
|
||||
ffeature "if ffeature aliases focused tag then" do
|
||||
scenario "scenario inside this feature has metatag focus tag" do |example|
|
||||
expect(example.metadata[:focus]).to eq true
|
||||
end
|
||||
|
||||
scenario "other scenarios also has metatag focus tag " do |example|
|
||||
expect(example.metadata[:focus]).to eq true
|
||||
end
|
||||
scenario "other scenarios also has metatag focus tag " do |example|
|
||||
expect(example.metadata[:focus]).to eq true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,11 +6,9 @@ RSpec.configuration.before(:each, { file_path: "./spec/rspec/scenarios_spec.rb"
|
|||
@in_filtered_hook = true
|
||||
end
|
||||
|
||||
if RSpec::Core::Version::STRING.to_f >= 3.0
|
||||
feature "if fscenario aliases focused tag then" do
|
||||
fscenario "scenario should have focused meta tag" do |example|
|
||||
expect(example.metadata[:focus]).to eq true
|
||||
end
|
||||
feature "if fscenario aliases focused tag then" do
|
||||
fscenario "scenario should have focused meta tag" do |example|
|
||||
expect(example.metadata[:focus]).to eq true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
it "supports compounding" do
|
||||
expect("<h1>Text</h1><h2>Text</h2>").to have_css('h1').and have_css('h2')
|
||||
expect("<h1>Text</h1><h2>Text</h2>").to have_css('h3').or have_css('h1')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
context "on a page or node" do
|
||||
|
@ -148,7 +148,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
it "supports compounding" do
|
||||
expect("<h1>Text</h1><h2>Text</h2>").to have_xpath('//h1').and have_xpath('//h2')
|
||||
expect("<h1>Text</h1><h2>Text</h2>").to have_xpath('//h3').or have_xpath('//h1')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
context "on a page or node" do
|
||||
|
@ -254,7 +254,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
it "supports compounding" do
|
||||
expect("<h1>Text</h1><h2>Text</h2>").to have_selector('//h1').and have_selector('//h2')
|
||||
expect("<h1>Text</h1><h2>Text</h2>").to have_selector('//h3').or have_selector('//h1')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
describe "have_content matcher" do
|
||||
|
@ -343,7 +343,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
it "supports compounding" do
|
||||
expect("<h1>Text</h1><h2>And</h2>").to have_content('Text').and have_content('And')
|
||||
expect("<h1>Text</h1><h2>Or</h2>").to have_content('XYZ').or have_content('Or')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
describe "have_text matcher" do
|
||||
|
@ -477,7 +477,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
it "supports compounding" do
|
||||
expect("<h1>Text</h1><h2>And</h2>").to have_text('Text').and have_text('And')
|
||||
expect("<h1>Text</h1><h2>Or</h2>").to have_text('Not here').or have_text('Or')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
describe "have_link matcher" do
|
||||
|
@ -500,7 +500,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
it "supports compounding" do
|
||||
expect(html).to have_link('Just a link').and have_link('Another link')
|
||||
expect(html).to have_link('Not a link').or have_link('Another link')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
describe "have_title matcher" do
|
||||
|
@ -565,7 +565,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
|
||||
it "supports compounding" do
|
||||
expect("<title>I compound</title>").to have_title('I dont compound').or have_title('I compound')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
describe "have_current_path matcher" do
|
||||
|
@ -611,7 +611,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
it "supports compounding" do
|
||||
visit('/with_html')
|
||||
expect(page).to have_current_path('/not_with_html').or have_current_path('/with_html')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
describe "have_button matcher" do
|
||||
|
@ -633,7 +633,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
|
||||
it "supports compounding" do
|
||||
expect(html).to have_button('Not this button').or have_button('A button')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
describe "have_field matcher" do
|
||||
|
@ -678,7 +678,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
|
||||
it "supports compounding" do
|
||||
expect(html).to have_field('Not this one').or have_field('Text field')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
describe "have_checked_field matcher" do
|
||||
|
@ -727,7 +727,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
|
||||
it "supports compounding" do
|
||||
expect(html).to have_checked_field('not this one').or have_checked_field('it is checked')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
describe "have_unchecked_field matcher" do
|
||||
|
@ -776,7 +776,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
|
||||
it "supports compounding" do
|
||||
expect(html).to have_unchecked_field('it is checked').or have_unchecked_field('unchecked field')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
describe "have_select matcher" do
|
||||
|
@ -802,7 +802,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
|
||||
it "supports compounding" do
|
||||
expect(html).to have_select('Not this one').or have_select('Select Box')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
describe "have_table matcher" do
|
||||
|
@ -831,7 +831,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|||
|
||||
it "supports compounding" do
|
||||
expect(html).to have_table('nope').or have_table('Lovely table')
|
||||
end if RSpec::Version::STRING.to_f >= 3.0
|
||||
end
|
||||
end
|
||||
|
||||
if RSpec::Version::STRING.to_f >= 3.0
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
require 'rspec/expectations'
|
||||
require "capybara/spec/spec_helper"
|
||||
require "pry"
|
||||
|
||||
RSpec.configure do |config|
|
||||
Capybara::SpecHelper.configure(config)
|
||||
|
|
Loading…
Add table
Reference in a new issue