mocktail 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/mocktail/explains_thing.rb +2 -2
- data/lib/mocktail/value/top_shelf.rb +21 -26
- data/lib/mocktail/version.rb +1 -1
- data/mocktail.gemspec +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: 8e043c9a28687502f8933593acca4a4860a11088b51a7f31ea726e2b80b8eb92
|
4
|
+
data.tar.gz: d406fcd7610fb29f2a6c964b777f0e77c770d273c87216872d2feeb9bcda39eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09b7f3e7931069bfd62993b8e91d08a92f6e11b51c5b6d21698a0f1773a72786d55d78db1c649aa9a1e935dc72e81042dd2127f15a09e0296c00dbdcb1937423'
|
7
|
+
data.tar.gz: d0ffd4f421f76afab828a426c9246a31794341fc7c5a8af862ab8f726eafad1324b3e2caa9ad2dae6ed79a34066fcd5e27be53e6dd7c70544bb3d75c900d725f
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -731,3 +731,4 @@ including (but not limited to) one-on-one communications, public posts/comments,
|
|
731
731
|
code reviews, pull requests, and GitHub issues. If violations occur, Test Double
|
732
732
|
will take any action they deem appropriate for the infraction, up to and
|
733
733
|
including blocking a user from the organization's repositories.
|
734
|
+
|
@@ -59,9 +59,9 @@ module Mocktail
|
|
59
59
|
This is a fake `#{double.original_type.name}' instance.
|
60
60
|
|
61
61
|
It has these mocked methods:
|
62
|
-
#{double.dry_methods.map { |method| " - #{method}" }.join("\n")}
|
62
|
+
#{double.dry_methods.sort.map { |method| " - #{method}" }.join("\n")}
|
63
63
|
|
64
|
-
#{double.dry_methods.map { |method| describe_dry_method(double_data, method) }.join("\n")}
|
64
|
+
#{double.dry_methods.sort.map { |method| describe_dry_method(double_data, method) }.join("\n")}
|
65
65
|
MSG
|
66
66
|
end
|
67
67
|
|
@@ -1,65 +1,60 @@
|
|
1
|
-
# The top shelf stores all cross-thread & thread-aware state, so anything that
|
2
|
-
# goes here is on its own when it comes to ensuring thread safety.
|
3
1
|
module Mocktail
|
4
2
|
class TopShelf
|
5
3
|
def self.instance
|
6
|
-
|
4
|
+
Thread.current[:mocktail_top_shelf] ||= new
|
7
5
|
end
|
8
6
|
|
7
|
+
@@type_replacements = {}
|
8
|
+
@@type_replacements_mutex = Mutex.new
|
9
|
+
|
9
10
|
def initialize
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@singleton_method_registrations = {}
|
11
|
+
@new_registrations = []
|
12
|
+
@of_next_registrations = []
|
13
|
+
@singleton_method_registrations = []
|
14
14
|
end
|
15
15
|
|
16
16
|
def type_replacement_for(type)
|
17
|
-
|
17
|
+
@@type_replacements_mutex.synchronize {
|
18
|
+
@@type_replacements[type] ||= TypeReplacement.new(type: type)
|
19
|
+
}
|
18
20
|
end
|
19
21
|
|
20
22
|
def type_replacement_if_exists_for(type)
|
21
|
-
|
23
|
+
@@type_replacements_mutex.synchronize {
|
24
|
+
@@type_replacements[type]
|
25
|
+
}
|
22
26
|
end
|
23
27
|
|
24
28
|
def reset_current_thread!
|
25
|
-
|
26
|
-
@of_next_registrations[Thread.current] = []
|
27
|
-
@singleton_method_registrations[Thread.current] = []
|
29
|
+
Thread.current[:mocktail_top_shelf] = self.class.new
|
28
30
|
end
|
29
31
|
|
30
32
|
def register_new_replacement!(type)
|
31
|
-
@new_registrations
|
32
|
-
@new_registrations[Thread.current] |= [type]
|
33
|
+
@new_registrations |= [type]
|
33
34
|
end
|
34
35
|
|
35
36
|
def new_replaced?(type)
|
36
|
-
@new_registrations
|
37
|
-
@new_registrations[Thread.current].include?(type)
|
37
|
+
@new_registrations.include?(type)
|
38
38
|
end
|
39
39
|
|
40
40
|
def register_of_next_replacement!(type)
|
41
|
-
@of_next_registrations
|
42
|
-
@of_next_registrations[Thread.current] |= [type]
|
41
|
+
@of_next_registrations |= [type]
|
43
42
|
end
|
44
43
|
|
45
44
|
def of_next_registered?(type)
|
46
|
-
@of_next_registrations
|
47
|
-
@of_next_registrations[Thread.current].include?(type)
|
45
|
+
@of_next_registrations.include?(type)
|
48
46
|
end
|
49
47
|
|
50
48
|
def unregister_of_next_replacement!(type)
|
51
|
-
@of_next_registrations
|
52
|
-
@of_next_registrations[Thread.current] -= [type]
|
49
|
+
@of_next_registrations -= [type]
|
53
50
|
end
|
54
51
|
|
55
52
|
def register_singleton_method_replacement!(type)
|
56
|
-
@singleton_method_registrations
|
57
|
-
@singleton_method_registrations[Thread.current] |= [type]
|
53
|
+
@singleton_method_registrations |= [type]
|
58
54
|
end
|
59
55
|
|
60
56
|
def singleton_methods_replaced?(type)
|
61
|
-
@singleton_method_registrations
|
62
|
-
@singleton_method_registrations[Thread.current].include?(type)
|
57
|
+
@singleton_method_registrations.include?(type)
|
63
58
|
end
|
64
59
|
end
|
65
60
|
end
|
data/lib/mocktail/version.rb
CHANGED
data/mocktail.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ["Justin Searls"]
|
7
7
|
spec.email = ["searls@gmail.com"]
|
8
8
|
|
9
|
-
spec.summary = "your objects,
|
9
|
+
spec.summary = "Take your objects, and make them a double"
|
10
10
|
spec.homepage = "https://github.com/testdouble/mocktail"
|
11
11
|
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
12
12
|
|
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: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Searls
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -119,5 +119,5 @@ requirements: []
|
|
119
119
|
rubygems_version: 3.2.15
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
|
-
summary: your objects,
|
122
|
+
summary: Take your objects, and make them a double
|
123
123
|
test_files: []
|