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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 426f5dbb08f6db2542f0a323d186df7126aaae652e848b0a0c378a602231d777
4
- data.tar.gz: 898501920257accc975d441a12d9e54a034c40aef8c950be2f0fa80aeb0288c6
3
+ metadata.gz: 8e043c9a28687502f8933593acca4a4860a11088b51a7f31ea726e2b80b8eb92
4
+ data.tar.gz: d406fcd7610fb29f2a6c964b777f0e77c770d273c87216872d2feeb9bcda39eb
5
5
  SHA512:
6
- metadata.gz: 6eea3625f3851c035e00c1593e91ae7d97c76b499510a71bd8b68fb0cfb27c4cac9116f9224f30853a97cfb6826385338506e33bf2ea6d43160f12093e8a591c
7
- data.tar.gz: 1e6041f4ea59a42c40b6ef42bf99f106f43eb18d3ec452580784072046f099af26753e61e79704679fba7973bc19b59b3b9cdf0b537fd95e20caceeb18a719ef
6
+ metadata.gz: '09b7f3e7931069bfd62993b8e91d08a92f6e11b51c5b6d21698a0f1773a72786d55d78db1c649aa9a1e935dc72e81042dd2127f15a09e0296c00dbdcb1937423'
7
+ data.tar.gz: d0ffd4f421f76afab828a426c9246a31794341fc7c5a8af862ab8f726eafad1324b3e2caa9ad2dae6ed79a34066fcd5e27be53e6dd7c70544bb3d75c900d725f
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- # unreleased
1
+ # 0.0.5
2
+
3
+ * Fix concurrency [#6](https://github.com/testdouble/mocktail/pull/6)
4
+
5
+ # 0.0.4
2
6
 
3
7
  * Introduce Mocktail.explain(), which will return a message & reference object
4
8
  for any of:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mocktail (0.0.4)
4
+ mocktail (0.0.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
- @self ||= new
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
- @type_replacements = {}
11
- @new_registrations = {}
12
- @of_next_registrations = {}
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
- @type_replacements[type] ||= TypeReplacement.new(type: type)
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
- @type_replacements[type]
23
+ @@type_replacements_mutex.synchronize {
24
+ @@type_replacements[type]
25
+ }
22
26
  end
23
27
 
24
28
  def reset_current_thread!
25
- @new_registrations[Thread.current] = []
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[Thread.current] ||= []
32
- @new_registrations[Thread.current] |= [type]
33
+ @new_registrations |= [type]
33
34
  end
34
35
 
35
36
  def new_replaced?(type)
36
- @new_registrations[Thread.current] ||= []
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[Thread.current] ||= []
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[Thread.current] ||= []
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[Thread.current] ||= []
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[Thread.current] ||= []
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[Thread.current] ||= []
62
- @singleton_method_registrations[Thread.current].include?(type)
57
+ @singleton_method_registrations.include?(type)
63
58
  end
64
59
  end
65
60
  end
@@ -1,3 +1,3 @@
1
1
  module Mocktail
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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, less potency"
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
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-07 00:00:00.000000000 Z
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, less potency
122
+ summary: Take your objects, and make them a double
123
123
  test_files: []