mocktail 1.1.0 → 1.1.1

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: 6a9c74cd3ff5167b99c38892ee6411a1ac3f1379158c062076bfbe6d8479c7b7
4
- data.tar.gz: 81dd2b80a78c162a9c4030fa8bc9be42741c3a8c053fa33c319dc13c404234a8
3
+ metadata.gz: 3f1b0c2f99097d0f23cb67928b5455ce5acf9fad24baee1dff64c748b60a8da9
4
+ data.tar.gz: 9595e5e672d13711a45447b8242977189700e6d0a044f9553e75d642e455f898
5
5
  SHA512:
6
- metadata.gz: bd1fbc482135e89dea00de9249d63b5e851d64ecb2f4afc898b4bb77abf5afc96303cfed6b59665d0e51ab4b2c8dd4c438dc2a7ab93d1c69e1d12d723797cf9a
7
- data.tar.gz: 3af137dd6d1488b1ef41ac0b47178a224e160f11dce0ed0cbeb24418ae4a33c86a6e4fa8e3cabb20c8421c8ac1ac8c166045051d996d4aa1dc709e4fcc97ec3a
6
+ metadata.gz: 5469cfd8d09da0ba752c60529cfc016acecea8b69107d07a467e576812e1d1abf74d05f3431228c4789bf3397059e249a3307dd788a7c4bce410a85f8d86d0ee
7
+ data.tar.gz: c7dea9981f4ed8f76b4f5595c0dd88d747f30371d6c5c6245f8bd498864850700e5ca9f1c1af06b67879b24bcdf90e14d5cfd7b2111838580f3fbd4554b3cbec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 1.1.1
2
+
3
+ * Improve output for undefined singleton methods
4
+ ([#11](https://github.com/testdouble/mocktail/pull/11) by
5
+ [@calebhearth](https://github.com/calebhearth))
6
+
1
7
  # 1.1.0
2
8
 
3
9
  * Feature: add support for passing methods to `Mocktail.explain()`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mocktail (1.1.0)
4
+ mocktail (1.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -11,28 +11,28 @@ GEM
11
11
  docile (1.4.0)
12
12
  method_source (1.0.0)
13
13
  minitest (5.15.0)
14
- parallel (1.21.0)
15
- parser (3.1.0.0)
14
+ parallel (1.22.1)
15
+ parser (3.1.2.0)
16
16
  ast (~> 2.4.1)
17
17
  pry (0.14.1)
18
18
  coderay (~> 1.1)
19
19
  method_source (~> 1.0)
20
20
  rainbow (3.1.1)
21
21
  rake (13.0.6)
22
- regexp_parser (2.2.0)
22
+ regexp_parser (2.3.0)
23
23
  rexml (3.2.5)
24
- rubocop (1.25.0)
24
+ rubocop (1.27.0)
25
25
  parallel (~> 1.10)
26
26
  parser (>= 3.1.0.0)
27
27
  rainbow (>= 2.2.2, < 4.0)
28
28
  regexp_parser (>= 1.8, < 3.0)
29
29
  rexml
30
- rubocop-ast (>= 1.15.1, < 2.0)
30
+ rubocop-ast (>= 1.16.0, < 2.0)
31
31
  ruby-progressbar (~> 1.7)
32
32
  unicode-display_width (>= 1.4.0, < 3.0)
33
- rubocop-ast (1.15.1)
34
- parser (>= 3.0.1.1)
35
- rubocop-performance (1.13.2)
33
+ rubocop-ast (1.17.0)
34
+ parser (>= 3.1.1.0)
35
+ rubocop-performance (1.13.3)
36
36
  rubocop (>= 1.7.0, < 2.0)
37
37
  rubocop-ast (>= 0.4.0)
38
38
  ruby-progressbar (1.11.0)
@@ -41,10 +41,10 @@ GEM
41
41
  simplecov-html (~> 0.11)
42
42
  simplecov_json_formatter (~> 0.1)
43
43
  simplecov-html (0.12.3)
44
- simplecov_json_formatter (0.1.3)
45
- standard (1.7.0)
46
- rubocop (= 1.25.0)
47
- rubocop-performance (= 1.13.2)
44
+ simplecov_json_formatter (0.1.4)
45
+ standard (1.10.0)
46
+ rubocop (= 1.27.0)
47
+ rubocop-performance (= 1.13.3)
48
48
  unicode-display_width (2.1.0)
49
49
 
50
50
  PLATFORMS
data/README.md CHANGED
@@ -813,6 +813,31 @@ Calling reset in a `teardown` or `after(:each)` hook will also improve the
813
813
  usefulness of messages returned by `Mocktail.explain` and
814
814
  `Mocktail.explain_nils`.
815
815
 
816
+ ## References
817
+
818
+ Mocktail is designed following a somewhat academic understanding of what mocking
819
+ is and how it should be used. Below are several references on this topic.
820
+
821
+ Blog Posts and Papers:
822
+
823
+ - [Endo-Testing: Unit Testing with Mock
824
+ Objects](<https://www2.ccs.neu.edu/research/demeter/related-work/extreme-programming/MockObjectsFinal.PDF>
825
+ by Tim Mackinnon, Steve Freeman, and Philip Craig, the paper that introduced
826
+ mocking presented by the creators of mocking.
827
+ - Michael Feathers' [The Flawed Theory Behind Unit
828
+ Testing](<https://michaelfeathers.typepad.com/michael_feathers_blog/2008/06/the-flawed-theo.html>)
829
+
830
+ Books:
831
+
832
+ - [_Growing Object-Oriented Software, Guided by
833
+ Tests_](<https://bookshop.org/books/growing-object-oriented-software-guided-by-tests/9780321503626>)
834
+ by Steve Freeman and Nat Price
835
+
836
+ Talks:
837
+
838
+ - [Please don’t mock me](https://www.youtube.com/watch?v=Af4M8GMoxi4) by Justin
839
+ Searls
840
+
816
841
  ## Acknowledgements
817
842
 
818
843
  Mocktail is created & maintained by the software agency [Test
@@ -839,4 +864,3 @@ including (but not limited to) one-on-one communications, public posts/comments,
839
864
  code reviews, pull requests, and GitHub issues. If violations occur, Test Double
840
865
  will take any action they deem appropriate for the infraction, up to and
841
866
  including blocking a user from the organization's repositories.
842
-
@@ -4,7 +4,9 @@ module Mocktail::Matchers
4
4
  :any
5
5
  end
6
6
 
7
- def initialize
7
+ # Change this comment to a descriptive one once this is merged:
8
+ # https://github.com/rubocop/rubocop/pull/10551
9
+ def initialize # standard:disable Style/RedundantInitialize
8
10
  end
9
11
 
10
12
  def match?(actual)
@@ -4,7 +4,9 @@ module Mocktail::Matchers
4
4
  :numeric
5
5
  end
6
6
 
7
- def initialize
7
+ # Change this comment to a descriptive one once this is merged:
8
+ # https://github.com/rubocop/rubocop/pull/10551
9
+ def initialize # standard:disable Style/RedundantInitialize
8
10
  end
9
11
 
10
12
  def match?(actual)
@@ -18,7 +18,7 @@ module Mocktail
18
18
 
19
19
  Need to define the method? Here's a sample definition:
20
20
 
21
- def #{call.method}#{params(call)}
21
+ def #{"self." if call.singleton}#{call.method}#{params(call)}
22
22
  end
23
23
  #{corrections(call)}
24
24
  MSG
@@ -12,6 +12,7 @@ module Mocktail
12
12
  type.method(name)
13
13
  } - [type_replacement.replacement_new]
14
14
 
15
+ declare_singleton_method_missing_errors!(type)
15
16
  handles_dry_call = @handles_dry_call
16
17
  type_replacement.replacement_methods = type_replacement.original_methods.map { |original_method|
17
18
  type.singleton_class.send(:undef_method, original_method.name)
@@ -35,5 +36,27 @@ module Mocktail
35
36
  type.singleton_method(original_method.name)
36
37
  }
37
38
  end
39
+
40
+ def declare_singleton_method_missing_errors!(type)
41
+ return if type.singleton_methods.include?(:method_missing)
42
+
43
+ raises_neato_no_method_error = RaisesNeatoNoMethodError.new
44
+ type.define_singleton_method :method_missing,
45
+ ->(name, *args, **kwargs, &block) {
46
+ raises_neato_no_method_error.call(
47
+ Call.new(
48
+ singleton: true,
49
+ double: self,
50
+ original_type: type,
51
+ dry_type: self.class,
52
+ method: name,
53
+ original_method: nil,
54
+ args: args,
55
+ kwargs: kwargs,
56
+ block: block
57
+ )
58
+ )
59
+ }
60
+ end
38
61
  end
39
62
  end
@@ -1,3 +1,3 @@
1
1
  module Mocktail
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocktail
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-27 00:00:00.000000000 Z
11
+ date: 2022-05-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 3.3.6
120
+ rubygems_version: 3.3.7
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Take your objects, and make them a double