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 +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +13 -13
- data/README.md +25 -1
- data/lib/mocktail/matchers/any.rb +3 -1
- data/lib/mocktail/matchers/numeric.rb +3 -1
- data/lib/mocktail/raises_neato_no_method_error.rb +1 -1
- data/lib/mocktail/replaces_type/redefines_singleton_methods.rb +23 -0
- data/lib/mocktail/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f1b0c2f99097d0f23cb67928b5455ce5acf9fad24baee1dff64c748b60a8da9
|
4
|
+
data.tar.gz: 9595e5e672d13711a45447b8242977189700e6d0a044f9553e75d642e455f898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5469cfd8d09da0ba752c60529cfc016acecea8b69107d07a467e576812e1d1abf74d05f3431228c4789bf3397059e249a3307dd788a7c4bce410a85f8d86d0ee
|
7
|
+
data.tar.gz: c7dea9981f4ed8f76b4f5595c0dd88d747f30371d6c5c6245f8bd498864850700e5ca9f1c1af06b67879b24bcdf90e14d5cfd7b2111838580f3fbd4554b3cbec
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mocktail (1.1.
|
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.
|
15
|
-
parser (3.1.
|
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.
|
22
|
+
regexp_parser (2.3.0)
|
23
23
|
rexml (3.2.5)
|
24
|
-
rubocop (1.
|
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.
|
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.
|
34
|
-
parser (>= 3.
|
35
|
-
rubocop-performance (1.13.
|
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.
|
45
|
-
standard (1.
|
46
|
-
rubocop (= 1.
|
47
|
-
rubocop-performance (= 1.13.
|
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
|
-
|
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
|
-
|
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)
|
@@ -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
|
data/lib/mocktail/version.rb
CHANGED
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.
|
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-
|
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.
|
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
|