site_prism 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de1db2cfa8b40510768bbea0bee96e548ae949149428d669e1a038c83e2b7f8d
4
- data.tar.gz: 3862848b777a9fbafb8c1640df914313b6deac6da942a3859ff2dfe6dbafb214
3
+ metadata.gz: 6702577fd95053cdaaa208fd2ee9434e3b6634cf7f20da087fa6d7d858c952cc
4
+ data.tar.gz: 8832e3b57c435d0e715e92c8c179781dc865ec98942518cb3cd982ecd845ca22
5
5
  SHA512:
6
- metadata.gz: 8deff2edc00b2b4c0fab86c96e10bc184ed2afc8276b7daf9f69b97a9f7ab4b105ece138f6901456d76e57d508f546971f0262e6cec90787e64ea89bac904047
7
- data.tar.gz: 505eb15872469490ab314497737e04eda896f14e7b98c631efae658d42eedb09d8a8aefa53fd5d845fa0a11936951aaf5cd9e6bc99563b4f454251eb212126d9
6
+ metadata.gz: d2607bc319b31ad2621e4b65d97680d24762d134f0ce0afa7a193e7e0d7021dfdc675f903d7b5b18f389f85dc30537d178a45dccdab3611b79c04c946dc9bca8
7
+ data.tar.gz: 5c2e419d8b490bb10a1afb0bb0673f8dbe4124786fcd7bc17d5ff8d6c90001da8e163a27ca6212158cb28d042043d0b5af1ad9750144c8891bdb89fe41f46bdf
@@ -22,17 +22,30 @@ module SitePrism
22
22
  private
23
23
 
24
24
  def create_rspec_existence_matchers(matcher, object_method, negated_object_method, warning)
25
- RSpec::Matchers.define(matcher) do |*args|
26
- match { |actual| actual.public_send(object_method, *args) }
25
+ forward = forwarder(object_method)
26
+
27
+ RSpec::Matchers.define(matcher) do |*args, **options|
28
+ match { |actual| forward.call(actual, args, options) }
27
29
  match_when_negated do |actual|
28
- return actual.public_send(negated_object_method, *args) if actual.respond_to?(negated_object_method)
30
+ return forward.call(actual, args, options, negated_object_method) if actual.respond_to?(negated_object_method)
29
31
 
30
32
  SitePrism.logger.debug(warning)
31
- !actual.public_send(object_method, *args)
33
+ !forward.call(actual, args, options)
32
34
  end
33
35
  end
34
36
  end
35
37
 
38
+ def forwarder(object_method)
39
+ lambda do |actual, args, options, method_name = object_method|
40
+ # To support Ruby 2.6. Otherwise methods that expect no arguments would fail with
41
+ # "wrong number of arguments (given 1, expected 0)" because Ruby 2.6 considers `method(**{})` the
42
+ # same as `method({})` (passing the empty Hash as an argument)
43
+ next actual.public_send(method_name, *args) if options.empty?
44
+
45
+ actual.public_send(method_name, *args, **options)
46
+ end
47
+ end
48
+
36
49
  def matcher
37
50
  "have_#{element_name}"
38
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SitePrism
4
- VERSION = '4.0.1'
4
+ VERSION = '4.0.2'
5
5
  end
data/lib/site_prism.rb CHANGED
@@ -4,6 +4,7 @@ require 'site_prism/error'
4
4
  require 'site_prism/all_there'
5
5
 
6
6
  require 'addressable/template'
7
+ require 'capybara/dsl'
7
8
  require 'forwardable'
8
9
 
9
10
  require 'site_prism/addressable_url_matcher'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site_prism
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Hill
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-05-11 00:00:00.000000000 Z
12
+ date: 2023-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable