mocktail 1.2.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +6 -5
- data/.gitignore +3 -0
- data/.standard.yml +8 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +98 -25
- data/README.md +18 -922
- data/Rakefile +0 -1
- data/bin/console +1 -2
- data/bin/tapioca +29 -0
- data/lib/mocktail/collects_calls.rb +2 -0
- data/lib/mocktail/debug.rb +13 -10
- data/lib/mocktail/dsl.rb +2 -0
- data/lib/mocktail/errors.rb +2 -0
- data/lib/mocktail/explains_nils.rb +2 -0
- data/lib/mocktail/explains_thing.rb +7 -4
- data/lib/mocktail/grabs_original_method_parameters.rb +30 -0
- data/lib/mocktail/handles_dry_call/fulfills_stubbing/describes_unsatisfied_stubbing.rb +3 -1
- data/lib/mocktail/handles_dry_call/fulfills_stubbing/finds_satisfaction.rb +5 -1
- data/lib/mocktail/handles_dry_call/fulfills_stubbing.rb +2 -0
- data/lib/mocktail/handles_dry_call/logs_call.rb +2 -0
- data/lib/mocktail/handles_dry_call/validates_arguments.rb +6 -4
- data/lib/mocktail/handles_dry_call.rb +2 -0
- data/lib/mocktail/handles_dry_new_call.rb +2 -0
- data/lib/mocktail/imitates_type/ensures_imitation_support.rb +2 -0
- data/lib/mocktail/imitates_type/makes_double/declares_dry_class/reconstructs_call.rb +4 -1
- data/lib/mocktail/imitates_type/makes_double/declares_dry_class.rb +32 -20
- data/lib/mocktail/imitates_type/makes_double/gathers_fakeable_instance_methods.rb +2 -0
- data/lib/mocktail/imitates_type/makes_double.rb +3 -0
- data/lib/mocktail/imitates_type.rb +3 -1
- data/lib/mocktail/initialize_based_on_type_system_mode_switching.rb +9 -0
- data/lib/mocktail/initializes_mocktail.rb +5 -0
- data/lib/mocktail/matcher_presentation.rb +4 -2
- data/lib/mocktail/matchers/any.rb +4 -3
- data/lib/mocktail/matchers/base.rb +10 -2
- data/lib/mocktail/matchers/captor.rb +9 -0
- data/lib/mocktail/matchers/includes.rb +2 -0
- data/lib/mocktail/matchers/includes_hash.rb +9 -0
- data/lib/mocktail/matchers/includes_key.rb +9 -0
- data/lib/mocktail/matchers/includes_string.rb +9 -0
- data/lib/mocktail/matchers/is_a.rb +2 -0
- data/lib/mocktail/matchers/matches.rb +2 -0
- data/lib/mocktail/matchers/not.rb +2 -0
- data/lib/mocktail/matchers/numeric.rb +5 -4
- data/lib/mocktail/matchers/that.rb +2 -0
- data/lib/mocktail/matchers.rb +3 -0
- data/lib/mocktail/raises_neato_no_method_error.rb +2 -0
- data/lib/mocktail/records_demonstration.rb +2 -0
- data/lib/mocktail/registers_matcher.rb +8 -3
- data/lib/mocktail/registers_stubbing.rb +2 -0
- data/lib/mocktail/replaces_next.rb +7 -1
- data/lib/mocktail/replaces_type/redefines_new.rb +3 -1
- data/lib/mocktail/replaces_type/redefines_singleton_methods.rb +14 -2
- data/lib/mocktail/replaces_type/runs_sorbet_sig_blocks_before_replacement.rb +37 -0
- data/lib/mocktail/replaces_type.rb +6 -0
- data/lib/mocktail/resets_state.rb +2 -0
- data/lib/mocktail/share/bind.rb +7 -5
- data/lib/mocktail/share/cleans_backtrace.rb +3 -5
- data/lib/mocktail/share/creates_identifier.rb +16 -9
- data/lib/mocktail/share/determines_matching_calls.rb +4 -2
- data/lib/mocktail/share/stringifies_call.rb +6 -2
- data/lib/mocktail/share/stringifies_method_name.rb +3 -1
- data/lib/mocktail/simulates_argument_error/reconciles_args_with_params.rb +2 -0
- data/lib/mocktail/simulates_argument_error/recreates_message.rb +2 -0
- data/lib/mocktail/simulates_argument_error/transforms_params.rb +15 -8
- data/lib/mocktail/simulates_argument_error.rb +2 -0
- data/lib/mocktail/sorbet/mocktail/collects_calls.rb +18 -0
- data/lib/mocktail/sorbet/mocktail/debug.rb +54 -0
- data/lib/mocktail/sorbet/mocktail/dsl.rb +46 -0
- data/lib/mocktail/sorbet/mocktail/errors.rb +19 -0
- data/lib/mocktail/sorbet/mocktail/explains_nils.rb +41 -0
- data/lib/mocktail/sorbet/mocktail/explains_thing.rb +137 -0
- data/lib/mocktail/sorbet/mocktail/grabs_original_method_parameters.rb +33 -0
- data/lib/mocktail/sorbet/mocktail/handles_dry_call/fulfills_stubbing/describes_unsatisfied_stubbing.rb +27 -0
- data/lib/mocktail/sorbet/mocktail/handles_dry_call/fulfills_stubbing/finds_satisfaction.rb +24 -0
- data/lib/mocktail/sorbet/mocktail/handles_dry_call/fulfills_stubbing.rb +45 -0
- data/lib/mocktail/sorbet/mocktail/handles_dry_call/logs_call.rb +12 -0
- data/lib/mocktail/sorbet/mocktail/handles_dry_call/validates_arguments.rb +45 -0
- data/lib/mocktail/sorbet/mocktail/handles_dry_call.rb +25 -0
- data/lib/mocktail/sorbet/mocktail/handles_dry_new_call.rb +42 -0
- data/lib/mocktail/sorbet/mocktail/imitates_type/ensures_imitation_support.rb +16 -0
- data/lib/mocktail/sorbet/mocktail/imitates_type/makes_double/declares_dry_class/reconstructs_call.rb +73 -0
- data/lib/mocktail/sorbet/mocktail/imitates_type/makes_double/declares_dry_class.rb +136 -0
- data/lib/mocktail/sorbet/mocktail/imitates_type/makes_double/gathers_fakeable_instance_methods.rb +28 -0
- data/lib/mocktail/sorbet/mocktail/imitates_type/makes_double.rb +29 -0
- data/lib/mocktail/sorbet/mocktail/imitates_type.rb +29 -0
- data/lib/mocktail/sorbet/mocktail/initialize_based_on_type_system_mode_switching.rb +11 -0
- data/lib/mocktail/sorbet/mocktail/initializes_mocktail.rb +25 -0
- data/lib/mocktail/sorbet/mocktail/matcher_presentation.rb +21 -0
- data/lib/mocktail/sorbet/mocktail/matchers/any.rb +27 -0
- data/lib/mocktail/sorbet/mocktail/matchers/base.rb +39 -0
- data/lib/mocktail/sorbet/mocktail/matchers/captor.rb +76 -0
- data/lib/mocktail/sorbet/mocktail/matchers/includes.rb +32 -0
- data/lib/mocktail/sorbet/mocktail/matchers/includes_hash.rb +12 -0
- data/lib/mocktail/sorbet/mocktail/matchers/includes_key.rb +12 -0
- data/lib/mocktail/sorbet/mocktail/matchers/includes_string.rb +12 -0
- data/lib/mocktail/sorbet/mocktail/matchers/is_a.rb +17 -0
- data/lib/mocktail/sorbet/mocktail/matchers/matches.rb +19 -0
- data/lib/mocktail/sorbet/mocktail/matchers/not.rb +17 -0
- data/lib/mocktail/sorbet/mocktail/matchers/numeric.rb +27 -0
- data/lib/mocktail/sorbet/mocktail/matchers/that.rb +32 -0
- data/lib/mocktail/sorbet/mocktail/matchers.rb +19 -0
- data/lib/mocktail/sorbet/mocktail/raises_neato_no_method_error.rb +93 -0
- data/lib/mocktail/sorbet/mocktail/records_demonstration.rb +43 -0
- data/lib/mocktail/sorbet/mocktail/registers_matcher.rb +65 -0
- data/lib/mocktail/sorbet/mocktail/registers_stubbing.rb +31 -0
- data/lib/mocktail/sorbet/mocktail/replaces_next.rb +55 -0
- data/lib/mocktail/sorbet/mocktail/replaces_type/redefines_new.rb +32 -0
- data/lib/mocktail/sorbet/mocktail/replaces_type/redefines_singleton_methods.rb +80 -0
- data/lib/mocktail/sorbet/mocktail/replaces_type/runs_sorbet_sig_blocks_before_replacement.rb +39 -0
- data/lib/mocktail/sorbet/mocktail/replaces_type.rb +36 -0
- data/lib/mocktail/sorbet/mocktail/resets_state.rb +14 -0
- data/lib/mocktail/sorbet/mocktail/share/bind.rb +18 -0
- data/lib/mocktail/sorbet/mocktail/share/cleans_backtrace.rb +22 -0
- data/lib/mocktail/sorbet/mocktail/share/creates_identifier.rb +39 -0
- data/lib/mocktail/sorbet/mocktail/share/determines_matching_calls.rb +72 -0
- data/lib/mocktail/sorbet/mocktail/share/stringifies_call.rb +85 -0
- data/lib/mocktail/sorbet/mocktail/share/stringifies_method_name.rb +16 -0
- data/lib/mocktail/sorbet/mocktail/simulates_argument_error/reconciles_args_with_params.rb +27 -0
- data/lib/mocktail/sorbet/mocktail/simulates_argument_error/recreates_message.rb +34 -0
- data/lib/mocktail/sorbet/mocktail/simulates_argument_error/transforms_params.rb +58 -0
- data/lib/mocktail/sorbet/mocktail/simulates_argument_error.rb +36 -0
- data/lib/mocktail/sorbet/mocktail/sorbet.rb +3 -0
- data/lib/mocktail/sorbet/mocktail/stringifies_method_signature.rb +53 -0
- data/lib/mocktail/sorbet/mocktail/typed.rb +5 -0
- data/lib/mocktail/sorbet/mocktail/value/cabinet.rb +91 -0
- data/lib/mocktail/sorbet/mocktail/value/call.rb +51 -0
- data/lib/mocktail/sorbet/mocktail/value/demo_config.rb +10 -0
- data/lib/mocktail/sorbet/mocktail/value/double.rb +10 -0
- data/lib/mocktail/sorbet/mocktail/value/double_data.rb +15 -0
- data/lib/mocktail/sorbet/mocktail/value/explanation.rb +68 -0
- data/lib/mocktail/sorbet/mocktail/value/explanation_data.rb +19 -0
- data/lib/mocktail/sorbet/mocktail/value/fake_method_data.rb +11 -0
- data/lib/mocktail/sorbet/mocktail/value/matcher_registry.rb +27 -0
- data/lib/mocktail/sorbet/mocktail/value/no_explanation_data.rb +20 -0
- data/lib/mocktail/sorbet/mocktail/value/signature.rb +35 -0
- data/lib/mocktail/sorbet/mocktail/value/stubbing.rb +26 -0
- data/lib/mocktail/sorbet/mocktail/value/top_shelf.rb +79 -0
- data/lib/mocktail/sorbet/mocktail/value/type_replacement.rb +11 -0
- data/lib/mocktail/sorbet/mocktail/value/type_replacement_data.rb +19 -0
- data/lib/mocktail/sorbet/mocktail/value/unsatisfying_call.rb +9 -0
- data/lib/mocktail/sorbet/mocktail/value/unsatisfying_call_explanation.rb +24 -0
- data/lib/mocktail/sorbet/mocktail/value.rb +19 -0
- data/lib/mocktail/sorbet/mocktail/verifies_call/finds_verifiable_calls.rb +21 -0
- data/lib/mocktail/sorbet/mocktail/verifies_call/raises_verification_error/gathers_calls_of_method.rb +15 -0
- data/lib/mocktail/sorbet/mocktail/verifies_call/raises_verification_error.rb +74 -0
- data/lib/mocktail/sorbet/mocktail/verifies_call.rb +37 -0
- data/lib/mocktail/sorbet/mocktail/version.rb +12 -0
- data/lib/mocktail/sorbet/mocktail.rb +154 -0
- data/lib/mocktail/sorbet.rb +1 -0
- data/lib/mocktail/stringifies_method_signature.rb +2 -0
- data/lib/mocktail/typed.rb +3 -0
- data/lib/mocktail/value/cabinet.rb +8 -1
- data/lib/mocktail/value/call.rb +44 -12
- data/lib/mocktail/value/demo_config.rb +6 -7
- data/lib/mocktail/value/double.rb +6 -7
- data/lib/mocktail/value/double_data.rb +11 -7
- data/lib/mocktail/value/explanation.rb +28 -3
- data/lib/mocktail/value/explanation_data.rb +14 -0
- data/lib/mocktail/value/fake_method_data.rb +7 -6
- data/lib/mocktail/value/matcher_registry.rb +2 -0
- data/lib/mocktail/value/no_explanation_data.rb +16 -0
- data/lib/mocktail/value/signature.rb +19 -27
- data/lib/mocktail/value/stubbing.rb +11 -12
- data/lib/mocktail/value/top_shelf.rb +5 -0
- data/lib/mocktail/value/type_replacement.rb +7 -8
- data/lib/mocktail/value/type_replacement_data.rb +10 -7
- data/lib/mocktail/value/unsatisfying_call.rb +5 -6
- data/lib/mocktail/value/unsatisfying_call_explanation.rb +18 -0
- data/lib/mocktail/value.rb +5 -2
- data/lib/mocktail/verifies_call/finds_verifiable_calls.rb +2 -0
- data/lib/mocktail/verifies_call/raises_verification_error/gathers_calls_of_method.rb +2 -0
- data/lib/mocktail/verifies_call/raises_verification_error.rb +2 -0
- data/lib/mocktail/verifies_call.rb +3 -0
- data/lib/mocktail/version.rb +8 -1
- data/lib/mocktail.rb +46 -5
- data/mocktail.gemspec +8 -4
- data/rbi/mocktail-pregenerated.rbi +1865 -0
- data/rbi/mocktail.rbi +77 -0
- data/rbi/sorbet-runtime.rbi +29 -0
- data/spoom_report.html +1248 -0
- metadata +130 -3
@@ -1,16 +1,14 @@
|
|
1
1
|
module Mocktail
|
2
|
-
Stubbing
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
self.satisfaction_count ||= 0
|
13
|
-
end
|
2
|
+
class Stubbing < T::Struct
|
3
|
+
extend T::Sig
|
4
|
+
extend T::Generic
|
5
|
+
MethodReturnType = type_member
|
6
|
+
|
7
|
+
const :demonstration
|
8
|
+
const :demo_config
|
9
|
+
prop :satisfaction_count, default: 0
|
10
|
+
const :recording
|
11
|
+
prop :effect
|
14
12
|
|
15
13
|
def satisfied!
|
16
14
|
self.satisfaction_count += 1
|
@@ -18,6 +16,7 @@ module Mocktail
|
|
18
16
|
|
19
17
|
def with(&block)
|
20
18
|
self.effect = block
|
19
|
+
nil
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
@@ -1,5 +1,10 @@
|
|
1
1
|
module Mocktail
|
2
|
+
# The TopShelf is where we keep all the more global, dangerous state.
|
3
|
+
# In particular, this is where Mocktail manages state related to singleton
|
4
|
+
# method replacements carried out with Mocktail.replace(ClassOrModule)
|
2
5
|
class TopShelf
|
6
|
+
extend T::Sig
|
7
|
+
|
3
8
|
def self.instance
|
4
9
|
Thread.current[:mocktail_top_shelf] ||= new
|
5
10
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module Mocktail
|
2
|
-
TypeReplacement
|
3
|
-
:type
|
4
|
-
:original_methods
|
5
|
-
:replacement_methods
|
6
|
-
:original_new
|
7
|
-
:replacement_new
|
8
|
-
|
9
|
-
)
|
2
|
+
class TypeReplacement < T::Struct
|
3
|
+
const :type
|
4
|
+
prop :original_methods
|
5
|
+
prop :replacement_methods
|
6
|
+
prop :original_new
|
7
|
+
prop :replacement_new
|
8
|
+
end
|
10
9
|
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
module Mocktail
|
2
|
-
TypeReplacementData
|
3
|
-
|
4
|
-
|
5
|
-
:
|
6
|
-
:
|
7
|
-
|
8
|
-
|
2
|
+
class TypeReplacementData < T::Struct
|
3
|
+
extend T::Sig
|
4
|
+
|
5
|
+
const :type
|
6
|
+
const :replaced_method_names
|
7
|
+
const :calls
|
8
|
+
const :stubbings
|
9
|
+
|
10
|
+
include ExplanationData
|
11
|
+
|
9
12
|
def double
|
10
13
|
type
|
11
14
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Mocktail
|
2
|
+
class UnsatisfyingCallExplanation
|
3
|
+
extend T::Sig
|
4
|
+
|
5
|
+
attr_reader :reference
|
6
|
+
|
7
|
+
attr_reader :message
|
8
|
+
|
9
|
+
def initialize(reference, message)
|
10
|
+
@reference = reference
|
11
|
+
@message = message
|
12
|
+
end
|
13
|
+
|
14
|
+
def type
|
15
|
+
self.class
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/mocktail/value.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
require_relative "value/cabinet"
|
2
2
|
require_relative "value/call"
|
3
3
|
require_relative "value/demo_config"
|
4
|
+
require_relative "value/explanation"
|
5
|
+
require_relative "value/explanation_data"
|
4
6
|
require_relative "value/double"
|
5
7
|
require_relative "value/double_data"
|
6
|
-
require_relative "value/explanation"
|
7
8
|
require_relative "value/fake_method_data"
|
8
9
|
require_relative "value/matcher_registry"
|
10
|
+
require_relative "value/no_explanation_data"
|
9
11
|
require_relative "value/signature"
|
10
12
|
require_relative "value/stubbing"
|
11
|
-
require_relative "value/top_shelf"
|
12
13
|
require_relative "value/type_replacement"
|
13
14
|
require_relative "value/type_replacement_data"
|
15
|
+
require_relative "value/unsatisfying_call_explanation"
|
14
16
|
require_relative "value/unsatisfying_call"
|
17
|
+
require_relative "value/top_shelf"
|
@@ -4,6 +4,8 @@ require_relative "verifies_call/raises_verification_error"
|
|
4
4
|
|
5
5
|
module Mocktail
|
6
6
|
class VerifiesCall
|
7
|
+
extend T::Sig
|
8
|
+
|
7
9
|
def initialize
|
8
10
|
@records_demonstration = RecordsDemonstration.new
|
9
11
|
@finds_verifiable_calls = FindsVerifiableCalls.new
|
@@ -17,6 +19,7 @@ module Mocktail
|
|
17
19
|
unless verification_satisfied?(verifiable_calls.size, demo_config)
|
18
20
|
@raises_verification_error.raise(recording, verifiable_calls, demo_config)
|
19
21
|
end
|
22
|
+
nil
|
20
23
|
end
|
21
24
|
|
22
25
|
private
|
data/lib/mocktail/version.rb
CHANGED
@@ -1,3 +1,10 @@
|
|
1
1
|
module Mocktail
|
2
|
-
VERSION
|
2
|
+
# The gemspec will define Module::VERSION as loaded from lib/, but if the
|
3
|
+
# user loads mocktail/sorbet, its version file will be effectively redefining
|
4
|
+
# it. Undef it first to ensure we don't spew warnings
|
5
|
+
if defined?(VERSION)
|
6
|
+
Mocktail.send(:remove_const, :VERSION)
|
7
|
+
end
|
8
|
+
|
9
|
+
VERSION = "2.0.0"
|
3
10
|
end
|
data/lib/mocktail.rb
CHANGED
@@ -1,9 +1,23 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
if defined?(Mocktail::TYPED)
|
4
|
+
if eval("Mocktail::TYPED", binding, __FILE__, __LINE__)
|
5
|
+
warn "`require \"mocktail\"' was called, but Mocktail was already required as `require \"mocktail/sorbet\"', so we're NOT going to load it to avoid constants from being redefined. If you want to use Mocktail WITHOUT sorbet runtime checks, remove whatever is requiring `mocktail/sorbet'."
|
6
|
+
else
|
7
|
+
warn "`require \"mocktail/sorbet\"' was called, but Mocktail was already required as `require \"mocktail\"', so we're NOT going to load it to avoid constants from being redefined. If you want to use Mocktail WITH sorbet runtime checks, remove whatever is requiring `mocktail'."
|
8
|
+
end
|
9
|
+
return
|
10
|
+
end
|
11
|
+
|
12
|
+
require_relative "mocktail/initialize_based_on_type_system_mode_switching"
|
13
|
+
|
1
14
|
require_relative "mocktail/collects_calls"
|
2
15
|
require_relative "mocktail/debug"
|
3
16
|
require_relative "mocktail/dsl"
|
4
17
|
require_relative "mocktail/errors"
|
5
18
|
require_relative "mocktail/explains_thing"
|
6
19
|
require_relative "mocktail/explains_nils"
|
20
|
+
require_relative "mocktail/grabs_original_method_parameters"
|
7
21
|
require_relative "mocktail/handles_dry_call"
|
8
22
|
require_relative "mocktail/handles_dry_new_call"
|
9
23
|
require_relative "mocktail/imitates_type"
|
@@ -23,20 +37,44 @@ require_relative "mocktail/verifies_call"
|
|
23
37
|
require_relative "mocktail/version"
|
24
38
|
|
25
39
|
module Mocktail
|
40
|
+
extend T::Sig
|
41
|
+
extend DSL
|
42
|
+
BASE_PATH = (Pathname.new(__FILE__) + "..").to_s
|
43
|
+
|
26
44
|
# Returns an instance of `type` whose implementation is mocked out
|
45
|
+
|
27
46
|
def self.of(type)
|
28
47
|
ImitatesType.new.imitate(type)
|
29
48
|
end
|
30
49
|
|
31
50
|
# Returns an instance of `klass` whose implementation is mocked out AND
|
32
51
|
# stubs its constructor to return that fake the next time klass.new is called
|
52
|
+
|
33
53
|
def self.of_next(type, count: 1)
|
34
|
-
|
54
|
+
count ||= 1
|
55
|
+
if count == 1
|
56
|
+
ReplacesNext.new.replace_once(type)
|
57
|
+
elsif !Mocktail::TYPED || T::Private::RuntimeLevels.default_checked_level == :never
|
58
|
+
ReplacesNext.new.replace(type, count)
|
59
|
+
else
|
60
|
+
raise TypeCheckingError.new <<~MSG
|
61
|
+
Calling `Mocktail.of_next()' with a `count' value other than 1 is not supported when
|
62
|
+
type checking is enabled. There are two ways to fix this:
|
63
|
+
|
64
|
+
1. Use `Mocktail.of_next_with_count(type, count)' instead, which will always return
|
65
|
+
an array of fake objects.
|
66
|
+
|
67
|
+
2. Disable runtime type checking by setting `T::Private::RuntimeLevels.default_checked_level = :never'
|
68
|
+
or by setting the envronment variable `SORBET_RUNTIME_DEFAULT_CHECKED_LEVEL=never'
|
69
|
+
MSG
|
70
|
+
end
|
35
71
|
end
|
36
72
|
|
37
|
-
#
|
38
|
-
|
39
|
-
|
73
|
+
# An alias of of_next that always returns an array of fakes
|
74
|
+
|
75
|
+
def self.of_next_with_count(type, count)
|
76
|
+
ReplacesNext.new.replace(type, count)
|
77
|
+
end
|
40
78
|
|
41
79
|
def self.matchers
|
42
80
|
MatcherPresentation.new
|
@@ -52,6 +90,7 @@ module Mocktail
|
|
52
90
|
|
53
91
|
# Replaces every singleton method on `type` with a fake, and when instantiated
|
54
92
|
# or included will also fake instance methods
|
93
|
+
|
55
94
|
def self.replace(type)
|
56
95
|
ReplacesType.new.replace(type)
|
57
96
|
nil
|
@@ -72,13 +111,15 @@ module Mocktail
|
|
72
111
|
# An alias for Mocktail.explain(double).reference.calls
|
73
112
|
# Takes an optional second parameter of the method name to filter only
|
74
113
|
# calls to that method
|
114
|
+
|
75
115
|
def self.calls(double, method_name = nil)
|
76
|
-
CollectsCalls.new.collect(double, method_name)
|
116
|
+
CollectsCalls.new.collect(double, method_name&.to_sym)
|
77
117
|
end
|
78
118
|
|
79
119
|
# Stores most transactional state about calls & stubbing configurations
|
80
120
|
# Anything returned by this is undocumented and could change at any time, so
|
81
121
|
# don't commit code that relies on it!
|
122
|
+
|
82
123
|
def self.cabinet
|
83
124
|
Thread.current[:mocktail_store] ||= Cabinet.new
|
84
125
|
end
|
data/mocktail.gemspec
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require_relative "lib/mocktail/version"
|
3
|
+
rescue LoadError
|
4
|
+
require_relative "src/mocktail/version"
|
5
|
+
end
|
2
6
|
|
3
7
|
Gem::Specification.new do |spec|
|
4
8
|
spec.name = "mocktail"
|
@@ -18,14 +22,14 @@ Gem::Specification.new do |spec|
|
|
18
22
|
# Specify which files should be added to the gem when it is released.
|
19
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
24
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|src|sub_projects|spoom_data|sorbet|script|docs)/}) }
|
22
26
|
end
|
23
27
|
spec.bindir = "exe"
|
24
28
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
25
29
|
spec.require_paths = ["lib"]
|
26
30
|
|
27
|
-
|
28
|
-
|
31
|
+
spec.add_dependency "sorbet-runtime", "~> 0.5.9204"
|
32
|
+
spec.add_dependency "sorbet-eraser", "~> 0.3.1"
|
29
33
|
|
30
34
|
# For more information and examples about making a new gem, checkout our
|
31
35
|
# guide at: https://bundler.io/guides/creating_gem.html
|