grift 2.0.0 → 2.0.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: 62cac26275a4af88278a38985c4edc2e3d001954fe68e491e242add325e49576
4
- data.tar.gz: 03ddad7645f758c5708e353e8780001cfd4ce7b478cee2a4c5d60ae7a180cb80
3
+ metadata.gz: '06800e91cb7e76be9232c7cf700d99ede4ba25212ed323abd1d5a4e944de455d'
4
+ data.tar.gz: 2d844fc80a5edcb9eb809c4946d7ee464465e8423b7a42e2f3a4ff4657e791d7
5
5
  SHA512:
6
- metadata.gz: 8df483db6759b17e6c8d7d6f05a81ed3b507b4be7d9a3d5b0f0adaa70bc8fec798d8d3e750d6f512a586e128ca0f492288d5b32a6e772a8ca6e2a67903116f41
7
- data.tar.gz: c6460882f099ec2622fe92b99882e52b54df86c5aaf86311f86104326a94455235890ca5cc161448f8b7d5ab60d6853c1d65287764b8516eeebb5fd53ba3c8e3
6
+ metadata.gz: c3a2e6a02bab0921a5c91c48c5fbbf67d1a9dd0b0d50bd3c4d9dfb49d6f686623ca0c017d1d51f1df3220b4c1c83c1fd9a26070daa05c36c38d657a2476a4602
7
+ data.tar.gz: a7197e5fb4f7bbaf506426c9f4ed2a04733201f8a27a4f015df9af7466c9bd8563e700c2adaaef34211690c5ecf795ded15308701877bd5a0fbb6ed5278b366a
data/CHANGELOG.md CHANGED
@@ -8,8 +8,17 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
8
8
 
9
9
  None
10
10
 
11
+ ## [2.0.1](https://github.com/clarkedb/grift/releases/tag/v2.0.1) - 2022-03-27
12
+
13
+ ### Fixed
14
+
15
+ * When spying on a method that takes a block, the block now gets forwarded to the original method ([#78](https://github.com/clarkedb/grift/pull/78))
16
+ * When mocking the implementation, if a block is not provided a `Grift::Error` is raised instead of a `LocalJumpError` ([#77](https://github.com/clarkedb/grift/pull/77))
17
+
11
18
  ## [2.0.0](https://github.com/clarkedb/grift/releases/tag/v2.0.0) - 2022-03-14
12
19
 
20
+ This version adds true keyword argument support for Ruby 3. See below for how to handle breaking changes.
21
+
13
22
  ### Changed
14
23
 
15
24
  * Dropped support for Ruby 2.5 ([#69](https://github.com/clarkedb/grift/pull/69))
@@ -17,7 +26,7 @@ None
17
26
  * To support keyword arguments, records of call arguments are no longer stored in simple arrays but in a custom Enumerable ([#72](https://github.com/clarkedb/grift/pull/72))
18
27
  + This changes the way that your tests will interact with mock calls
19
28
  + When before `calls` returned an array, it returns a `Grift::MockMethod::MockExecutions::MockArguments` object
20
- + Migrating to maintain previous behavior just requires appending `.args` to `calls`
29
+ + Migrating to maintain previous behavior just requires appending `.args` to `calls[i]`
21
30
 
22
31
  ### Added
23
32
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grift (2.0.0)
4
+ grift (2.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -75,4 +75,4 @@ DEPENDENCIES
75
75
  simplecov (>= 0.21.2)
76
76
 
77
77
  BUNDLED WITH
78
- 2.1.4
78
+ 2.2.32
data/README.md CHANGED
@@ -86,6 +86,7 @@ my_spy.mock_implementation do |arg1, arg2, **kwargs|
86
86
  x = do_something(arg1, arg2, kwargs[:arg3], kwargs[:arg4])
87
87
  do_something_else(x) # the last line will be returned
88
88
  end
89
+ ```
89
90
 
90
91
  ### Chaining
91
92
 
@@ -134,6 +134,8 @@ module Grift
134
134
  # @return [self] the mock itself
135
135
  #
136
136
  def mock_implementation(*)
137
+ raise(Grift::Error, 'Must provide a block for the new implementation') unless block_given?
138
+
137
139
  premock_setup
138
140
  mock_executions = @mock_executions # required to access inside class instance block
139
141
 
@@ -220,8 +222,8 @@ module Grift
220
222
  cache_method_name = @cache_method_name
221
223
 
222
224
  class_instance.remove_method(@method_name) if !@inherited && method_defined?
223
- class_instance.define_method @method_name do |*args, **kwargs|
224
- return_value = send(cache_method_name, *args, **kwargs)
225
+ class_instance.define_method @method_name do |*args, **kwargs, &block|
226
+ return_value = send(cache_method_name, *args, **kwargs, &block)
225
227
 
226
228
  # record the args passed in the call to the method and the result
227
229
  mock_executions.store(args: args, kwargs: kwargs, result: return_value)
data/lib/grift/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Grift
4
4
  # gem version
5
- VERSION = '2.0.0'
5
+ VERSION = '2.0.1'
6
6
  public_constant :VERSION
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grift
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clark Brown
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-15 00:00:00.000000000 Z
11
+ date: 2022-03-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A gem for simple mocking and spying in Ruby's MiniTest framework.
14
14
  email:
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.1.6
72
+ rubygems_version: 3.2.32
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Mocking and spying in MiniTest