mocha-macruby 0.9.8.20100129120100

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. data/COPYING +3 -0
  2. data/MIT-LICENSE +7 -0
  3. data/README +39 -0
  4. data/RELEASE +294 -0
  5. data/Rakefile +214 -0
  6. data/examples/misc.rb +43 -0
  7. data/examples/mocha.rb +25 -0
  8. data/examples/stubba.rb +64 -0
  9. data/lib/mocha.rb +3 -0
  10. data/lib/mocha/any_instance_method.rb +59 -0
  11. data/lib/mocha/api.rb +173 -0
  12. data/lib/mocha/argument_iterator.rb +21 -0
  13. data/lib/mocha/backtrace_filter.rb +17 -0
  14. data/lib/mocha/cardinality.rb +95 -0
  15. data/lib/mocha/central.rb +27 -0
  16. data/lib/mocha/change_state_side_effect.rb +19 -0
  17. data/lib/mocha/class_method.rb +117 -0
  18. data/lib/mocha/configuration.rb +79 -0
  19. data/lib/mocha/deprecation.rb +22 -0
  20. data/lib/mocha/exception_raiser.rb +17 -0
  21. data/lib/mocha/expectation.rb +476 -0
  22. data/lib/mocha/expectation_error.rb +15 -0
  23. data/lib/mocha/expectation_list.rb +50 -0
  24. data/lib/mocha/in_state_ordering_constraint.rb +19 -0
  25. data/lib/mocha/inspect.rb +67 -0
  26. data/lib/mocha/instance_method.rb +16 -0
  27. data/lib/mocha/integration.rb +38 -0
  28. data/lib/mocha/integration/mini_test.rb +21 -0
  29. data/lib/mocha/integration/mini_test/assertion_counter.rb +23 -0
  30. data/lib/mocha/integration/mini_test/version_131_and_above.rb +50 -0
  31. data/lib/mocha/integration/test_unit.rb +40 -0
  32. data/lib/mocha/integration/test_unit/assertion_counter.rb +23 -0
  33. data/lib/mocha/integration/test_unit/gem_version_200.rb +49 -0
  34. data/lib/mocha/integration/test_unit/gem_version_201_and_above.rb +49 -0
  35. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +48 -0
  36. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +50 -0
  37. data/lib/mocha/is_a.rb +9 -0
  38. data/lib/mocha/logger.rb +15 -0
  39. data/lib/mocha/metaclass.rb +13 -0
  40. data/lib/mocha/method_matcher.rb +21 -0
  41. data/lib/mocha/mock.rb +200 -0
  42. data/lib/mocha/mockery.rb +181 -0
  43. data/lib/mocha/module_method.rb +16 -0
  44. data/lib/mocha/multiple_yields.rb +20 -0
  45. data/lib/mocha/names.rb +53 -0
  46. data/lib/mocha/no_yields.rb +11 -0
  47. data/lib/mocha/object.rb +187 -0
  48. data/lib/mocha/parameter_matchers.rb +27 -0
  49. data/lib/mocha/parameter_matchers/all_of.rb +42 -0
  50. data/lib/mocha/parameter_matchers/any_of.rb +47 -0
  51. data/lib/mocha/parameter_matchers/any_parameters.rb +40 -0
  52. data/lib/mocha/parameter_matchers/anything.rb +33 -0
  53. data/lib/mocha/parameter_matchers/base.rb +15 -0
  54. data/lib/mocha/parameter_matchers/equals.rb +42 -0
  55. data/lib/mocha/parameter_matchers/has_entries.rb +45 -0
  56. data/lib/mocha/parameter_matchers/has_entry.rb +57 -0
  57. data/lib/mocha/parameter_matchers/has_key.rb +43 -0
  58. data/lib/mocha/parameter_matchers/has_value.rb +43 -0
  59. data/lib/mocha/parameter_matchers/includes.rb +41 -0
  60. data/lib/mocha/parameter_matchers/instance_of.rb +42 -0
  61. data/lib/mocha/parameter_matchers/is_a.rb +42 -0
  62. data/lib/mocha/parameter_matchers/kind_of.rb +42 -0
  63. data/lib/mocha/parameter_matchers/not.rb +42 -0
  64. data/lib/mocha/parameter_matchers/object.rb +15 -0
  65. data/lib/mocha/parameter_matchers/optionally.rb +55 -0
  66. data/lib/mocha/parameter_matchers/regexp_matches.rb +44 -0
  67. data/lib/mocha/parameter_matchers/responds_with.rb +43 -0
  68. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +43 -0
  69. data/lib/mocha/parameters_matcher.rb +37 -0
  70. data/lib/mocha/pretty_parameters.rb +28 -0
  71. data/lib/mocha/return_values.rb +31 -0
  72. data/lib/mocha/sequence.rb +42 -0
  73. data/lib/mocha/single_return_value.rb +17 -0
  74. data/lib/mocha/single_yield.rb +18 -0
  75. data/lib/mocha/standalone.rb +1 -0
  76. data/lib/mocha/state_machine.rb +91 -0
  77. data/lib/mocha/stubbing_error.rb +16 -0
  78. data/lib/mocha/unexpected_invocation.rb +18 -0
  79. data/lib/mocha/yield_parameters.rb +31 -0
  80. data/lib/mocha_standalone.rb +2 -0
  81. data/lib/stubba.rb +4 -0
  82. data/test/acceptance/acceptance_test_helper.rb +38 -0
  83. data/test/acceptance/api_test.rb +139 -0
  84. data/test/acceptance/bug_18914_test.rb +43 -0
  85. data/test/acceptance/bug_21465_test.rb +34 -0
  86. data/test/acceptance/bug_21563_test.rb +25 -0
  87. data/test/acceptance/expected_invocation_count_test.rb +196 -0
  88. data/test/acceptance/failure_messages_test.rb +64 -0
  89. data/test/acceptance/minitest_test.rb +153 -0
  90. data/test/acceptance/mocha_example_test.rb +98 -0
  91. data/test/acceptance/mocha_test_result_test.rb +84 -0
  92. data/test/acceptance/mock_test.rb +100 -0
  93. data/test/acceptance/mock_with_initializer_block_test.rb +51 -0
  94. data/test/acceptance/mocked_methods_dispatch_test.rb +78 -0
  95. data/test/acceptance/optional_parameters_test.rb +70 -0
  96. data/test/acceptance/parameter_matcher_test.rb +209 -0
  97. data/test/acceptance/partial_mocks_test.rb +47 -0
  98. data/test/acceptance/return_value_test.rb +52 -0
  99. data/test/acceptance/sequence_test.rb +186 -0
  100. data/test/acceptance/states_test.rb +70 -0
  101. data/test/acceptance/stub_any_instance_method_test.rb +195 -0
  102. data/test/acceptance/stub_class_method_test.rb +203 -0
  103. data/test/acceptance/stub_everything_test.rb +56 -0
  104. data/test/acceptance/stub_instance_method_test.rb +203 -0
  105. data/test/acceptance/stub_module_method_test.rb +163 -0
  106. data/test/acceptance/stub_test.rb +52 -0
  107. data/test/acceptance/stubba_example_test.rb +102 -0
  108. data/test/acceptance/stubba_test.rb +15 -0
  109. data/test/acceptance/stubba_test_result_test.rb +66 -0
  110. data/test/acceptance/stubbing_error_backtrace_test.rb +64 -0
  111. data/test/acceptance/stubbing_method_unnecessarily_test.rb +65 -0
  112. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +130 -0
  113. data/test/acceptance/stubbing_non_existent_class_method_test.rb +157 -0
  114. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +147 -0
  115. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +130 -0
  116. data/test/acceptance/stubbing_non_public_class_method_test.rb +163 -0
  117. data/test/acceptance/stubbing_non_public_instance_method_test.rb +143 -0
  118. data/test/acceptance/stubbing_on_non_mock_object_test.rb +64 -0
  119. data/test/deprecation_disabler.rb +15 -0
  120. data/test/execution_point.rb +36 -0
  121. data/test/method_definer.rb +24 -0
  122. data/test/simple_counter.rb +13 -0
  123. data/test/test_helper.rb +25 -0
  124. data/test/test_runner.rb +33 -0
  125. data/test/unit/any_instance_method_test.rb +126 -0
  126. data/test/unit/array_inspect_test.rb +16 -0
  127. data/test/unit/backtrace_filter_test.rb +19 -0
  128. data/test/unit/cardinality_test.rb +56 -0
  129. data/test/unit/central_test.rb +65 -0
  130. data/test/unit/change_state_side_effect_test.rb +41 -0
  131. data/test/unit/class_method_test.rb +295 -0
  132. data/test/unit/configuration_test.rb +38 -0
  133. data/test/unit/date_time_inspect_test.rb +21 -0
  134. data/test/unit/exception_raiser_test.rb +42 -0
  135. data/test/unit/expectation_list_test.rb +57 -0
  136. data/test/unit/expectation_test.rb +480 -0
  137. data/test/unit/hash_inspect_test.rb +16 -0
  138. data/test/unit/in_state_ordering_constraint_test.rb +43 -0
  139. data/test/unit/metaclass_test.rb +22 -0
  140. data/test/unit/method_matcher_test.rb +23 -0
  141. data/test/unit/mock_test.rb +302 -0
  142. data/test/unit/mockery_test.rb +149 -0
  143. data/test/unit/multiple_yields_test.rb +18 -0
  144. data/test/unit/no_yields_test.rb +18 -0
  145. data/test/unit/object_inspect_test.rb +37 -0
  146. data/test/unit/object_test.rb +82 -0
  147. data/test/unit/parameter_matchers/all_of_test.rb +26 -0
  148. data/test/unit/parameter_matchers/any_of_test.rb +26 -0
  149. data/test/unit/parameter_matchers/anything_test.rb +21 -0
  150. data/test/unit/parameter_matchers/equals_test.rb +25 -0
  151. data/test/unit/parameter_matchers/has_entries_test.rb +51 -0
  152. data/test/unit/parameter_matchers/has_entry_test.rb +82 -0
  153. data/test/unit/parameter_matchers/has_key_test.rb +55 -0
  154. data/test/unit/parameter_matchers/has_value_test.rb +57 -0
  155. data/test/unit/parameter_matchers/includes_test.rb +44 -0
  156. data/test/unit/parameter_matchers/instance_of_test.rb +25 -0
  157. data/test/unit/parameter_matchers/is_a_test.rb +25 -0
  158. data/test/unit/parameter_matchers/kind_of_test.rb +25 -0
  159. data/test/unit/parameter_matchers/not_test.rb +26 -0
  160. data/test/unit/parameter_matchers/regexp_matches_test.rb +46 -0
  161. data/test/unit/parameter_matchers/responds_with_test.rb +25 -0
  162. data/test/unit/parameter_matchers/stub_matcher.rb +27 -0
  163. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +25 -0
  164. data/test/unit/parameters_matcher_test.rb +121 -0
  165. data/test/unit/return_values_test.rb +63 -0
  166. data/test/unit/sequence_test.rb +104 -0
  167. data/test/unit/single_return_value_test.rb +14 -0
  168. data/test/unit/single_yield_test.rb +18 -0
  169. data/test/unit/state_machine_test.rb +98 -0
  170. data/test/unit/string_inspect_test.rb +11 -0
  171. data/test/unit/yield_parameters_test.rb +93 -0
  172. metadata +240 -0
@@ -0,0 +1,63 @@
1
+ require File.join(File.dirname(__FILE__), "..", "test_helper")
2
+
3
+ require 'mocha/return_values'
4
+
5
+ class ReturnValuesTest < Test::Unit::TestCase
6
+
7
+ include Mocha
8
+
9
+ def test_should_return_nil
10
+ values = ReturnValues.new
11
+ assert_nil values.next
12
+ end
13
+
14
+ def test_should_keep_returning_nil
15
+ values = ReturnValues.new
16
+ values.next
17
+ assert_nil values.next
18
+ assert_nil values.next
19
+ end
20
+
21
+ def test_should_return_evaluated_single_return_value
22
+ values = ReturnValues.new(SingleReturnValue.new('value'))
23
+ assert_equal 'value', values.next
24
+ end
25
+
26
+ def test_should_keep_returning_evaluated_single_return_value
27
+ values = ReturnValues.new(SingleReturnValue.new('value'))
28
+ values.next
29
+ assert_equal 'value', values.next
30
+ assert_equal 'value', values.next
31
+ end
32
+
33
+ def test_should_return_consecutive_evaluated_single_return_values
34
+ values = ReturnValues.new(SingleReturnValue.new('value_1'), SingleReturnValue.new('value_2'))
35
+ assert_equal 'value_1', values.next
36
+ assert_equal 'value_2', values.next
37
+ end
38
+
39
+ def test_should_keep_returning_last_of_consecutive_evaluated_single_return_values
40
+ values = ReturnValues.new(SingleReturnValue.new('value_1'), SingleReturnValue.new('value_2'))
41
+ values.next
42
+ values.next
43
+ assert_equal 'value_2', values.next
44
+ assert_equal 'value_2', values.next
45
+ end
46
+
47
+ def test_should_build_single_return_values_for_each_values
48
+ values = ReturnValues.build('value_1', 'value_2', 'value_3').values
49
+ assert_equal 'value_1', values[0].evaluate
50
+ assert_equal 'value_2', values[1].evaluate
51
+ assert_equal 'value_3', values[2].evaluate
52
+ end
53
+
54
+ def test_should_combine_two_sets_of_return_values
55
+ values_1 = ReturnValues.build('value_1')
56
+ values_2 = ReturnValues.build('value_2a', 'value_2b')
57
+ values = (values_1 + values_2).values
58
+ assert_equal 'value_1', values[0].evaluate
59
+ assert_equal 'value_2a', values[1].evaluate
60
+ assert_equal 'value_2b', values[2].evaluate
61
+ end
62
+
63
+ end
@@ -0,0 +1,104 @@
1
+ require File.join(File.dirname(__FILE__), "..", "test_helper")
2
+ require 'mocha/sequence'
3
+ require 'mocha/expectation'
4
+
5
+ class SequenceTest < Test::Unit::TestCase
6
+
7
+ include Mocha
8
+
9
+ class FakeExpectation
10
+
11
+ attr_reader :ordering_constraints
12
+
13
+ def initialize(satisfied = false)
14
+ @satisfied = satisfied
15
+ @ordering_constraints = []
16
+ end
17
+
18
+ def add_ordering_constraint(ordering_constraint)
19
+ @ordering_constraints << ordering_constraint
20
+ end
21
+
22
+ def satisfied?
23
+ @satisfied
24
+ end
25
+
26
+ end
27
+
28
+ def test_should_be_satisfied_if_no_expectations_added
29
+ sequence = Sequence.new('name')
30
+ assert sequence.satisfied_to_index?(0)
31
+ end
32
+
33
+ def test_should_be_satisfied_if_one_unsatisfied_expectations_added_but_it_is_not_included_by_index
34
+ sequence = Sequence.new('name')
35
+ expectation = FakeExpectation.new(satisfied = false)
36
+ sequence.constrain_as_next_in_sequence(expectation)
37
+ assert sequence.satisfied_to_index?(0)
38
+ end
39
+
40
+ def test_should_not_be_satisfied_if_one_unsatisfied_expectations_added_and_it_is_included_by_index
41
+ sequence = Sequence.new('name')
42
+ expectation = FakeExpectation.new(satisfied = false)
43
+ sequence.constrain_as_next_in_sequence(expectation)
44
+ assert !sequence.satisfied_to_index?(1)
45
+ end
46
+
47
+ def test_should_be_satisfied_if_one_satisfied_expectations_added_and_it_is_included_by_index
48
+ sequence = Sequence.new('name')
49
+ expectation = FakeExpectation.new(satisfied = true)
50
+ sequence.constrain_as_next_in_sequence(expectation)
51
+ assert sequence.satisfied_to_index?(1)
52
+ end
53
+
54
+ def test_should_not_be_satisfied_if_one_satisfied_and_one_unsatisfied_expectation_added_and_both_are_included_by_index
55
+ sequence = Sequence.new('name')
56
+ expectation_one = FakeExpectation.new(satisfied = true)
57
+ expectation_two = FakeExpectation.new(satisfied = false)
58
+ sequence.constrain_as_next_in_sequence(expectation_one)
59
+ sequence.constrain_as_next_in_sequence(expectation_two)
60
+ assert !sequence.satisfied_to_index?(2)
61
+ end
62
+
63
+ def test_should_be_satisfied_if_two_satisfied_expectations_added_and_both_are_included_by_index
64
+ sequence = Sequence.new('name')
65
+ expectation_one = FakeExpectation.new(satisfied = true)
66
+ expectation_two = FakeExpectation.new(satisfied = true)
67
+ sequence.constrain_as_next_in_sequence(expectation_one)
68
+ sequence.constrain_as_next_in_sequence(expectation_two)
69
+ assert sequence.satisfied_to_index?(2)
70
+ end
71
+
72
+ def test_should_add_ordering_constraint_to_expectation
73
+ sequence = Sequence.new('name')
74
+ expectation = FakeExpectation.new
75
+ sequence.constrain_as_next_in_sequence(expectation)
76
+ assert_equal 1, expectation.ordering_constraints.length
77
+ end
78
+
79
+ def test_should_not_allow_invocation_of_second_method_when_first_n_sequence_has_not_been_invoked
80
+ sequence = Sequence.new('name')
81
+ expectation_one = FakeExpectation.new(satisfied = false)
82
+ expectation_two = FakeExpectation.new(satisfied = false)
83
+ sequence.constrain_as_next_in_sequence(expectation_one)
84
+ sequence.constrain_as_next_in_sequence(expectation_two)
85
+ assert !expectation_two.ordering_constraints[0].allows_invocation_now?
86
+ end
87
+
88
+ def test_should_allow_invocation_of_second_method_when_first_in_sequence_has_been_invoked
89
+ sequence = Sequence.new('name')
90
+ expectation_one = FakeExpectation.new(satisfied = true)
91
+ expectation_two = FakeExpectation.new(satisfied = false)
92
+ sequence.constrain_as_next_in_sequence(expectation_one)
93
+ sequence.constrain_as_next_in_sequence(expectation_two)
94
+ assert expectation_two.ordering_constraints[0].allows_invocation_now?
95
+ end
96
+
97
+ def test_should_describe_ordering_constraint_as_being_part_of_named_sequence
98
+ sequence = Sequence.new('wibble')
99
+ expectation = FakeExpectation.new
100
+ sequence.constrain_as_next_in_sequence(expectation)
101
+ assert_equal "in sequence 'wibble'", expectation.ordering_constraints[0].mocha_inspect
102
+ end
103
+
104
+ end
@@ -0,0 +1,14 @@
1
+ require File.join(File.dirname(__FILE__), "..", "test_helper")
2
+
3
+ require 'mocha/single_return_value'
4
+
5
+ class SingleReturnValueTest < Test::Unit::TestCase
6
+
7
+ include Mocha
8
+
9
+ def test_should_return_value
10
+ value = SingleReturnValue.new('value')
11
+ assert_equal 'value', value.evaluate
12
+ end
13
+
14
+ end
@@ -0,0 +1,18 @@
1
+ require File.join(File.dirname(__FILE__), "..", "test_helper")
2
+
3
+ require 'mocha/single_yield'
4
+
5
+ class SingleYieldTest < Test::Unit::TestCase
6
+
7
+ include Mocha
8
+
9
+ def test_should_provide_parameters_for_single_yield_in_single_invocation
10
+ parameter_group = SingleYield.new(1, 2, 3)
11
+ parameter_groups = []
12
+ parameter_group.each do |parameters|
13
+ parameter_groups << parameters
14
+ end
15
+ assert_equal [[1, 2, 3]], parameter_groups
16
+ end
17
+
18
+ end
@@ -0,0 +1,98 @@
1
+ require File.join(File.dirname(__FILE__), "..", "test_helper")
2
+
3
+ require 'mocha/state_machine'
4
+
5
+ class StateMachineTest < Test::Unit::TestCase
6
+
7
+ include Mocha
8
+
9
+ def test_should_initially_be_in_no_state
10
+ state_machine = StateMachine.new('name')
11
+ any_state.each do |state|
12
+ assert !state_machine.is(state).active?
13
+ assert state_machine.is_not(state).active?
14
+ end
15
+ end
16
+
17
+ def test_should_be_able_to_enter_a_state
18
+ state_machine = StateMachine.new('name')
19
+ state = 'A'
20
+ other_states = any_state.reject { |s| s == state }
21
+
22
+ state_machine.is(state).activate
23
+
24
+ assert state_machine.is(state).active?
25
+ assert !state_machine.is_not(state).active?
26
+ other_states.each do |s|
27
+ assert !state_machine.is(s).active?
28
+ assert state_machine.is_not(s).active?
29
+ end
30
+ end
31
+
32
+ def test_should_be_able_to_change_state
33
+ state_machine = StateMachine.new('name')
34
+ state = 'B'
35
+ other_states = any_state.reject { |s| s == state }
36
+
37
+ state_machine.is('A').activate
38
+ state_machine.is(state).activate
39
+
40
+ assert state_machine.is(state).active?
41
+ assert !state_machine.is_not(state).active?
42
+ other_states.each do |s|
43
+ assert !state_machine.is(s).active?
44
+ assert state_machine.is_not(s).active?
45
+ end
46
+ end
47
+
48
+ def test_should_be_put_into_an_initial_state
49
+ state_machine = StateMachine.new('name')
50
+ initial_state = 'A'
51
+ other_states = any_state.reject { |s| s == initial_state }
52
+
53
+ state_machine.starts_as(initial_state)
54
+
55
+ assert state_machine.is(initial_state).active?
56
+ assert !state_machine.is_not(initial_state).active?
57
+ other_states.each do |state|
58
+ assert !state_machine.is(state).active?
59
+ assert state_machine.is_not(state).active?
60
+ end
61
+ end
62
+
63
+ def test_should_be_put_into_a_new_state
64
+ next_state = 'B'
65
+
66
+ other_states = any_state.reject { |s| s == next_state }
67
+ state_machine = StateMachine.new('name').starts_as('A')
68
+
69
+ state_machine.become(next_state)
70
+
71
+ assert state_machine.is(next_state).active?
72
+ assert !state_machine.is_not(next_state).active?
73
+ other_states.each do |state|
74
+ assert !state_machine.is(state).active?
75
+ assert state_machine.is_not(state).active?
76
+ end
77
+ end
78
+
79
+ def test_should_describe_itself_as_name_and_current_state
80
+ state_machine = StateMachine.new('state_machine_name')
81
+ assert_equal 'state_machine_name has no current state', state_machine.mocha_inspect
82
+ inspectable_state = Class.new { define_method(:mocha_inspect) { "'inspectable_state'" } }.new
83
+ state_machine.is(inspectable_state).activate
84
+ assert_equal "state_machine_name is 'inspectable_state'", state_machine.mocha_inspect
85
+ end
86
+
87
+ def test_should_have_self_describing_states
88
+ state_machine = StateMachine.new('state_machine_name')
89
+ inspectable_state = Class.new { define_method(:mocha_inspect) { "'inspectable_state'" } }.new
90
+ assert_equal "state_machine_name is 'inspectable_state'", state_machine.is(inspectable_state).mocha_inspect
91
+ assert_equal "state_machine_name is not 'inspectable_state'", state_machine.is_not(inspectable_state).mocha_inspect
92
+ end
93
+
94
+ def any_state
95
+ %w(A B C D)
96
+ end
97
+
98
+ end
@@ -0,0 +1,11 @@
1
+ require File.join(File.dirname(__FILE__), "..", "test_helper")
2
+ require 'mocha/inspect'
3
+
4
+ class StringInspectTest < Test::Unit::TestCase
5
+
6
+ def test_should_replace_escaped_quotes_with_single_quote
7
+ string = "my_string"
8
+ assert_equal "'my_string'", string.mocha_inspect
9
+ end
10
+
11
+ end
@@ -0,0 +1,93 @@
1
+ require File.join(File.dirname(__FILE__), "..", "test_helper")
2
+
3
+ require 'mocha/yield_parameters'
4
+ require 'mocha/no_yields'
5
+ require 'mocha/single_yield'
6
+ require 'mocha/multiple_yields'
7
+
8
+ class YieldParametersTest < Test::Unit::TestCase
9
+
10
+ include Mocha
11
+
12
+ def test_should_return_null_yield_parameter_group_by_default
13
+ yield_parameters = YieldParameters.new
14
+ assert yield_parameters.next_invocation.is_a?(NoYields)
15
+ end
16
+
17
+ def test_should_return_single_yield_parameter_group
18
+ yield_parameters = YieldParameters.new
19
+ yield_parameters.add(1, 2, 3)
20
+ parameter_group = yield_parameters.next_invocation
21
+ assert parameter_group.is_a?(SingleYield)
22
+ assert_equal [1, 2, 3], parameter_group.parameters
23
+ end
24
+
25
+ def test_should_keep_returning_single_yield_parameter_group
26
+ yield_parameters = YieldParameters.new
27
+ yield_parameters.add(1, 2, 3)
28
+ yield_parameters.next_invocation
29
+ parameter_group = yield_parameters.next_invocation
30
+ assert parameter_group.is_a?(SingleYield)
31
+ assert_equal [1, 2, 3], parameter_group.parameters
32
+ parameter_group = yield_parameters.next_invocation
33
+ assert parameter_group.is_a?(SingleYield)
34
+ assert_equal [1, 2, 3], parameter_group.parameters
35
+ end
36
+
37
+ def test_should_return_consecutive_single_yield_parameter_groups
38
+ yield_parameters = YieldParameters.new
39
+ yield_parameters.add(1, 2, 3)
40
+ yield_parameters.add(4, 5)
41
+ parameter_group = yield_parameters.next_invocation
42
+ assert parameter_group.is_a?(SingleYield)
43
+ assert_equal [1, 2, 3], parameter_group.parameters
44
+ parameter_group = yield_parameters.next_invocation
45
+ assert parameter_group.is_a?(SingleYield)
46
+ assert_equal [4, 5], parameter_group.parameters
47
+ end
48
+
49
+ def test_should_return_multiple_yield_parameter_group
50
+ yield_parameters = YieldParameters.new
51
+ yield_parameters.multiple_add([1, 2, 3], [4, 5])
52
+ parameter_group = yield_parameters.next_invocation
53
+ assert parameter_group.is_a?(MultipleYields)
54
+ assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
55
+ end
56
+
57
+ def test_should_keep_returning_multiple_yield_parameter_group
58
+ yield_parameters = YieldParameters.new
59
+ yield_parameters.multiple_add([1, 2, 3], [4, 5])
60
+ yield_parameters.next_invocation
61
+ parameter_group = yield_parameters.next_invocation
62
+ assert parameter_group.is_a?(MultipleYields)
63
+ assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
64
+ parameter_group = yield_parameters.next_invocation
65
+ assert parameter_group.is_a?(MultipleYields)
66
+ assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
67
+ end
68
+
69
+ def test_should_return_consecutive_multiple_yield_parameter_groups
70
+ yield_parameters = YieldParameters.new
71
+ yield_parameters.multiple_add([1, 2, 3], [4, 5])
72
+ yield_parameters.multiple_add([6, 7], [8, 9, 0])
73
+ parameter_group = yield_parameters.next_invocation
74
+ assert parameter_group.is_a?(MultipleYields)
75
+ assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
76
+ parameter_group = yield_parameters.next_invocation
77
+ assert parameter_group.is_a?(MultipleYields)
78
+ assert_equal [[6, 7], [8, 9, 0]], parameter_group.parameter_groups
79
+ end
80
+
81
+ def test_should_return_consecutive_single_and_multiple_yield_parameter_groups
82
+ yield_parameters = YieldParameters.new
83
+ yield_parameters.add(1, 2, 3)
84
+ yield_parameters.multiple_add([4, 5, 6], [7, 8])
85
+ parameter_group = yield_parameters.next_invocation
86
+ assert parameter_group.is_a?(SingleYield)
87
+ assert_equal [1, 2, 3], parameter_group.parameters
88
+ parameter_group = yield_parameters.next_invocation
89
+ assert parameter_group.is_a?(MultipleYields)
90
+ assert_equal [[4, 5, 6], [7, 8]], parameter_group.parameter_groups
91
+ end
92
+
93
+ end
metadata ADDED
@@ -0,0 +1,240 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mocha-macruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.8.20100129120100
5
+ platform: ruby
6
+ authors:
7
+ - James Mead
8
+ - Eloy Duran
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-09-18 00:00:00 +02:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rake
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ version:
26
+ description: " Mocking and stubbing library with JMock/SchMock syntax, which allows mocking and stubbing of methods on real (non-mock) classes.\n"
27
+ email: mocha-developer@googlegroups.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - README
34
+ - COPYING
35
+ files:
36
+ - lib/mocha/any_instance_method.rb
37
+ - lib/mocha/api.rb
38
+ - lib/mocha/argument_iterator.rb
39
+ - lib/mocha/backtrace_filter.rb
40
+ - lib/mocha/cardinality.rb
41
+ - lib/mocha/central.rb
42
+ - lib/mocha/change_state_side_effect.rb
43
+ - lib/mocha/class_method.rb
44
+ - lib/mocha/configuration.rb
45
+ - lib/mocha/deprecation.rb
46
+ - lib/mocha/exception_raiser.rb
47
+ - lib/mocha/expectation.rb
48
+ - lib/mocha/expectation_error.rb
49
+ - lib/mocha/expectation_list.rb
50
+ - lib/mocha/in_state_ordering_constraint.rb
51
+ - lib/mocha/inspect.rb
52
+ - lib/mocha/instance_method.rb
53
+ - lib/mocha/integration/mini_test/assertion_counter.rb
54
+ - lib/mocha/integration/mini_test/version_131_and_above.rb
55
+ - lib/mocha/integration/mini_test.rb
56
+ - lib/mocha/integration/test_unit/assertion_counter.rb
57
+ - lib/mocha/integration/test_unit/gem_version_200.rb
58
+ - lib/mocha/integration/test_unit/gem_version_201_and_above.rb
59
+ - lib/mocha/integration/test_unit/ruby_version_185_and_below.rb
60
+ - lib/mocha/integration/test_unit/ruby_version_186_and_above.rb
61
+ - lib/mocha/integration/test_unit.rb
62
+ - lib/mocha/integration.rb
63
+ - lib/mocha/is_a.rb
64
+ - lib/mocha/logger.rb
65
+ - lib/mocha/metaclass.rb
66
+ - lib/mocha/method_matcher.rb
67
+ - lib/mocha/mock.rb
68
+ - lib/mocha/mockery.rb
69
+ - lib/mocha/module_method.rb
70
+ - lib/mocha/multiple_yields.rb
71
+ - lib/mocha/names.rb
72
+ - lib/mocha/no_yields.rb
73
+ - lib/mocha/object.rb
74
+ - lib/mocha/parameter_matchers/all_of.rb
75
+ - lib/mocha/parameter_matchers/any_of.rb
76
+ - lib/mocha/parameter_matchers/any_parameters.rb
77
+ - lib/mocha/parameter_matchers/anything.rb
78
+ - lib/mocha/parameter_matchers/base.rb
79
+ - lib/mocha/parameter_matchers/equals.rb
80
+ - lib/mocha/parameter_matchers/has_entries.rb
81
+ - lib/mocha/parameter_matchers/has_entry.rb
82
+ - lib/mocha/parameter_matchers/has_key.rb
83
+ - lib/mocha/parameter_matchers/has_value.rb
84
+ - lib/mocha/parameter_matchers/includes.rb
85
+ - lib/mocha/parameter_matchers/instance_of.rb
86
+ - lib/mocha/parameter_matchers/is_a.rb
87
+ - lib/mocha/parameter_matchers/kind_of.rb
88
+ - lib/mocha/parameter_matchers/not.rb
89
+ - lib/mocha/parameter_matchers/object.rb
90
+ - lib/mocha/parameter_matchers/optionally.rb
91
+ - lib/mocha/parameter_matchers/regexp_matches.rb
92
+ - lib/mocha/parameter_matchers/responds_with.rb
93
+ - lib/mocha/parameter_matchers/yaml_equivalent.rb
94
+ - lib/mocha/parameter_matchers.rb
95
+ - lib/mocha/parameters_matcher.rb
96
+ - lib/mocha/pretty_parameters.rb
97
+ - lib/mocha/return_values.rb
98
+ - lib/mocha/sequence.rb
99
+ - lib/mocha/single_return_value.rb
100
+ - lib/mocha/single_yield.rb
101
+ - lib/mocha/standalone.rb
102
+ - lib/mocha/state_machine.rb
103
+ - lib/mocha/stubbing_error.rb
104
+ - lib/mocha/unexpected_invocation.rb
105
+ - lib/mocha/yield_parameters.rb
106
+ - lib/mocha.rb
107
+ - lib/mocha_standalone.rb
108
+ - lib/stubba.rb
109
+ - test/acceptance/acceptance_test_helper.rb
110
+ - test/acceptance/api_test.rb
111
+ - test/acceptance/bug_18914_test.rb
112
+ - test/acceptance/bug_21465_test.rb
113
+ - test/acceptance/bug_21563_test.rb
114
+ - test/acceptance/expected_invocation_count_test.rb
115
+ - test/acceptance/failure_messages_test.rb
116
+ - test/acceptance/minitest_test.rb
117
+ - test/acceptance/mocha_example_test.rb
118
+ - test/acceptance/mocha_test_result_test.rb
119
+ - test/acceptance/mock_test.rb
120
+ - test/acceptance/mock_with_initializer_block_test.rb
121
+ - test/acceptance/mocked_methods_dispatch_test.rb
122
+ - test/acceptance/optional_parameters_test.rb
123
+ - test/acceptance/parameter_matcher_test.rb
124
+ - test/acceptance/partial_mocks_test.rb
125
+ - test/acceptance/return_value_test.rb
126
+ - test/acceptance/sequence_test.rb
127
+ - test/acceptance/states_test.rb
128
+ - test/acceptance/stub_any_instance_method_test.rb
129
+ - test/acceptance/stub_class_method_test.rb
130
+ - test/acceptance/stub_everything_test.rb
131
+ - test/acceptance/stub_instance_method_test.rb
132
+ - test/acceptance/stub_module_method_test.rb
133
+ - test/acceptance/stub_test.rb
134
+ - test/acceptance/stubba_example_test.rb
135
+ - test/acceptance/stubba_test.rb
136
+ - test/acceptance/stubba_test_result_test.rb
137
+ - test/acceptance/stubbing_error_backtrace_test.rb
138
+ - test/acceptance/stubbing_method_unnecessarily_test.rb
139
+ - test/acceptance/stubbing_non_existent_any_instance_method_test.rb
140
+ - test/acceptance/stubbing_non_existent_class_method_test.rb
141
+ - test/acceptance/stubbing_non_existent_instance_method_test.rb
142
+ - test/acceptance/stubbing_non_public_any_instance_method_test.rb
143
+ - test/acceptance/stubbing_non_public_class_method_test.rb
144
+ - test/acceptance/stubbing_non_public_instance_method_test.rb
145
+ - test/acceptance/stubbing_on_non_mock_object_test.rb
146
+ - test/deprecation_disabler.rb
147
+ - test/execution_point.rb
148
+ - test/method_definer.rb
149
+ - test/simple_counter.rb
150
+ - test/test_helper.rb
151
+ - test/test_runner.rb
152
+ - test/unit/any_instance_method_test.rb
153
+ - test/unit/array_inspect_test.rb
154
+ - test/unit/backtrace_filter_test.rb
155
+ - test/unit/cardinality_test.rb
156
+ - test/unit/central_test.rb
157
+ - test/unit/change_state_side_effect_test.rb
158
+ - test/unit/class_method_test.rb
159
+ - test/unit/configuration_test.rb
160
+ - test/unit/date_time_inspect_test.rb
161
+ - test/unit/exception_raiser_test.rb
162
+ - test/unit/expectation_list_test.rb
163
+ - test/unit/expectation_test.rb
164
+ - test/unit/hash_inspect_test.rb
165
+ - test/unit/in_state_ordering_constraint_test.rb
166
+ - test/unit/metaclass_test.rb
167
+ - test/unit/method_matcher_test.rb
168
+ - test/unit/mock_test.rb
169
+ - test/unit/mockery_test.rb
170
+ - test/unit/multiple_yields_test.rb
171
+ - test/unit/no_yields_test.rb
172
+ - test/unit/object_inspect_test.rb
173
+ - test/unit/object_test.rb
174
+ - test/unit/parameter_matchers/all_of_test.rb
175
+ - test/unit/parameter_matchers/any_of_test.rb
176
+ - test/unit/parameter_matchers/anything_test.rb
177
+ - test/unit/parameter_matchers/equals_test.rb
178
+ - test/unit/parameter_matchers/has_entries_test.rb
179
+ - test/unit/parameter_matchers/has_entry_test.rb
180
+ - test/unit/parameter_matchers/has_key_test.rb
181
+ - test/unit/parameter_matchers/has_value_test.rb
182
+ - test/unit/parameter_matchers/includes_test.rb
183
+ - test/unit/parameter_matchers/instance_of_test.rb
184
+ - test/unit/parameter_matchers/is_a_test.rb
185
+ - test/unit/parameter_matchers/kind_of_test.rb
186
+ - test/unit/parameter_matchers/not_test.rb
187
+ - test/unit/parameter_matchers/regexp_matches_test.rb
188
+ - test/unit/parameter_matchers/responds_with_test.rb
189
+ - test/unit/parameter_matchers/stub_matcher.rb
190
+ - test/unit/parameter_matchers/yaml_equivalent_test.rb
191
+ - test/unit/parameters_matcher_test.rb
192
+ - test/unit/return_values_test.rb
193
+ - test/unit/sequence_test.rb
194
+ - test/unit/single_return_value_test.rb
195
+ - test/unit/single_yield_test.rb
196
+ - test/unit/state_machine_test.rb
197
+ - test/unit/string_inspect_test.rb
198
+ - test/unit/yield_parameters_test.rb
199
+ - examples/misc.rb
200
+ - examples/mocha.rb
201
+ - examples/stubba.rb
202
+ - COPYING
203
+ - MIT-LICENSE
204
+ - Rakefile
205
+ - README
206
+ - RELEASE
207
+ has_rdoc: true
208
+ homepage: http://github.com/alloy/mocha/tree/macruby
209
+ licenses: []
210
+
211
+ post_install_message:
212
+ rdoc_options:
213
+ - --title
214
+ - Mocha
215
+ - --main
216
+ - README
217
+ - --line-numbers
218
+ require_paths:
219
+ - lib
220
+ required_ruby_version: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - ">="
223
+ - !ruby/object:Gem::Version
224
+ version: "0"
225
+ version:
226
+ required_rubygems_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: "0"
231
+ version:
232
+ requirements: []
233
+
234
+ rubyforge_project: mocha
235
+ rubygems_version: 1.3.5
236
+ signing_key:
237
+ specification_version: 3
238
+ summary: Mocking and stubbing library
239
+ test_files: []
240
+