duck_typer 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fa69aacb39291c263a7cd2d09e094ee7cf18e62f90b1148e5747f5515107c8c
4
- data.tar.gz: dec6c2a99167fe5cdcc06e2a6d9b2a0e9c42b1898969d0637c717f7122875184
3
+ metadata.gz: c357093ac549ba934b47e7923d236062457e52b494588adb8a2fdef41dc3b0a9
4
+ data.tar.gz: f900f3ad9409f4a8f0707b30aa88fd34ad6f330437e84fd6b3e8560d36edaaef
5
5
  SHA512:
6
- metadata.gz: 94070439840328f9faac3275ad69b57230981bcac9369aff4b26ee93b87cdf127e74848b7d44d4aed78bd5f37f6308ba19ec9c97a1264c86f5809db920897361
7
- data.tar.gz: 7007b8b442e0ac7528a8aed5646d03e2e5a5256e1eb5a79a6dc20c665de1f8a9df52a29d11ab25ddc6857da9b9211f1d218ad0ab9bc2b697ef00ff475d6ddc2c
6
+ metadata.gz: 86a751c5a4a61ef768bee2aa753c6c16e6e3b9e58860c2ed3ed71c0bf1dd5cf3668c3b4258caa59dc588d5b15964481cf10bdc3913da6654327654a198321de4
7
+ data.tar.gz: c8a249693663d8a70cfb7af3aa8fa58d422ed19bea2626586ad6c93a6dd8ec9c99c86823cc8084c923e2922c7cd51e73413333844469bfdbe57d19b879fedc10
data/README.md CHANGED
@@ -107,14 +107,24 @@ def test_payment_processors_have_compatible_interfaces
107
107
  end
108
108
  ```
109
109
 
110
- The same `type:` and `methods:` options are supported:
110
+ By default, DuckTyper checks instance method interfaces. To check
111
+ class-level interfaces instead, pass `type: :class_methods`:
112
+
113
+ ```ruby
114
+ assert_interfaces_match [StripeProcessor, PaypalProcessor],
115
+ type: :class_methods
116
+ ```
117
+
118
+ To check only a subset of methods (partial interface), use `methods:`:
111
119
 
112
120
  ```ruby
113
121
  assert_interfaces_match [StripeProcessor, PaypalProcessor],
114
- type: :class_methods,
115
122
  methods: %i[charge refund]
116
123
  ```
117
124
 
125
+ This is useful if your class implements multiple interfaces, in
126
+ which case you can write an assertion for each.
127
+
118
128
  ### RSpec
119
129
 
120
130
  Require the RSpec integration in your `spec_helper.rb`:
@@ -11,7 +11,7 @@ module DuckTyper
11
11
  def call(&block)
12
12
  @objects.each_cons(2).map do |left, right|
13
13
  result = @checker.call(left, right)
14
- block&.call(left, right, result)
14
+ block&.call(result)
15
15
  result
16
16
  end
17
17
  end
@@ -8,7 +8,7 @@ module DuckTyper
8
8
  checker = BulkInterfaceChecker
9
9
  .new(objects, type:, partial_interface_methods: methods)
10
10
 
11
- checker.call do |_, _, result|
11
+ checker.call do |result|
12
12
  assert result.match?, result.failure_message
13
13
  end
14
14
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DuckTyper
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duck_typer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago A. Silva