mocha 3.0.0.pre.rc.1 → 3.0.0.pre.rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -37
  3. data/.yardopts +2 -0
  4. data/Gemfile +2 -5
  5. data/RELEASE.md +42 -0
  6. data/Rakefile +39 -19
  7. data/lib/mocha/any_instance_method.rb +4 -4
  8. data/lib/mocha/api.rb +1 -1
  9. data/lib/mocha/class_methods.rb +9 -5
  10. data/lib/mocha/configuration.rb +1 -1
  11. data/lib/mocha/deprecation.rb +1 -1
  12. data/lib/mocha/expectation.rb +2 -2
  13. data/lib/mocha/expectation_list.rb +1 -1
  14. data/lib/mocha/hooks.rb +4 -4
  15. data/lib/mocha/ignoring_warning.rb +20 -0
  16. data/lib/mocha/instance_method.rb +4 -4
  17. data/lib/mocha/integration/minitest/adapter.rb +4 -3
  18. data/lib/mocha/integration/minitest.rb +1 -1
  19. data/lib/mocha/integration/test_unit/adapter.rb +7 -4
  20. data/lib/mocha/integration/test_unit.rb +1 -1
  21. data/lib/mocha/integration.rb +5 -0
  22. data/lib/mocha/mock.rb +8 -4
  23. data/lib/mocha/mockery.rb +20 -12
  24. data/lib/mocha/object_methods.rb +13 -1
  25. data/lib/mocha/parameter_matchers/all_of.rb +24 -22
  26. data/lib/mocha/parameter_matchers/any_of.rb +30 -28
  27. data/lib/mocha/parameter_matchers/any_parameters.rb +22 -20
  28. data/lib/mocha/parameter_matchers/anything.rb +19 -17
  29. data/lib/mocha/parameter_matchers/{base.rb → base_methods.rb} +6 -4
  30. data/lib/mocha/parameter_matchers/equals.rb +25 -23
  31. data/lib/mocha/parameter_matchers/equivalent_uri.rb +28 -24
  32. data/lib/mocha/parameter_matchers/has_entries.rb +25 -23
  33. data/lib/mocha/parameter_matchers/has_entry.rb +66 -66
  34. data/lib/mocha/parameter_matchers/has_key.rb +25 -23
  35. data/lib/mocha/parameter_matchers/has_keys.rb +25 -23
  36. data/lib/mocha/parameter_matchers/has_value.rb +25 -23
  37. data/lib/mocha/parameter_matchers/includes.rb +63 -61
  38. data/lib/mocha/parameter_matchers/instance_methods.rb +2 -2
  39. data/lib/mocha/parameter_matchers/instance_of.rb +25 -23
  40. data/lib/mocha/parameter_matchers/is_a.rb +26 -24
  41. data/lib/mocha/parameter_matchers/kind_of.rb +25 -23
  42. data/lib/mocha/parameter_matchers/not.rb +25 -23
  43. data/lib/mocha/parameter_matchers/optionally.rb +35 -33
  44. data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +2 -2
  45. data/lib/mocha/parameter_matchers/regexp_matches.rb +25 -23
  46. data/lib/mocha/parameter_matchers/responds_with.rb +49 -47
  47. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +24 -22
  48. data/lib/mocha/parameter_matchers.rb +5 -2
  49. data/lib/mocha/state_machine.rb +1 -1
  50. data/lib/mocha/stubbed_method.rb +7 -7
  51. data/lib/mocha/version.rb +1 -1
  52. data/lib/mocha.rb +15 -0
  53. metadata +9 -4
@@ -1,35 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mocha/parameter_matchers/base'
3
+ require 'mocha/parameter_matchers/base_methods'
4
4
 
5
5
  module Mocha
6
6
  module ParameterMatchers
7
- # Matches any +Object+ that is a kind of +klass+.
8
- #
9
- # @param [Class] klass expected class.
10
- # @return [KindOf] parameter matcher.
11
- #
12
- # @see Expectation#with
13
- # @see Kernel#kind_of?
14
- #
15
- # @example Actual parameter is a kind of +Integer+.
16
- # object = mock()
17
- # object.expects(:method_1).with(kind_of(Integer))
18
- # object.method_1(99)
19
- # # no error raised
20
- #
21
- # @example Actual parameter is not a kind of +Integer+.
22
- # object = mock()
23
- # object.expects(:method_1).with(kind_of(Integer))
24
- # object.method_1('string')
25
- # # error raised, because method_1 was not called with a kind of Integer
26
- def kind_of(klass)
27
- KindOf.new(klass)
7
+ module Methods
8
+ # Matches any +Object+ that is a kind of +klass+.
9
+ #
10
+ # @param [Class] klass expected class.
11
+ # @return [KindOf] parameter matcher.
12
+ #
13
+ # @see Expectation#with
14
+ # @see Kernel#kind_of?
15
+ #
16
+ # @example Actual parameter is a kind of +Integer+.
17
+ # object = mock()
18
+ # object.expects(:method_1).with(kind_of(Integer))
19
+ # object.method_1(99)
20
+ # # no error raised
21
+ #
22
+ # @example Actual parameter is not a kind of +Integer+.
23
+ # object = mock()
24
+ # object.expects(:method_1).with(kind_of(Integer))
25
+ # object.method_1('string')
26
+ # # error raised, because method_1 was not called with a kind of Integer
27
+ def kind_of(klass)
28
+ KindOf.new(klass)
29
+ end
28
30
  end
29
31
 
30
32
  # Parameter matcher which matches when actual parameter is a kind of specified class.
31
33
  class KindOf
32
- include Base
34
+ include BaseMethods
33
35
 
34
36
  # @private
35
37
  def initialize(klass)
@@ -1,35 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mocha/parameter_matchers/base'
3
+ require 'mocha/parameter_matchers/base_methods'
4
4
 
5
5
  module Mocha
6
6
  module ParameterMatchers
7
- # Matches if +matcher+ does *not* match.
8
- #
9
- # @param [Base] matcher matcher whose logic to invert.
10
- # @return [Not] parameter matcher.
11
- #
12
- # @see Expectation#with
13
- #
14
- # @example Actual parameter does not include the value +1+.
15
- # object = mock()
16
- # object.expects(:method_1).with(Not(includes(1)))
17
- # object.method_1([0, 2, 3])
18
- # # no error raised
19
- #
20
- # @example Actual parameter does include the value +1+.
21
- # object = mock()
22
- # object.expects(:method_1).with(Not(includes(1)))
23
- # object.method_1([0, 1, 2, 3])
24
- # # error raised, because method_1 was not called with object not including 1
25
- #
26
- def Not(matcher) # rubocop:disable Naming/MethodName
27
- Not.new(matcher)
7
+ module Methods
8
+ # Matches if +matcher+ does *not* match.
9
+ #
10
+ # @param [BaseMethods] matcher matcher whose logic to invert.
11
+ # @return [Not] parameter matcher.
12
+ #
13
+ # @see Expectation#with
14
+ #
15
+ # @example Actual parameter does not include the value +1+.
16
+ # object = mock()
17
+ # object.expects(:method_1).with(Not(includes(1)))
18
+ # object.method_1([0, 2, 3])
19
+ # # no error raised
20
+ #
21
+ # @example Actual parameter does include the value +1+.
22
+ # object = mock()
23
+ # object.expects(:method_1).with(Not(includes(1)))
24
+ # object.method_1([0, 1, 2, 3])
25
+ # # error raised, because method_1 was not called with object not including 1
26
+ #
27
+ def Not(matcher) # rubocop:disable Naming/MethodName
28
+ Not.new(matcher)
29
+ end
28
30
  end
29
31
 
30
32
  # Parameter matcher which inverts the logic of the specified matcher using a logical NOT operation.
31
33
  class Not
32
- include Base
34
+ include BaseMethods
33
35
 
34
36
  # @private
35
37
  def initialize(matcher)
@@ -2,43 +2,45 @@
2
2
 
3
3
  module Mocha
4
4
  module ParameterMatchers
5
- # Matches optional parameters if available.
6
- #
7
- # @param [*Array<Base>] matchers matchers for optional parameters.
8
- # @return [Optionally] parameter matcher.
9
- #
10
- # @see Expectation#with
11
- #
12
- # @example Only the two required parameters are supplied and they both match their expected value.
13
- # object = mock()
14
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
15
- # object.method_1(1, 2)
16
- # # no error raised
17
- #
18
- # @example Both required parameters and one of the optional parameters are supplied and they all match their expected value.
19
- # object = mock()
20
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
21
- # object.method_1(1, 2, 3)
22
- # # no error raised
23
- #
24
- # @example Both required parameters and both of the optional parameters are supplied and they all match their expected value.
25
- # object = mock()
26
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
27
- # object.method_1(1, 2, 3, 4)
28
- # # no error raised
29
- #
30
- # @example One of the actual optional parameters does not match the expected value.
31
- # object = mock()
32
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
33
- # object.method_1(1, 2, 3, 5)
34
- # # error raised, because optional parameters did not match
35
- def optionally(*matchers)
36
- Optionally.new(*matchers)
5
+ module Methods
6
+ # Matches optional parameters if available.
7
+ #
8
+ # @param [*Array<BaseMethods>] matchers matchers for optional parameters.
9
+ # @return [Optionally] parameter matcher.
10
+ #
11
+ # @see Expectation#with
12
+ #
13
+ # @example Only the two required parameters are supplied and they both match their expected value.
14
+ # object = mock()
15
+ # object.expects(:method_1).with(1, 2, optionally(3, 4))
16
+ # object.method_1(1, 2)
17
+ # # no error raised
18
+ #
19
+ # @example Both required parameters and one of the optional parameters are supplied and they all match their expected value.
20
+ # object = mock()
21
+ # object.expects(:method_1).with(1, 2, optionally(3, 4))
22
+ # object.method_1(1, 2, 3)
23
+ # # no error raised
24
+ #
25
+ # @example Both required parameters and both of the optional parameters are supplied and they all match their expected value.
26
+ # object = mock()
27
+ # object.expects(:method_1).with(1, 2, optionally(3, 4))
28
+ # object.method_1(1, 2, 3, 4)
29
+ # # no error raised
30
+ #
31
+ # @example One of the actual optional parameters does not match the expected value.
32
+ # object = mock()
33
+ # object.expects(:method_1).with(1, 2, optionally(3, 4))
34
+ # object.method_1(1, 2, 3, 5)
35
+ # # error raised, because optional parameters did not match
36
+ def optionally(*matchers)
37
+ Optionally.new(*matchers)
38
+ end
37
39
  end
38
40
 
39
41
  # Parameter matcher which allows optional parameters to be specified.
40
42
  class Optionally
41
- include Base
43
+ include BaseMethods
42
44
 
43
45
  # @private
44
46
  def initialize(*parameters)
@@ -3,14 +3,14 @@
3
3
  require 'mocha/configuration'
4
4
  require 'mocha/deprecation'
5
5
  require 'mocha/ruby_version'
6
- require 'mocha/parameter_matchers/base'
6
+ require 'mocha/parameter_matchers/base_methods'
7
7
  require 'mocha/parameter_matchers/has_entries'
8
8
 
9
9
  module Mocha
10
10
  module ParameterMatchers
11
11
  # @private
12
12
  class PositionalOrKeywordHash
13
- include Base
13
+ include BaseMethods
14
14
 
15
15
  def initialize(expected_value, expectation, last_expected_value)
16
16
  @expected_value = expected_value
@@ -1,35 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mocha/parameter_matchers/base'
3
+ require 'mocha/parameter_matchers/base_methods'
4
4
 
5
5
  module Mocha
6
6
  module ParameterMatchers
7
- # Matches any object that matches +regexp+.
8
- #
9
- # @param [Regexp] regexp regular expression to match.
10
- # @return [RegexpMatches] parameter matcher.
11
- #
12
- # @see Expectation#with
13
- #
14
- # @example Actual parameter is matched by specified regular expression.
15
- # object = mock()
16
- # object.expects(:method_1).with(regexp_matches(/e/))
17
- # object.method_1('hello')
18
- # # no error raised
19
- #
20
- # @example Actual parameter is not matched by specified regular expression.
21
- # object = mock()
22
- # object.expects(:method_1).with(regexp_matches(/a/))
23
- # object.method_1('hello')
24
- # # error raised, because method_1 was not called with a parameter that matched the
25
- # # regular expression
26
- def regexp_matches(regexp)
27
- RegexpMatches.new(regexp)
7
+ module Methods
8
+ # Matches any object that matches +regexp+.
9
+ #
10
+ # @param [Regexp] regexp regular expression to match.
11
+ # @return [RegexpMatches] parameter matcher.
12
+ #
13
+ # @see Expectation#with
14
+ #
15
+ # @example Actual parameter is matched by specified regular expression.
16
+ # object = mock()
17
+ # object.expects(:method_1).with(regexp_matches(/e/))
18
+ # object.method_1('hello')
19
+ # # no error raised
20
+ #
21
+ # @example Actual parameter is not matched by specified regular expression.
22
+ # object = mock()
23
+ # object.expects(:method_1).with(regexp_matches(/a/))
24
+ # object.method_1('hello')
25
+ # # error raised, because method_1 was not called with a parameter that matched the
26
+ # # regular expression
27
+ def regexp_matches(regexp)
28
+ RegexpMatches.new(regexp)
29
+ end
28
30
  end
29
31
 
30
32
  # Parameter matcher which matches if specified regular expression matches actual paramter.
31
33
  class RegexpMatches
32
- include Base
34
+ include BaseMethods
33
35
 
34
36
  # @private
35
37
  def initialize(regexp)
@@ -1,63 +1,65 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mocha/parameter_matchers/base'
3
+ require 'mocha/parameter_matchers/base_methods'
4
4
  require 'mocha/parameter_matchers/all_of'
5
5
  require 'yaml'
6
6
 
7
7
  module Mocha
8
8
  module ParameterMatchers
9
- # @overload def responds_with(message, result)
10
- # Matches any object that responds to +message+ with +result+. To put it another way, it tests the quack, not the duck.
11
- # @param [Symbol] message method to invoke.
12
- # @param [Object] result expected result of sending +message+.
13
- # @overload def responds_with(messages_vs_results)
14
- # Matches any object that responds to all the messages with the corresponding results as specified by +messages_vs_results+.
15
- # @param [Hash<Symbol,Object>] messages_vs_results +Hash+ of messages vs results.
16
- # @raise [ArgumentError] if +messages_vs_results+ does not contain at least one entry.
17
- #
18
- # @return [RespondsWith] parameter matcher.
19
- #
20
- # @see Expectation#with
21
- #
22
- # @example Actual parameter responds with "FOO" when :upcase is invoked.
23
- # object = mock()
24
- # object.expects(:method_1).with(responds_with(:upcase, "FOO"))
25
- # object.method_1("foo")
26
- # # no error raised, because "foo".upcase == "FOO"
27
- #
28
- # @example Actual parameter does not respond with "FOO" when :upcase is invoked.
29
- # object = mock()
30
- # object.expects(:method_1).with(responds_with(:upcase, "BAR"))
31
- # object.method_1("foo")
32
- # # error raised, because "foo".upcase != "BAR"
33
- #
34
- # @example Actual parameter responds with "FOO" when :upcase is invoked and "oof" when :reverse is invoked.
35
- # object = mock()
36
- # object.expects(:method_1).with(responds_with(upcase: "FOO", reverse: "oof"))
37
- # object.method_1("foo")
38
- # # no error raised, because "foo".upcase == "FOO" and "foo".reverse == "oof"
39
- def responds_with(*options)
40
- case options.length
41
- when 0
42
- raise ArgumentError, 'No arguments. Expecting at least one.'
43
- when 1
44
- option = options.first
45
- raise ArgumentError, 'Argument is not a Hash.' unless option.is_a?(Hash)
46
- raise ArgumentError, 'Argument has no entries.' if option.empty?
9
+ module Methods
10
+ # @overload def responds_with(message, result)
11
+ # Matches any object that responds to +message+ with +result+. To put it another way, it tests the quack, not the duck.
12
+ # @param [Symbol] message method to invoke.
13
+ # @param [Object] result expected result of sending +message+.
14
+ # @overload def responds_with(messages_vs_results)
15
+ # Matches any object that responds to all the messages with the corresponding results as specified by +messages_vs_results+.
16
+ # @param [Hash<Symbol,Object>] messages_vs_results +Hash+ of messages vs results.
17
+ # @raise [ArgumentError] if +messages_vs_results+ does not contain at least one entry.
18
+ #
19
+ # @return [RespondsWith] parameter matcher.
20
+ #
21
+ # @see Expectation#with
22
+ #
23
+ # @example Actual parameter responds with "FOO" when :upcase is invoked.
24
+ # object = mock()
25
+ # object.expects(:method_1).with(responds_with(:upcase, "FOO"))
26
+ # object.method_1("foo")
27
+ # # no error raised, because "foo".upcase == "FOO"
28
+ #
29
+ # @example Actual parameter does not respond with "FOO" when :upcase is invoked.
30
+ # object = mock()
31
+ # object.expects(:method_1).with(responds_with(:upcase, "BAR"))
32
+ # object.method_1("foo")
33
+ # # error raised, because "foo".upcase != "BAR"
34
+ #
35
+ # @example Actual parameter responds with "FOO" when :upcase is invoked and "oof" when :reverse is invoked.
36
+ # object = mock()
37
+ # object.expects(:method_1).with(responds_with(upcase: "FOO", reverse: "oof"))
38
+ # object.method_1("foo")
39
+ # # no error raised, because "foo".upcase == "FOO" and "foo".reverse == "oof"
40
+ def responds_with(*options)
41
+ case options.length
42
+ when 0
43
+ raise ArgumentError, 'No arguments. Expecting at least one.'
44
+ when 1
45
+ option = options.first
46
+ raise ArgumentError, 'Argument is not a Hash.' unless option.is_a?(Hash)
47
+ raise ArgumentError, 'Argument has no entries.' if option.empty?
47
48
 
48
- matchers = option.map { |message, result| RespondsWith.new(message, result) }
49
- AllOf.new(*matchers)
50
- when 2
51
- message, result = options
52
- RespondsWith.new(message, result)
53
- else
54
- raise ArgumentError, 'Too many arguments; use either a single argument (must be a Hash) or two arguments (a message and a result).'
49
+ matchers = option.map { |message, result| RespondsWith.new(message, result) }
50
+ AllOf.new(*matchers)
51
+ when 2
52
+ message, result = options
53
+ RespondsWith.new(message, result)
54
+ else
55
+ raise ArgumentError, 'Too many arguments; use either a single argument (must be a Hash) or two arguments (a message and a result).'
56
+ end
55
57
  end
56
58
  end
57
59
 
58
60
  # Parameter matcher which matches if actual parameter returns expected result when specified method is invoked.
59
61
  class RespondsWith
60
- include Base
62
+ include BaseMethods
61
63
 
62
64
  # @private
63
65
  def initialize(message, result)
@@ -1,35 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mocha/parameter_matchers/base'
3
+ require 'mocha/parameter_matchers/base_methods'
4
4
  require 'yaml'
5
5
 
6
6
  module Mocha
7
7
  module ParameterMatchers
8
- # Matches any YAML that represents the specified +object+
9
- #
10
- # @param [Object] object object whose YAML to compare.
11
- # @return [YamlEquivalent] parameter matcher.
12
- #
13
- # @see Expectation#with
14
- #
15
- # @example Actual parameter is YAML equivalent of specified +object+.
16
- # object = mock()
17
- # object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
18
- # object.method_1("--- \n- 1\n- 2\n- 3\n")
19
- # # no error raised
20
- #
21
- # @example Actual parameter is not YAML equivalent of specified +object+.
22
- # object = mock()
23
- # object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
24
- # object.method_1("--- \n- 1\n- 2\n")
25
- # # error raised, because method_1 was not called with YAML representing the specified Array
26
- def yaml_equivalent(object)
27
- YamlEquivalent.new(object)
8
+ module Methods
9
+ # Matches any YAML that represents the specified +object+
10
+ #
11
+ # @param [Object] object object whose YAML to compare.
12
+ # @return [YamlEquivalent] parameter matcher.
13
+ #
14
+ # @see Expectation#with
15
+ #
16
+ # @example Actual parameter is YAML equivalent of specified +object+.
17
+ # object = mock()
18
+ # object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
19
+ # object.method_1("--- \n- 1\n- 2\n- 3\n")
20
+ # # no error raised
21
+ #
22
+ # @example Actual parameter is not YAML equivalent of specified +object+.
23
+ # object = mock()
24
+ # object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
25
+ # object.method_1("--- \n- 1\n- 2\n")
26
+ # # error raised, because method_1 was not called with YAML representing the specified Array
27
+ def yaml_equivalent(object)
28
+ YamlEquivalent.new(object)
29
+ end
28
30
  end
29
31
 
30
32
  # Parameter matcher which matches if actual parameter is YAML equivalent of specified object.
31
33
  class YamlEquivalent
32
- include Base
34
+ include BaseMethods
33
35
 
34
36
  # @private
35
37
  def initialize(object)
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mocha
4
- # Used as parameters for {Expectation#with} to restrict the parameter values which will match the expectation. Can be nested.
5
- module ParameterMatchers; end
4
+ # Matcher classes used as parameters for {Expectation#with} to restrict the parameter values which will match the expectation. Can be nested. Build matcher instances in tests using methods in {Methods}, e.g. {Methods#includes}.
5
+ module ParameterMatchers
6
+ # These methods build instances of the {ParameterMatchers} classes which are used with {Expectation#with} to restrict the parameter values. Can be nested, e.g. see {Methods#all_of} examples.
7
+ module Methods; end
8
+ end
6
9
  end
7
10
 
8
11
  require 'mocha/parameter_matchers/instance_methods'
@@ -83,7 +83,7 @@ module Mocha
83
83
  #
84
84
  # @param [String] unexpected_state_name name of unexpected state.
85
85
  # @return [StatePredicate] state predicate which, when queried, will indicate whether the {StateMachine} is *not* in the state specified by +unexpected_state_name+.
86
- def is_not(unexpected_state_name) # rubocop:disable Naming/PredicateName
86
+ def is_not(unexpected_state_name) # rubocop:disable Naming/PredicatePrefix
87
87
  StatePredicate.new(self, unexpected_state_name, 'is not') { |current, given| current != given }
88
88
  end
89
89
 
@@ -7,10 +7,10 @@ module Mocha
7
7
  class StubbedMethod
8
8
  PrependedModule = Class.new(Module)
9
9
 
10
- attr_reader :stubbee, :method_name
10
+ attr_reader :stubba_object, :method_name
11
11
 
12
- def initialize(stubbee, method_name)
13
- @stubbee = stubbee
12
+ def initialize(stubba_object, method_name)
13
+ @stubba_object = stubba_object
14
14
  @original_method = nil
15
15
  @original_visibility = nil
16
16
  @method_name = method_name.to_sym
@@ -30,11 +30,11 @@ module Mocha
30
30
  end
31
31
 
32
32
  def mock
33
- mock_owner.mocha
33
+ stubbee.mocha
34
34
  end
35
35
 
36
36
  def reset_mocha
37
- mock_owner.reset_mocha
37
+ stubbee.reset_mocha
38
38
  end
39
39
 
40
40
  def hide_original_method
@@ -61,14 +61,14 @@ module Mocha
61
61
  def matches?(other)
62
62
  return false unless other.instance_of?(self.class)
63
63
 
64
- (stubbee.object_id == other.stubbee.object_id) && # rubocop:disable Lint/IdentityComparison
64
+ (stubba_object.object_id == other.stubba_object.object_id) && # rubocop:disable Lint/IdentityComparison
65
65
  (method_name == other.method_name)
66
66
  end
67
67
 
68
68
  alias_method :==, :eql?
69
69
 
70
70
  def to_s
71
- "#{stubbee}.#{method_name}"
71
+ "#{stubba_object}.#{method_name}"
72
72
  end
73
73
 
74
74
  private
data/lib/mocha/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mocha
4
- VERSION = '3.0.0-rc.1'
4
+ VERSION = '3.0.0-rc.2'
5
5
  end
data/lib/mocha.rb CHANGED
@@ -2,5 +2,20 @@
2
2
 
3
3
  require 'mocha/version'
4
4
 
5
+ # Mocha's top level namespace, which also provides the ability to {.configure configure} Mocha's behavior.
6
+ #
7
+ # Methods in the {API} are directly available in +Test::Unit::TestCase+, +Minitest::Unit::TestCase+.
8
+ #
9
+ # The mock creation methods are {API#mock mock}, {API#stub stub} and {API#stub_everything stub_everything}, all of which return a {Mock}
10
+ #
11
+ # A {Mock} {Mock#expects expects} or {Mock#stubs stubs} a method, which sets up (returns) an {Expectation}.
12
+ #
13
+ # An {Expectation} can be further qualified through its {Expectation fluent interface}.
14
+ #
15
+ # {ParameterMatchers} for {Expectation#with} restrict the parameter values which will match the {Expectation}.
16
+ #
17
+ # Adapters in {Integration} provide built-in support for +Minitest+ and +Test::Unit+.
18
+ #
19
+ # Integration {Hooks} enable support for other test frameworks.
5
20
  module Mocha
6
21
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocha
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre.rc.1
4
+ version: 3.0.0.pre.rc.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Mead
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 2025-01-24 00:00:00.000000000 Z
11
+ date: 2025-11-11 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: ruby2_keywords
@@ -70,11 +71,13 @@ files:
70
71
  - lib/mocha/expectation_error_factory.rb
71
72
  - lib/mocha/expectation_list.rb
72
73
  - lib/mocha/hooks.rb
74
+ - lib/mocha/ignoring_warning.rb
73
75
  - lib/mocha/impersonating_any_instance_name.rb
74
76
  - lib/mocha/impersonating_name.rb
75
77
  - lib/mocha/in_state_ordering_constraint.rb
76
78
  - lib/mocha/inspect.rb
77
79
  - lib/mocha/instance_method.rb
80
+ - lib/mocha/integration.rb
78
81
  - lib/mocha/integration/assertion_counter.rb
79
82
  - lib/mocha/integration/minitest.rb
80
83
  - lib/mocha/integration/minitest/adapter.rb
@@ -97,7 +100,7 @@ files:
97
100
  - lib/mocha/parameter_matchers/any_of.rb
98
101
  - lib/mocha/parameter_matchers/any_parameters.rb
99
102
  - lib/mocha/parameter_matchers/anything.rb
100
- - lib/mocha/parameter_matchers/base.rb
103
+ - lib/mocha/parameter_matchers/base_methods.rb
101
104
  - lib/mocha/parameter_matchers/equals.rb
102
105
  - lib/mocha/parameter_matchers/equivalent_uri.rb
103
106
  - lib/mocha/parameter_matchers/has_entries.rb
@@ -143,6 +146,7 @@ metadata:
143
146
  homepage_uri: https://mocha.jamesmead.org
144
147
  source_code_uri: https://github.com/freerange/mocha
145
148
  rubygems_mfa_required: 'true'
149
+ post_install_message:
146
150
  rdoc_options: []
147
151
  require_paths:
148
152
  - lib
@@ -157,7 +161,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
161
  - !ruby/object:Gem::Version
158
162
  version: '0'
159
163
  requirements: []
160
- rubygems_version: 3.6.2
164
+ rubygems_version: 3.5.3
165
+ signing_key:
161
166
  specification_version: 4
162
167
  summary: Mocking and stubbing library
163
168
  test_files: []