mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Reorganize matcher proxies so JRuby is only checked once
This commit is contained in:
parent
057b552f5b
commit
1f2a028167
3 changed files with 52 additions and 63 deletions
|
@ -1,10 +1,6 @@
|
|||
# Version 3.10.0
|
||||
Release date: unreleased
|
||||
|
||||
### Fixed
|
||||
|
||||
* Workaround installation of rspec matcher proxies under jruby by reverting to the old solution not using prepend, so jruby bugs are not hit - Issue #2115
|
||||
|
||||
### Added
|
||||
|
||||
* :class filter can now check for class names starting with !
|
||||
|
@ -14,6 +10,7 @@ Release date: unreleased
|
|||
|
||||
* Selector `css` expression definiton declared filters now work again
|
||||
* Cleaned up warnings [Yuji Yaginuma]
|
||||
* Workaround installation of rspec matcher proxies under jruby by reverting to the old solution not using prepend, so jruby bugs are not hit - Issue #2115
|
||||
|
||||
# Version 3.9.0
|
||||
Release date: 2018-10-03
|
||||
|
|
|
@ -18,69 +18,61 @@ module Capybara
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
if RUBY_ENGINE == "jruby"
|
||||
module DSL
|
||||
class <<self
|
||||
remove_method :included
|
||||
|
||||
def included(base)
|
||||
warn "including Capybara::DSL in the global scope is not recommended!" if base == Object
|
||||
|
||||
if defined?(::RSpec::Matchers) && base.include?(::RSpec::Matchers)
|
||||
base.send(:include, ::Capybara::RSpecMatcherProxies)
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
module DSLRSpecProxyInstaller
|
||||
module ClassMethods
|
||||
def included(base)
|
||||
if defined?(::RSpec::Matchers)
|
||||
base.include(::Capybara::RSpecMatcherProxies) if base.include?(::RSpec::Matchers)
|
||||
end
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
class <<base
|
||||
prepend ClassMethods
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module RSpecMatcherProxyInstaller
|
||||
module ClassMethods
|
||||
def included(base)
|
||||
base.include(::Capybara::RSpecMatcherProxies) if base.include?(::Capybara::DSL)
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
class <<base
|
||||
prepend ClassMethods
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DSL.prepend ::Capybara::DSLRSpecProxyInstaller
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(::RSpec::Matchers)
|
||||
module ::RSpec::Matchers
|
||||
if RUBY_ENGINE == "jruby"
|
||||
if RUBY_ENGINE == 'jruby'
|
||||
module Capybara::DSL
|
||||
class <<self
|
||||
remove_method :included
|
||||
|
||||
def included(base)
|
||||
warn 'including Capybara::DSL in the global scope is not recommended!' if base == Object
|
||||
base.send(:include, ::Capybara::RSpecMatcherProxies) if defined?(::RSpec::Matchers) && base.include?(::RSpec::Matchers)
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(::RSpec::Matchers)
|
||||
module ::RSpec::Matchers
|
||||
def self.included(base)
|
||||
base.send(:include, ::Capybara::RSpecMatcherProxies) if base.include?(::Capybara::DSL)
|
||||
super
|
||||
end
|
||||
else
|
||||
prepend ::Capybara::RSpecMatcherProxyInstaller
|
||||
end
|
||||
end
|
||||
else
|
||||
module Capybara::DSLRSpecProxyInstaller
|
||||
module ClassMethods
|
||||
def included(base)
|
||||
base.include(::Capybara::RSpecMatcherProxies) if defined?(::RSpec::Matchers) && base.include?(::RSpec::Matchers)
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
class <<base
|
||||
prepend ClassMethods
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Capybara::RSpecMatcherProxyInstaller
|
||||
module ClassMethods
|
||||
def included(base)
|
||||
base.include(::Capybara::RSpecMatcherProxies) if base.include?(::Capybara::DSL)
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
class <<base
|
||||
prepend ClassMethods
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Capybara::DSL.prepend ::Capybara::DSLRSpecProxyInstaller
|
||||
|
||||
::RSpec::Matchers.prepend ::Capybara::RSpecMatcherProxyInstaller if defined?(::RSpec::Matchers)
|
||||
end
|
||||
|
|
|
@ -121,12 +121,12 @@ RSpec.describe 'capybara/rspec' do
|
|||
end
|
||||
end
|
||||
|
||||
it "can be called with `not_to`" do
|
||||
it 'can be called with `not_to`' do
|
||||
# This test is for a bug in jruby where `super` isn't defined correctly - https://github.com/jruby/jruby/issues/4678
|
||||
# Reported in https://github.com/teamcapybara/capybara/issues/2115
|
||||
@test_class_instance.instance_eval do
|
||||
expect do
|
||||
expect(true).not_to only_match_matcher(false)
|
||||
expect(true).not_to only_match_matcher(false) # rubocop:disable RSpec/ExpectActual
|
||||
end.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue