mocha 0.10.5 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING.rdoc +1 -1
- data/README.rdoc +6 -4
- data/RELEASE.rdoc +12 -0
- data/Rakefile +29 -60
- data/doc/Mocha.html +112 -0
- data/doc/Mocha/API.html +898 -0
- data/doc/Mocha/ClassMethods.html +246 -0
- data/doc/Mocha/Configuration.html +471 -0
- data/doc/Mocha/Expectation.html +2570 -0
- data/doc/Mocha/Mock.html +830 -0
- data/doc/Mocha/ObjectMethods.html +668 -0
- data/doc/Mocha/ParameterMatchers.html +2715 -0
- data/doc/Mocha/ParameterMatchers/AllOf.html +137 -0
- data/doc/Mocha/ParameterMatchers/AnyOf.html +137 -0
- data/doc/Mocha/ParameterMatchers/AnyParameters.html +136 -0
- data/doc/Mocha/ParameterMatchers/Anything.html +136 -0
- data/doc/Mocha/ParameterMatchers/Base.html +419 -0
- data/doc/Mocha/ParameterMatchers/Equals.html +137 -0
- data/doc/Mocha/ParameterMatchers/HasEntries.html +137 -0
- data/doc/Mocha/ParameterMatchers/HasEntry.html +137 -0
- data/doc/Mocha/ParameterMatchers/HasKey.html +137 -0
- data/doc/Mocha/ParameterMatchers/HasValue.html +137 -0
- data/doc/Mocha/ParameterMatchers/Includes.html +137 -0
- data/doc/Mocha/ParameterMatchers/InstanceOf.html +137 -0
- data/doc/Mocha/ParameterMatchers/IsA.html +136 -0
- data/doc/Mocha/ParameterMatchers/KindOf.html +137 -0
- data/doc/Mocha/ParameterMatchers/Not.html +137 -0
- data/doc/Mocha/ParameterMatchers/Optionally.html +136 -0
- data/doc/Mocha/ParameterMatchers/QueryStringMatches.html +136 -0
- data/doc/Mocha/ParameterMatchers/RegexpMatches.html +137 -0
- data/doc/Mocha/ParameterMatchers/RespondsWith.html +137 -0
- data/doc/Mocha/ParameterMatchers/YamlEquivalent.html +137 -0
- data/doc/Mocha/Sequence.html +133 -0
- data/doc/Mocha/StateMachine.html +510 -0
- data/doc/Mocha/StateMachine/State.html +125 -0
- data/doc/Mocha/StateMachine/StatePredicate.html +125 -0
- data/doc/Mocha/StubbingError.html +134 -0
- data/doc/Mocha/UnexpectedInvocation.html +124 -0
- data/doc/_index.html +481 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file.COPYING.html +72 -0
- data/doc/file.MIT-LICENSE.html +86 -0
- data/doc/file.README.html +153 -0
- data/doc/file.RELEASE.html +933 -0
- data/doc/file.misc.html +108 -0
- data/doc/file.mocha.html +90 -0
- data/doc/file.stubba.html +129 -0
- data/doc/file_list.html +67 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +153 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +510 -0
- data/doc/top-level-namespace.html +105 -0
- data/lib/mocha/any_instance_method.rb +16 -11
- data/lib/mocha/api.rb +120 -106
- data/lib/mocha/argument_iterator.rb +6 -6
- data/lib/mocha/backtrace_filter.rb +1 -1
- data/lib/mocha/cardinality.rb +21 -21
- data/lib/mocha/central.rb +8 -8
- data/lib/mocha/change_state_side_effect.rb +5 -5
- data/lib/mocha/class_method.rb +14 -19
- data/lib/mocha/configuration.rb +47 -37
- data/lib/mocha/deprecation.rb +8 -8
- data/lib/mocha/exception_raiser.rb +7 -7
- data/lib/mocha/expectation.rb +173 -77
- data/lib/mocha/expectation_error.rb +2 -2
- data/lib/mocha/expectation_list.rb +11 -11
- data/lib/mocha/in_state_ordering_constraint.rb +5 -5
- data/lib/mocha/inspect.rb +8 -8
- data/lib/mocha/instance_method.rb +1 -17
- data/lib/mocha/integration.rb +9 -9
- data/lib/mocha/integration/mini_test/assertion_counter.rb +9 -9
- data/lib/mocha/integration/mini_test/exception_translation.rb +6 -6
- data/lib/mocha/integration/mini_test/version_13.rb +6 -6
- data/lib/mocha/integration/mini_test/version_140.rb +6 -6
- data/lib/mocha/integration/mini_test/version_141.rb +6 -6
- data/lib/mocha/integration/mini_test/version_142_to_172.rb +7 -7
- data/lib/mocha/integration/mini_test/version_200.rb +7 -7
- data/lib/mocha/integration/test_unit/assertion_counter.rb +10 -10
- data/lib/mocha/integration/test_unit/gem_version_200.rb +6 -6
- data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +6 -6
- data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +6 -6
- data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +6 -6
- data/lib/mocha/is_a.rb +1 -1
- data/lib/mocha/logger.rb +6 -6
- data/lib/mocha/method_matcher.rb +7 -7
- data/lib/mocha/mock.rb +85 -48
- data/lib/mocha/mockery.rb +47 -33
- data/lib/mocha/module_method.rb +2 -2
- data/lib/mocha/multiple_yields.rb +9 -9
- data/lib/mocha/names.rb +18 -18
- data/lib/mocha/no_yields.rb +7 -7
- data/lib/mocha/object.rb +104 -75
- data/lib/mocha/parameter_matchers.rb +3 -3
- data/lib/mocha/parameter_matchers/all_of.rb +22 -12
- data/lib/mocha/parameter_matchers/any_of.rb +23 -12
- data/lib/mocha/parameter_matchers/any_parameters.rb +15 -8
- data/lib/mocha/parameter_matchers/anything.rb +20 -11
- data/lib/mocha/parameter_matchers/base.rb +35 -27
- data/lib/mocha/parameter_matchers/equals.rb +23 -12
- data/lib/mocha/parameter_matchers/has_entries.rb +22 -12
- data/lib/mocha/parameter_matchers/has_entry.rb +31 -13
- data/lib/mocha/parameter_matchers/has_key.rb +21 -11
- data/lib/mocha/parameter_matchers/has_value.rb +21 -11
- data/lib/mocha/parameter_matchers/includes.rb +15 -5
- data/lib/mocha/parameter_matchers/instance_of.rb +23 -12
- data/lib/mocha/parameter_matchers/is_a.rb +23 -12
- data/lib/mocha/parameter_matchers/kind_of.rb +23 -12
- data/lib/mocha/parameter_matchers/not.rb +22 -12
- data/lib/mocha/parameter_matchers/object.rb +5 -3
- data/lib/mocha/parameter_matchers/optionally.rb +24 -12
- data/lib/mocha/parameter_matchers/query_string.rb +14 -3
- data/lib/mocha/parameter_matchers/regexp_matches.rb +21 -11
- data/lib/mocha/parameter_matchers/responds_with.rb +17 -6
- data/lib/mocha/parameter_matchers/yaml_equivalent.rb +16 -6
- data/lib/mocha/parameters_matcher.rb +8 -8
- data/lib/mocha/pretty_parameters.rb +7 -7
- data/lib/mocha/return_values.rb +11 -11
- data/lib/mocha/sequence.rb +23 -14
- data/lib/mocha/single_return_value.rb +7 -7
- data/lib/mocha/single_yield.rb +9 -9
- data/lib/mocha/standalone.rb +1 -1
- data/lib/mocha/state_machine.rb +61 -46
- data/lib/mocha/stubbing_error.rb +8 -5
- data/lib/mocha/thrower.rb +2 -2
- data/lib/mocha/unexpected_invocation.rb +9 -6
- data/lib/mocha/version.rb +1 -1
- data/lib/mocha/yield_parameters.rb +10 -10
- data/lib/mocha_standalone.rb +1 -1
- data/mocha.gemspec +4 -7
- data/test/acceptance/acceptance_test_helper.rb +10 -10
- data/test/acceptance/api_test.rb +20 -20
- data/test/acceptance/bug_18914_test.rb +12 -12
- data/test/acceptance/bug_21465_test.rb +6 -6
- data/test/acceptance/bug_21563_test.rb +5 -5
- data/test/acceptance/exception_rescue_test.rb +1 -1
- data/test/acceptance/expected_invocation_count_test.rb +17 -17
- data/test/acceptance/failure_messages_test.rb +13 -13
- data/test/acceptance/minitest_test.rb +39 -39
- data/test/acceptance/mocha_example_test.rb +26 -26
- data/test/acceptance/mocha_test_result_test.rb +13 -13
- data/test/acceptance/mock_test.rb +5 -5
- data/test/acceptance/mock_with_initializer_block_test.rb +5 -5
- data/test/acceptance/mocked_methods_dispatch_test.rb +4 -4
- data/test/acceptance/multiple_expectations_failure_message_test.rb +2 -2
- data/test/acceptance/optional_parameters_test.rb +5 -5
- data/test/acceptance/parameter_matcher_test.rb +18 -18
- data/test/acceptance/partial_mocks_test.rb +9 -9
- data/test/acceptance/raise_exception_test.rb +1 -1
- data/test/acceptance/return_value_test.rb +5 -5
- data/test/acceptance/sequence_test.rb +29 -29
- data/test/acceptance/states_test.rb +17 -17
- data/test/acceptance/stub_any_instance_method_test.rb +13 -13
- data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +7 -7
- data/test/acceptance/stub_everything_test.rb +5 -5
- data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +1 -1
- data/test/acceptance/stub_module_method_test.rb +17 -17
- data/test/acceptance/stub_test.rb +5 -5
- data/test/acceptance/stubba_example_test.rb +24 -24
- data/test/acceptance/stubba_test_result_test.rb +11 -11
- data/test/acceptance/stubbing_error_backtrace_test.rb +6 -6
- data/test/acceptance/stubbing_frozen_object_test.rb +88 -0
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +9 -9
- data/test/acceptance/stubbing_nil_test.rb +59 -0
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +13 -13
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +15 -15
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +14 -14
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +13 -13
- data/test/acceptance/stubbing_non_public_class_method_test.rb +12 -12
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +12 -12
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +9 -9
- data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +35 -0
- data/test/acceptance/throw_test.rb +1 -1
- data/test/deprecation_disabler.rb +1 -1
- data/test/execution_point.rb +7 -7
- data/test/method_definer.rb +1 -1
- data/test/mini_test_result.rb +21 -21
- data/test/simple_counter.rb +5 -5
- data/test/test_helper.rb +1 -1
- data/test/test_runner.rb +22 -24
- data/test/test_unit_result.rb +20 -0
- data/test/unit/any_instance_method_test.rb +28 -32
- data/test/unit/array_inspect_test.rb +3 -3
- data/test/unit/backtrace_filter_test.rb +3 -3
- data/test/unit/cardinality_test.rb +12 -12
- data/test/unit/central_test.rb +18 -18
- data/test/unit/change_state_side_effect_test.rb +12 -12
- data/test/unit/class_method_test.rb +33 -91
- data/test/unit/date_time_inspect_test.rb +4 -4
- data/test/unit/exception_raiser_test.rb +5 -5
- data/test/unit/expectation_list_test.rb +7 -7
- data/test/unit/expectation_test.rb +66 -66
- data/test/unit/hash_inspect_test.rb +4 -4
- data/test/unit/in_state_ordering_constraint_test.rb +13 -13
- data/test/unit/method_matcher_test.rb +3 -3
- data/test/unit/mock_test.rb +40 -40
- data/test/unit/mockery_test.rb +25 -25
- data/test/unit/multiple_yields_test.rb +2 -2
- data/test/unit/no_yields_test.rb +2 -2
- data/test/unit/object_inspect_test.rb +4 -4
- data/test/unit/object_test.rb +15 -15
- data/test/unit/parameter_matchers/all_of_test.rb +6 -6
- data/test/unit/parameter_matchers/any_of_test.rb +6 -6
- data/test/unit/parameter_matchers/anything_test.rb +5 -5
- data/test/unit/parameter_matchers/has_entries_test.rb +10 -10
- data/test/unit/parameter_matchers/has_entry_test.rb +13 -13
- data/test/unit/parameter_matchers/has_key_test.rb +11 -11
- data/test/unit/parameter_matchers/has_value_test.rb +12 -12
- data/test/unit/parameter_matchers/includes_test.rb +4 -4
- data/test/unit/parameter_matchers/not_test.rb +6 -6
- data/test/unit/parameter_matchers/regexp_matches_test.rb +9 -9
- data/test/unit/parameter_matchers/responds_with_test.rb +6 -6
- data/test/unit/parameter_matchers/stub_matcher.rb +4 -4
- data/test/unit/parameter_matchers/yaml_equivalent_test.rb +6 -6
- data/test/unit/parameters_matcher_test.rb +16 -16
- data/test/unit/return_values_test.rb +5 -5
- data/test/unit/sequence_test.rb +10 -10
- data/test/unit/single_return_value_test.rb +3 -3
- data/test/unit/single_yield_test.rb +2 -2
- data/test/unit/state_machine_test.rb +19 -19
- data/test/unit/string_inspect_test.rb +2 -2
- data/test/unit/thrower_test.rb +1 -1
- data/test/unit/yield_parameters_test.rb +11 -11
- metadata +113 -101
data/lib/mocha/return_values.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'mocha/single_return_value'
|
2
2
|
|
3
|
-
module Mocha
|
4
|
-
|
5
|
-
class ReturnValues
|
6
|
-
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
class ReturnValues
|
6
|
+
|
7
7
|
def self.build(*values)
|
8
8
|
new(*values.map { |value| SingleReturnValue.new(value) })
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
attr_accessor :values
|
12
|
-
|
12
|
+
|
13
13
|
def initialize(*values)
|
14
14
|
@values = values
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def next
|
18
18
|
case @values.length
|
19
19
|
when 0 then nil
|
@@ -21,11 +21,11 @@ module Mocha # :nodoc:
|
|
21
21
|
else @values.shift.evaluate
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def +(other)
|
26
26
|
self.class.new(*(@values + other.values))
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
end
|
30
|
-
|
31
|
-
end
|
30
|
+
|
31
|
+
end
|
data/lib/mocha/sequence.rb
CHANGED
@@ -1,42 +1,51 @@
|
|
1
|
-
module Mocha
|
2
|
-
|
1
|
+
module Mocha
|
2
|
+
|
3
|
+
# Used to constrain the order in which expectations can occur.
|
4
|
+
#
|
5
|
+
# @see API#sequence
|
6
|
+
# @see Expectation#in_sequence
|
3
7
|
class Sequence
|
4
|
-
|
8
|
+
|
9
|
+
# @private
|
5
10
|
class InSequenceOrderingConstraint
|
6
|
-
|
11
|
+
|
7
12
|
def initialize(sequence, index)
|
8
13
|
@sequence, @index = sequence, index
|
9
14
|
end
|
10
|
-
|
15
|
+
|
11
16
|
def allows_invocation_now?
|
12
17
|
@sequence.satisfied_to_index?(@index)
|
13
18
|
end
|
14
|
-
|
19
|
+
|
15
20
|
def mocha_inspect
|
16
21
|
"in sequence #{@sequence.mocha_inspect}"
|
17
22
|
end
|
18
|
-
|
23
|
+
|
19
24
|
end
|
20
|
-
|
25
|
+
|
26
|
+
# @private
|
21
27
|
def initialize(name)
|
22
28
|
@name = name
|
23
29
|
@expectations = []
|
24
30
|
end
|
25
|
-
|
31
|
+
|
32
|
+
# @private
|
26
33
|
def constrain_as_next_in_sequence(expectation)
|
27
34
|
index = @expectations.length
|
28
35
|
@expectations << expectation
|
29
36
|
expectation.add_ordering_constraint(InSequenceOrderingConstraint.new(self, index))
|
30
37
|
end
|
31
|
-
|
38
|
+
|
39
|
+
# @private
|
32
40
|
def satisfied_to_index?(index)
|
33
41
|
@expectations[0...index].all? { |expectation| expectation.satisfied? }
|
34
42
|
end
|
35
|
-
|
43
|
+
|
44
|
+
# @private
|
36
45
|
def mocha_inspect
|
37
46
|
"#{@name.mocha_inspect}"
|
38
47
|
end
|
39
|
-
|
48
|
+
|
40
49
|
end
|
41
|
-
|
42
|
-
end
|
50
|
+
|
51
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'mocha/is_a'
|
2
2
|
|
3
|
-
module Mocha
|
4
|
-
|
5
|
-
class SingleReturnValue
|
6
|
-
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
class SingleReturnValue
|
6
|
+
|
7
7
|
def initialize(value)
|
8
8
|
@value = value
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def evaluate
|
12
12
|
@value
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
end
|
data/lib/mocha/single_yield.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
module Mocha
|
2
|
-
|
3
|
-
class SingleYield
|
4
|
-
|
1
|
+
module Mocha
|
2
|
+
|
3
|
+
class SingleYield
|
4
|
+
|
5
5
|
attr_reader :parameters
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(*parameters)
|
8
8
|
@parameters = parameters
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def each
|
12
12
|
yield(@parameters)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
end
|
18
|
-
|
18
|
+
|
data/lib/mocha/standalone.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'mocha/api'
|
1
|
+
require 'mocha/api'
|
data/lib/mocha/state_machine.rb
CHANGED
@@ -1,91 +1,106 @@
|
|
1
|
-
module Mocha
|
1
|
+
module Mocha
|
2
2
|
|
3
3
|
# A state machine that is used to constrain the order of invocations.
|
4
|
-
# An invocation can be constrained to occur when a state is, or is_not, active.
|
4
|
+
# An invocation can be constrained to occur when a state {#is}, or {#is_not}, active.
|
5
5
|
class StateMachine
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
|
7
|
+
# Provides a mechanism to change the state of a {StateMachine} at some point in the future.
|
8
|
+
class State
|
9
|
+
|
10
|
+
# @private
|
9
11
|
def initialize(state_machine, state)
|
10
12
|
@state_machine, @state = state_machine, state
|
11
13
|
end
|
12
|
-
|
14
|
+
|
15
|
+
# @private
|
13
16
|
def activate
|
14
17
|
@state_machine.current_state = @state
|
15
18
|
end
|
16
|
-
|
19
|
+
|
20
|
+
# @private
|
17
21
|
def active?
|
18
22
|
@state_machine.current_state == @state
|
19
23
|
end
|
20
|
-
|
24
|
+
|
25
|
+
# @private
|
21
26
|
def mocha_inspect
|
22
27
|
"#{@state_machine.name} is #{@state.mocha_inspect}"
|
23
28
|
end
|
24
|
-
|
29
|
+
|
25
30
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
|
32
|
+
# Provides the ability to determine whether a {StateMachine} is in a specified state at some point in the future.
|
33
|
+
class StatePredicate
|
34
|
+
|
35
|
+
# @private
|
29
36
|
def initialize(state_machine, state)
|
30
37
|
@state_machine, @state = state_machine, state
|
31
38
|
end
|
32
|
-
|
39
|
+
|
40
|
+
# @private
|
33
41
|
def active?
|
34
42
|
@state_machine.current_state != @state
|
35
43
|
end
|
36
|
-
|
44
|
+
|
45
|
+
# @private
|
37
46
|
def mocha_inspect
|
38
47
|
"#{@state_machine.name} is not #{@state.mocha_inspect}"
|
39
48
|
end
|
40
|
-
|
49
|
+
|
41
50
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
51
|
+
|
52
|
+
# @private
|
53
|
+
attr_reader :name
|
54
|
+
|
55
|
+
# @private
|
56
|
+
attr_accessor :current_state
|
57
|
+
|
58
|
+
# @private
|
59
|
+
def initialize(name)
|
48
60
|
@name = name
|
49
61
|
@current_state = nil
|
50
62
|
end
|
51
|
-
|
52
|
-
#
|
63
|
+
|
64
|
+
# Put the {StateMachine} into the state specified by +initial_state_name+.
|
53
65
|
#
|
54
|
-
#
|
55
|
-
|
56
|
-
|
66
|
+
# @param [String] initial_state_name name of initial state
|
67
|
+
# @return [StateMachine] state machine, thereby allowing invocations of other {StateMachine} methods to be chained.
|
68
|
+
def starts_as(initial_state_name)
|
69
|
+
become(initial_state_name)
|
57
70
|
self
|
58
71
|
end
|
59
|
-
|
60
|
-
#
|
72
|
+
|
73
|
+
# Put the {StateMachine} into the +next_state_name+.
|
61
74
|
#
|
62
|
-
#
|
63
|
-
def become(
|
64
|
-
@current_state =
|
75
|
+
# @param [String] next_state_name name of new state
|
76
|
+
def become(next_state_name)
|
77
|
+
@current_state = next_state_name
|
65
78
|
end
|
66
|
-
|
67
|
-
#
|
79
|
+
|
80
|
+
# Provides a mechanism to change the {StateMachine} into the state specified by +state_name+ at some point in the future.
|
68
81
|
#
|
69
|
-
#
|
70
|
-
def is(state)
|
71
|
-
State.new(self, state)
|
72
|
-
end
|
73
|
-
|
74
|
-
# :call-seq: is_not(state)
|
82
|
+
# Or provides a mechanism to determine whether the {StateMachine} is in the state specified by +state_name+ at some point in the future.
|
75
83
|
#
|
76
|
-
#
|
77
|
-
|
78
|
-
|
84
|
+
# @param [String] state_name name of new state
|
85
|
+
# @return [State] state which, when activated, will change the {StateMachine} into the state with the specified +state_name+.
|
86
|
+
def is(state_name)
|
87
|
+
State.new(self, state_name)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Provides a mechanism to determine whether the {StateMachine} is not in the state specified by +state_name+ at some point in the future.
|
91
|
+
def is_not(state_name)
|
92
|
+
StatePredicate.new(self, state_name)
|
79
93
|
end
|
80
|
-
|
81
|
-
|
94
|
+
|
95
|
+
# @private
|
96
|
+
def mocha_inspect
|
82
97
|
if @current_state
|
83
98
|
"#{@name} is #{@current_state.mocha_inspect}"
|
84
99
|
else
|
85
100
|
"#{@name} has no current state"
|
86
101
|
end
|
87
102
|
end
|
88
|
-
|
103
|
+
|
89
104
|
end
|
90
105
|
|
91
|
-
end
|
106
|
+
end
|
data/lib/mocha/stubbing_error.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
require 'mocha/backtrace_filter'
|
2
2
|
|
3
|
-
module Mocha
|
4
|
-
|
5
|
-
# Exception raised when
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
# Exception raised when stubbing a particular method is not allowed.
|
6
|
+
#
|
7
|
+
# @see Configuration.prevent
|
6
8
|
class StubbingError < StandardError
|
7
9
|
|
8
|
-
|
10
|
+
# @private
|
11
|
+
def initialize(message = nil, backtrace = [])
|
9
12
|
super(message)
|
10
13
|
filter = BacktraceFilter.new
|
11
14
|
set_backtrace(filter.filtered(backtrace))
|
12
15
|
end
|
13
16
|
|
14
17
|
end
|
15
|
-
|
18
|
+
|
16
19
|
end
|
data/lib/mocha/thrower.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
-
module Mocha
|
1
|
+
module Mocha
|
2
2
|
|
3
|
+
# Exception raised when an unexpected method is invoked
|
3
4
|
class UnexpectedInvocation
|
4
|
-
|
5
|
+
|
6
|
+
# @private
|
5
7
|
def initialize(mock, symbol, *arguments)
|
6
8
|
@mock = mock
|
7
9
|
@method_matcher = MethodMatcher.new(symbol)
|
8
10
|
@parameters_matcher = ParametersMatcher.new(arguments)
|
9
11
|
end
|
10
|
-
|
12
|
+
|
13
|
+
# @private
|
11
14
|
def to_s
|
12
15
|
method_signature = "#{@mock.mocha_inspect}.#{@method_matcher.mocha_inspect}#{@parameters_matcher.mocha_inspect}"
|
13
16
|
"unexpected invocation: #{method_signature}\n"
|
14
17
|
end
|
15
|
-
|
18
|
+
|
16
19
|
end
|
17
|
-
|
18
|
-
end
|
20
|
+
|
21
|
+
end
|
data/lib/mocha/version.rb
CHANGED
@@ -2,14 +2,14 @@ require 'mocha/no_yields'
|
|
2
2
|
require 'mocha/single_yield'
|
3
3
|
require 'mocha/multiple_yields'
|
4
4
|
|
5
|
-
module Mocha
|
6
|
-
|
7
|
-
class YieldParameters
|
8
|
-
|
5
|
+
module Mocha
|
6
|
+
|
7
|
+
class YieldParameters
|
8
|
+
|
9
9
|
def initialize
|
10
10
|
@parameter_groups = []
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def next_invocation
|
14
14
|
case @parameter_groups.length
|
15
15
|
when 0 then NoYields.new
|
@@ -17,15 +17,15 @@ module Mocha # :nodoc:
|
|
17
17
|
else @parameter_groups.shift
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def add(*parameters)
|
22
22
|
@parameter_groups << SingleYield.new(*parameters)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def multiple_add(*parameter_groups)
|
26
26
|
@parameter_groups << MultipleYields.new(*parameter_groups)
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
end
|
30
|
-
|
31
|
-
end
|
30
|
+
|
31
|
+
end
|
data/lib/mocha_standalone.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'mocha/api'
|
2
|
-
require 'mocha/object'
|
2
|
+
require 'mocha/object'
|
data/mocha.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n") - ["TODO", ".travis.yml", ".gitignore"]
|
17
17
|
|
18
|
-
s.homepage = "http://
|
18
|
+
s.homepage = "http://floehopper.github.com/mocha/"
|
19
19
|
s.rdoc_options = ["--title", "Mocha", "--main", "README.rdoc", "--line-numbers"]
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
s.rubyforge_project = "mocha"
|
@@ -29,18 +29,15 @@ Gem::Specification.new do |s|
|
|
29
29
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
30
30
|
s.add_development_dependency("rake", ">= 0")
|
31
31
|
s.add_development_dependency("introspection", "~> 0.0.1")
|
32
|
-
s.add_development_dependency("
|
33
|
-
s.add_development_dependency("coderay", "~> 0.1")
|
32
|
+
s.add_development_dependency("yard")
|
34
33
|
else
|
35
34
|
s.add_dependency("rake", ">= 0")
|
36
35
|
s.add_dependency("introspection", "~> 0.0.1")
|
37
|
-
s.add_dependency("
|
38
|
-
s.add_dependency("coderay", "~> 0.1")
|
36
|
+
s.add_dependency("yard")
|
39
37
|
end
|
40
38
|
else
|
41
39
|
s.add_dependency("rake", ">= 0")
|
42
40
|
s.add_dependency("introspection", "~> 0.0.1")
|
43
|
-
s.add_dependency("
|
44
|
-
s.add_dependency("coderay", "~> 0.1")
|
41
|
+
s.add_dependency("yard")
|
45
42
|
end
|
46
43
|
end
|