mocha 0.10.5 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/COPYING.rdoc +1 -1
  2. data/README.rdoc +6 -4
  3. data/RELEASE.rdoc +12 -0
  4. data/Rakefile +29 -60
  5. data/doc/Mocha.html +112 -0
  6. data/doc/Mocha/API.html +898 -0
  7. data/doc/Mocha/ClassMethods.html +246 -0
  8. data/doc/Mocha/Configuration.html +471 -0
  9. data/doc/Mocha/Expectation.html +2570 -0
  10. data/doc/Mocha/Mock.html +830 -0
  11. data/doc/Mocha/ObjectMethods.html +668 -0
  12. data/doc/Mocha/ParameterMatchers.html +2715 -0
  13. data/doc/Mocha/ParameterMatchers/AllOf.html +137 -0
  14. data/doc/Mocha/ParameterMatchers/AnyOf.html +137 -0
  15. data/doc/Mocha/ParameterMatchers/AnyParameters.html +136 -0
  16. data/doc/Mocha/ParameterMatchers/Anything.html +136 -0
  17. data/doc/Mocha/ParameterMatchers/Base.html +419 -0
  18. data/doc/Mocha/ParameterMatchers/Equals.html +137 -0
  19. data/doc/Mocha/ParameterMatchers/HasEntries.html +137 -0
  20. data/doc/Mocha/ParameterMatchers/HasEntry.html +137 -0
  21. data/doc/Mocha/ParameterMatchers/HasKey.html +137 -0
  22. data/doc/Mocha/ParameterMatchers/HasValue.html +137 -0
  23. data/doc/Mocha/ParameterMatchers/Includes.html +137 -0
  24. data/doc/Mocha/ParameterMatchers/InstanceOf.html +137 -0
  25. data/doc/Mocha/ParameterMatchers/IsA.html +136 -0
  26. data/doc/Mocha/ParameterMatchers/KindOf.html +137 -0
  27. data/doc/Mocha/ParameterMatchers/Not.html +137 -0
  28. data/doc/Mocha/ParameterMatchers/Optionally.html +136 -0
  29. data/doc/Mocha/ParameterMatchers/QueryStringMatches.html +136 -0
  30. data/doc/Mocha/ParameterMatchers/RegexpMatches.html +137 -0
  31. data/doc/Mocha/ParameterMatchers/RespondsWith.html +137 -0
  32. data/doc/Mocha/ParameterMatchers/YamlEquivalent.html +137 -0
  33. data/doc/Mocha/Sequence.html +133 -0
  34. data/doc/Mocha/StateMachine.html +510 -0
  35. data/doc/Mocha/StateMachine/State.html +125 -0
  36. data/doc/Mocha/StateMachine/StatePredicate.html +125 -0
  37. data/doc/Mocha/StubbingError.html +134 -0
  38. data/doc/Mocha/UnexpectedInvocation.html +124 -0
  39. data/doc/_index.html +481 -0
  40. data/doc/class_list.html +47 -0
  41. data/doc/css/common.css +1 -0
  42. data/doc/css/full_list.css +55 -0
  43. data/doc/css/style.css +322 -0
  44. data/doc/file.COPYING.html +72 -0
  45. data/doc/file.MIT-LICENSE.html +86 -0
  46. data/doc/file.README.html +153 -0
  47. data/doc/file.RELEASE.html +933 -0
  48. data/doc/file.misc.html +108 -0
  49. data/doc/file.mocha.html +90 -0
  50. data/doc/file.stubba.html +129 -0
  51. data/doc/file_list.html +67 -0
  52. data/doc/frames.html +13 -0
  53. data/doc/index.html +153 -0
  54. data/doc/js/app.js +205 -0
  55. data/doc/js/full_list.js +173 -0
  56. data/doc/js/jquery.js +16 -0
  57. data/doc/method_list.html +510 -0
  58. data/doc/top-level-namespace.html +105 -0
  59. data/lib/mocha/any_instance_method.rb +16 -11
  60. data/lib/mocha/api.rb +120 -106
  61. data/lib/mocha/argument_iterator.rb +6 -6
  62. data/lib/mocha/backtrace_filter.rb +1 -1
  63. data/lib/mocha/cardinality.rb +21 -21
  64. data/lib/mocha/central.rb +8 -8
  65. data/lib/mocha/change_state_side_effect.rb +5 -5
  66. data/lib/mocha/class_method.rb +14 -19
  67. data/lib/mocha/configuration.rb +47 -37
  68. data/lib/mocha/deprecation.rb +8 -8
  69. data/lib/mocha/exception_raiser.rb +7 -7
  70. data/lib/mocha/expectation.rb +173 -77
  71. data/lib/mocha/expectation_error.rb +2 -2
  72. data/lib/mocha/expectation_list.rb +11 -11
  73. data/lib/mocha/in_state_ordering_constraint.rb +5 -5
  74. data/lib/mocha/inspect.rb +8 -8
  75. data/lib/mocha/instance_method.rb +1 -17
  76. data/lib/mocha/integration.rb +9 -9
  77. data/lib/mocha/integration/mini_test/assertion_counter.rb +9 -9
  78. data/lib/mocha/integration/mini_test/exception_translation.rb +6 -6
  79. data/lib/mocha/integration/mini_test/version_13.rb +6 -6
  80. data/lib/mocha/integration/mini_test/version_140.rb +6 -6
  81. data/lib/mocha/integration/mini_test/version_141.rb +6 -6
  82. data/lib/mocha/integration/mini_test/version_142_to_172.rb +7 -7
  83. data/lib/mocha/integration/mini_test/version_200.rb +7 -7
  84. data/lib/mocha/integration/test_unit/assertion_counter.rb +10 -10
  85. data/lib/mocha/integration/test_unit/gem_version_200.rb +6 -6
  86. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +6 -6
  87. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +6 -6
  88. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +6 -6
  89. data/lib/mocha/is_a.rb +1 -1
  90. data/lib/mocha/logger.rb +6 -6
  91. data/lib/mocha/method_matcher.rb +7 -7
  92. data/lib/mocha/mock.rb +85 -48
  93. data/lib/mocha/mockery.rb +47 -33
  94. data/lib/mocha/module_method.rb +2 -2
  95. data/lib/mocha/multiple_yields.rb +9 -9
  96. data/lib/mocha/names.rb +18 -18
  97. data/lib/mocha/no_yields.rb +7 -7
  98. data/lib/mocha/object.rb +104 -75
  99. data/lib/mocha/parameter_matchers.rb +3 -3
  100. data/lib/mocha/parameter_matchers/all_of.rb +22 -12
  101. data/lib/mocha/parameter_matchers/any_of.rb +23 -12
  102. data/lib/mocha/parameter_matchers/any_parameters.rb +15 -8
  103. data/lib/mocha/parameter_matchers/anything.rb +20 -11
  104. data/lib/mocha/parameter_matchers/base.rb +35 -27
  105. data/lib/mocha/parameter_matchers/equals.rb +23 -12
  106. data/lib/mocha/parameter_matchers/has_entries.rb +22 -12
  107. data/lib/mocha/parameter_matchers/has_entry.rb +31 -13
  108. data/lib/mocha/parameter_matchers/has_key.rb +21 -11
  109. data/lib/mocha/parameter_matchers/has_value.rb +21 -11
  110. data/lib/mocha/parameter_matchers/includes.rb +15 -5
  111. data/lib/mocha/parameter_matchers/instance_of.rb +23 -12
  112. data/lib/mocha/parameter_matchers/is_a.rb +23 -12
  113. data/lib/mocha/parameter_matchers/kind_of.rb +23 -12
  114. data/lib/mocha/parameter_matchers/not.rb +22 -12
  115. data/lib/mocha/parameter_matchers/object.rb +5 -3
  116. data/lib/mocha/parameter_matchers/optionally.rb +24 -12
  117. data/lib/mocha/parameter_matchers/query_string.rb +14 -3
  118. data/lib/mocha/parameter_matchers/regexp_matches.rb +21 -11
  119. data/lib/mocha/parameter_matchers/responds_with.rb +17 -6
  120. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +16 -6
  121. data/lib/mocha/parameters_matcher.rb +8 -8
  122. data/lib/mocha/pretty_parameters.rb +7 -7
  123. data/lib/mocha/return_values.rb +11 -11
  124. data/lib/mocha/sequence.rb +23 -14
  125. data/lib/mocha/single_return_value.rb +7 -7
  126. data/lib/mocha/single_yield.rb +9 -9
  127. data/lib/mocha/standalone.rb +1 -1
  128. data/lib/mocha/state_machine.rb +61 -46
  129. data/lib/mocha/stubbing_error.rb +8 -5
  130. data/lib/mocha/thrower.rb +2 -2
  131. data/lib/mocha/unexpected_invocation.rb +9 -6
  132. data/lib/mocha/version.rb +1 -1
  133. data/lib/mocha/yield_parameters.rb +10 -10
  134. data/lib/mocha_standalone.rb +1 -1
  135. data/mocha.gemspec +4 -7
  136. data/test/acceptance/acceptance_test_helper.rb +10 -10
  137. data/test/acceptance/api_test.rb +20 -20
  138. data/test/acceptance/bug_18914_test.rb +12 -12
  139. data/test/acceptance/bug_21465_test.rb +6 -6
  140. data/test/acceptance/bug_21563_test.rb +5 -5
  141. data/test/acceptance/exception_rescue_test.rb +1 -1
  142. data/test/acceptance/expected_invocation_count_test.rb +17 -17
  143. data/test/acceptance/failure_messages_test.rb +13 -13
  144. data/test/acceptance/minitest_test.rb +39 -39
  145. data/test/acceptance/mocha_example_test.rb +26 -26
  146. data/test/acceptance/mocha_test_result_test.rb +13 -13
  147. data/test/acceptance/mock_test.rb +5 -5
  148. data/test/acceptance/mock_with_initializer_block_test.rb +5 -5
  149. data/test/acceptance/mocked_methods_dispatch_test.rb +4 -4
  150. data/test/acceptance/multiple_expectations_failure_message_test.rb +2 -2
  151. data/test/acceptance/optional_parameters_test.rb +5 -5
  152. data/test/acceptance/parameter_matcher_test.rb +18 -18
  153. data/test/acceptance/partial_mocks_test.rb +9 -9
  154. data/test/acceptance/raise_exception_test.rb +1 -1
  155. data/test/acceptance/return_value_test.rb +5 -5
  156. data/test/acceptance/sequence_test.rb +29 -29
  157. data/test/acceptance/states_test.rb +17 -17
  158. data/test/acceptance/stub_any_instance_method_test.rb +13 -13
  159. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +7 -7
  160. data/test/acceptance/stub_everything_test.rb +5 -5
  161. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +1 -1
  162. data/test/acceptance/stub_module_method_test.rb +17 -17
  163. data/test/acceptance/stub_test.rb +5 -5
  164. data/test/acceptance/stubba_example_test.rb +24 -24
  165. data/test/acceptance/stubba_test_result_test.rb +11 -11
  166. data/test/acceptance/stubbing_error_backtrace_test.rb +6 -6
  167. data/test/acceptance/stubbing_frozen_object_test.rb +88 -0
  168. data/test/acceptance/stubbing_method_unnecessarily_test.rb +9 -9
  169. data/test/acceptance/stubbing_nil_test.rb +59 -0
  170. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +13 -13
  171. data/test/acceptance/stubbing_non_existent_class_method_test.rb +15 -15
  172. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +14 -14
  173. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +13 -13
  174. data/test/acceptance/stubbing_non_public_class_method_test.rb +12 -12
  175. data/test/acceptance/stubbing_non_public_instance_method_test.rb +12 -12
  176. data/test/acceptance/stubbing_on_non_mock_object_test.rb +9 -9
  177. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +35 -0
  178. data/test/acceptance/throw_test.rb +1 -1
  179. data/test/deprecation_disabler.rb +1 -1
  180. data/test/execution_point.rb +7 -7
  181. data/test/method_definer.rb +1 -1
  182. data/test/mini_test_result.rb +21 -21
  183. data/test/simple_counter.rb +5 -5
  184. data/test/test_helper.rb +1 -1
  185. data/test/test_runner.rb +22 -24
  186. data/test/test_unit_result.rb +20 -0
  187. data/test/unit/any_instance_method_test.rb +28 -32
  188. data/test/unit/array_inspect_test.rb +3 -3
  189. data/test/unit/backtrace_filter_test.rb +3 -3
  190. data/test/unit/cardinality_test.rb +12 -12
  191. data/test/unit/central_test.rb +18 -18
  192. data/test/unit/change_state_side_effect_test.rb +12 -12
  193. data/test/unit/class_method_test.rb +33 -91
  194. data/test/unit/date_time_inspect_test.rb +4 -4
  195. data/test/unit/exception_raiser_test.rb +5 -5
  196. data/test/unit/expectation_list_test.rb +7 -7
  197. data/test/unit/expectation_test.rb +66 -66
  198. data/test/unit/hash_inspect_test.rb +4 -4
  199. data/test/unit/in_state_ordering_constraint_test.rb +13 -13
  200. data/test/unit/method_matcher_test.rb +3 -3
  201. data/test/unit/mock_test.rb +40 -40
  202. data/test/unit/mockery_test.rb +25 -25
  203. data/test/unit/multiple_yields_test.rb +2 -2
  204. data/test/unit/no_yields_test.rb +2 -2
  205. data/test/unit/object_inspect_test.rb +4 -4
  206. data/test/unit/object_test.rb +15 -15
  207. data/test/unit/parameter_matchers/all_of_test.rb +6 -6
  208. data/test/unit/parameter_matchers/any_of_test.rb +6 -6
  209. data/test/unit/parameter_matchers/anything_test.rb +5 -5
  210. data/test/unit/parameter_matchers/has_entries_test.rb +10 -10
  211. data/test/unit/parameter_matchers/has_entry_test.rb +13 -13
  212. data/test/unit/parameter_matchers/has_key_test.rb +11 -11
  213. data/test/unit/parameter_matchers/has_value_test.rb +12 -12
  214. data/test/unit/parameter_matchers/includes_test.rb +4 -4
  215. data/test/unit/parameter_matchers/not_test.rb +6 -6
  216. data/test/unit/parameter_matchers/regexp_matches_test.rb +9 -9
  217. data/test/unit/parameter_matchers/responds_with_test.rb +6 -6
  218. data/test/unit/parameter_matchers/stub_matcher.rb +4 -4
  219. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +6 -6
  220. data/test/unit/parameters_matcher_test.rb +16 -16
  221. data/test/unit/return_values_test.rb +5 -5
  222. data/test/unit/sequence_test.rb +10 -10
  223. data/test/unit/single_return_value_test.rb +3 -3
  224. data/test/unit/single_yield_test.rb +2 -2
  225. data/test/unit/state_machine_test.rb +19 -19
  226. data/test/unit/string_inspect_test.rb +2 -2
  227. data/test/unit/thrower_test.rb +1 -1
  228. data/test/unit/yield_parameters_test.rb +11 -11
  229. metadata +113 -101
@@ -21,22 +21,22 @@ class IncludesTest < Test::Unit::TestCase
21
21
  matcher = includes(:x)
22
22
  assert_equal "includes(:x)", matcher.mocha_inspect
23
23
  end
24
-
24
+
25
25
  def test_should_not_raise_error_on_emtpy_arguments
26
26
  matcher = includes(:x)
27
27
  assert_nothing_raised { matcher.matches?([]) }
28
28
  end
29
-
29
+
30
30
  def test_should_not_match_on_empty_arguments
31
31
  matcher = includes(:x)
32
32
  assert !matcher.matches?([])
33
33
  end
34
-
34
+
35
35
  def test_should_not_raise_error_on_argument_that_does_not_respond_to_include
36
36
  matcher = includes(:x)
37
37
  assert_nothing_raised { matcher.matches?([:x]) }
38
38
  end
39
-
39
+
40
40
  def test_should_not_match_on_argument_that_does_not_respond_to_include
41
41
  matcher = includes(:x)
42
42
  assert !matcher.matches?([:x])
@@ -5,22 +5,22 @@ require 'mocha/inspect'
5
5
  require 'stub_matcher'
6
6
 
7
7
  class NotTest < Test::Unit::TestCase
8
-
8
+
9
9
  include Mocha::ParameterMatchers
10
-
10
+
11
11
  def test_should_match_if_matcher_does_not_match
12
12
  matcher = Not(Stub::Matcher.new(false))
13
13
  assert matcher.matches?(['any_old_value'])
14
14
  end
15
-
15
+
16
16
  def test_should_not_match_if_matcher_does_match
17
17
  matcher = Not(Stub::Matcher.new(true))
18
18
  assert !matcher.matches?(['any_old_value'])
19
19
  end
20
-
20
+
21
21
  def test_should_describe_matcher
22
22
  matcher = Not(Stub::Matcher.new(true))
23
23
  assert_equal 'Not(matcher(true))', matcher.mocha_inspect
24
24
  end
25
-
26
- end
25
+
26
+ end
@@ -4,43 +4,43 @@ require 'mocha/parameter_matchers/regexp_matches'
4
4
  require 'mocha/inspect'
5
5
 
6
6
  class RegexpMatchesTest < Test::Unit::TestCase
7
-
7
+
8
8
  include Mocha::ParameterMatchers
9
-
9
+
10
10
  def test_should_match_parameter_matching_regular_expression
11
11
  matcher = regexp_matches(/oo/)
12
12
  assert matcher.matches?(['foo'])
13
13
  end
14
-
14
+
15
15
  def test_should_not_match_parameter_not_matching_regular_expression
16
16
  matcher = regexp_matches(/oo/)
17
17
  assert !matcher.matches?(['bar'])
18
18
  end
19
-
19
+
20
20
  def test_should_describe_matcher
21
21
  matcher = regexp_matches(/oo/)
22
22
  assert_equal "regexp_matches(/oo/)", matcher.mocha_inspect
23
23
  end
24
-
24
+
25
25
  def test_should_not_raise_error_on_empty_arguments
26
26
  matcher = regexp_matches(/oo/)
27
27
  assert_nothing_raised { matcher.matches?([]) }
28
28
  end
29
-
29
+
30
30
  def test_should_not_match_on_empty_arguments
31
31
  matcher = regexp_matches(/oo/)
32
32
  assert !matcher.matches?([])
33
33
  end
34
-
34
+
35
35
  def test_should_not_raise_error_on_argument_that_does_not_respond_to_equals_tilde
36
36
  object_not_responding_to_equals_tilde = Class.new { undef =~ }.new
37
37
  matcher = regexp_matches(/oo/)
38
38
  assert_nothing_raised { matcher.matches?([object_not_responding_to_equals_tilde]) }
39
39
  end
40
-
40
+
41
41
  def test_should_not_match_on_argument_that_does_not_respond_to_equals_tilde
42
42
  object_not_responding_to_equals_tilde = Class.new { undef =~ }.new
43
43
  matcher = regexp_matches(/oo/)
44
44
  assert !matcher.matches?([object_not_responding_to_equals_tilde])
45
45
  end
46
- end
46
+ end
@@ -4,22 +4,22 @@ require 'mocha/parameter_matchers/responds_with'
4
4
  require 'mocha/inspect'
5
5
 
6
6
  class RespondsWithTest < Test::Unit::TestCase
7
-
7
+
8
8
  include Mocha::ParameterMatchers
9
-
9
+
10
10
  def test_should_match_parameter_responding_with_expected_value
11
11
  matcher = responds_with(:upcase, 'FOO')
12
12
  assert matcher.matches?(['foo'])
13
13
  end
14
-
14
+
15
15
  def test_should_not_match_parameter_responding_with_unexpected_value
16
16
  matcher = responds_with(:upcase, 'FOO')
17
17
  assert !matcher.matches?(['bar'])
18
18
  end
19
-
19
+
20
20
  def test_should_describe_matcher
21
21
  matcher = responds_with(:foo, :bar)
22
22
  assert_equal 'responds_with(:foo, :bar)', matcher.mocha_inspect
23
23
  end
24
-
25
- end
24
+
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Stub
2
-
2
+
3
3
  class Matcher
4
4
 
5
5
  attr_accessor :value
@@ -17,11 +17,11 @@ module Stub
17
17
  def mocha_inspect
18
18
  "matcher(#{@matches})"
19
19
  end
20
-
20
+
21
21
  def to_matcher
22
22
  self
23
23
  end
24
24
 
25
25
  end
26
-
27
- end
26
+
27
+ end
@@ -4,22 +4,22 @@ require 'mocha/parameter_matchers/yaml_equivalent'
4
4
  require 'mocha/inspect'
5
5
 
6
6
  class YamlEquivalentTest < Test::Unit::TestCase
7
-
7
+
8
8
  include Mocha::ParameterMatchers
9
-
9
+
10
10
  def test_should_match_parameter_matching_yaml_representation_of_object
11
11
  matcher = yaml_equivalent([1, 2, 3])
12
12
  assert matcher.matches?(["--- \n- 1\n- 2\n- 3\n"])
13
13
  end
14
-
14
+
15
15
  def test_should_not_match_parameter_matching_yaml_representation_of_object
16
16
  matcher = yaml_equivalent([1, 2, 3])
17
17
  assert !matcher.matches?(["--- \n- 4\n- 5\n"])
18
18
  end
19
-
19
+
20
20
  def test_should_describe_matcher
21
21
  matcher = yaml_equivalent([1, 2, 3])
22
22
  assert_equal "yaml_equivalent([1, 2, 3])", matcher.mocha_inspect
23
23
  end
24
-
25
- end
24
+
25
+ end
@@ -2,7 +2,7 @@ require File.expand_path('../../test_helper', __FILE__)
2
2
  require 'mocha/parameters_matcher'
3
3
 
4
4
  class ParametersMatcherTest < Test::Unit::TestCase
5
-
5
+
6
6
  include Mocha
7
7
 
8
8
  def test_should_match_any_actual_parameters_if_no_expected_parameters_specified
@@ -14,52 +14,52 @@ class ParametersMatcherTest < Test::Unit::TestCase
14
14
  parameters_matcher = ParametersMatcher.new([4, 5, 6])
15
15
  assert parameters_matcher.match?([4, 5, 6])
16
16
  end
17
-
17
+
18
18
  def test_should_not_match_if_actual_parameters_are_different_from_expected_parameters
19
19
  parameters_matcher = ParametersMatcher.new([4, 5, 6])
20
20
  assert !parameters_matcher.match?([1, 2, 3])
21
21
  end
22
-
22
+
23
23
  def test_should_not_match_if_there_are_less_actual_parameters_than_expected_parameters
24
24
  parameters_matcher = ParametersMatcher.new([4, 5, 6])
25
25
  assert !parameters_matcher.match?([4, 5])
26
26
  end
27
-
27
+
28
28
  def test_should_not_match_if_there_are_more_actual_parameters_than_expected_parameters
29
29
  parameters_matcher = ParametersMatcher.new([4, 5])
30
30
  assert !parameters_matcher.match?([4, 5, 6])
31
31
  end
32
-
32
+
33
33
  def test_should_not_match_if_not_all_required_parameters_are_supplied
34
34
  optionals = ParameterMatchers::Optionally.new(6, 7)
35
35
  parameters_matcher = ParametersMatcher.new([4, 5, optionals])
36
36
  assert !parameters_matcher.match?([4])
37
37
  end
38
-
38
+
39
39
  def test_should_match_if_all_required_parameters_match_and_no_optional_parameters_are_supplied
40
40
  optionals = ParameterMatchers::Optionally.new(6, 7)
41
41
  parameters_matcher = ParametersMatcher.new([4, 5, optionals])
42
42
  assert parameters_matcher.match?([4, 5])
43
43
  end
44
-
44
+
45
45
  def test_should_match_if_all_required_and_optional_parameters_match_and_some_optional_parameters_are_supplied
46
46
  optionals = ParameterMatchers::Optionally.new(6, 7)
47
47
  parameters_matcher = ParametersMatcher.new([4, 5, optionals])
48
48
  assert parameters_matcher.match?([4, 5, 6])
49
49
  end
50
-
50
+
51
51
  def test_should_match_if_all_required_and_optional_parameters_match_and_all_optional_parameters_are_supplied
52
52
  optionals = ParameterMatchers::Optionally.new(6, 7)
53
53
  parameters_matcher = ParametersMatcher.new([4, 5, optionals])
54
54
  assert parameters_matcher.match?([4, 5, 6, 7])
55
55
  end
56
-
56
+
57
57
  def test_should_not_match_if_all_required_and_optional_parameters_match_but_too_many_optional_parameters_are_supplied
58
58
  optionals = ParameterMatchers::Optionally.new(6, 7)
59
59
  parameters_matcher = ParametersMatcher.new([4, 5, optionals])
60
60
  assert !parameters_matcher.match?([4, 5, 6, 7, 8])
61
61
  end
62
-
62
+
63
63
  def test_should_not_match_if_all_required_parameters_match_but_some_optional_parameters_do_not_match
64
64
  optionals = ParameterMatchers::Optionally.new(6, 7)
65
65
  parameters_matcher = ParametersMatcher.new([4, 5, optionals])
@@ -87,35 +87,35 @@ class ParametersMatcherTest < Test::Unit::TestCase
87
87
  parameters_matcher = ParametersMatcher.new { |x, y| x + y == 3 }
88
88
  assert !parameters_matcher.match?([2, 3])
89
89
  end
90
-
90
+
91
91
  def test_should_remove_outer_array_braces
92
92
  params = [1, 2, [3, 4]]
93
93
  parameters_matcher = ParametersMatcher.new(params)
94
94
  assert_equal '(1, 2, [3, 4])', parameters_matcher.mocha_inspect
95
95
  end
96
-
96
+
97
97
  def test_should_display_numeric_arguments_as_is
98
98
  params = [1, 2, 3]
99
99
  parameters_matcher = ParametersMatcher.new(params)
100
100
  assert_equal '(1, 2, 3)', parameters_matcher.mocha_inspect
101
101
  end
102
-
102
+
103
103
  def test_should_remove_curly_braces_if_hash_is_only_argument
104
104
  params = [{:a => 1, :z => 2}]
105
105
  parameters_matcher = ParametersMatcher.new(params)
106
106
  assert_nil parameters_matcher.mocha_inspect.index('{')
107
107
  assert_nil parameters_matcher.mocha_inspect.index('}')
108
108
  end
109
-
109
+
110
110
  def test_should_not_remove_curly_braces_if_hash_is_not_the_only_argument
111
111
  params = [1, {:a => 1}]
112
112
  parameters_matcher = ParametersMatcher.new(params)
113
113
  assert_equal '(1, {:a => 1})', parameters_matcher.mocha_inspect
114
114
  end
115
-
115
+
116
116
  def test_should_indicate_that_matcher_will_match_any_actual_parameters
117
117
  parameters_matcher = ParametersMatcher.new
118
118
  assert_equal '(any_parameters)', parameters_matcher.mocha_inspect
119
119
  end
120
120
 
121
- end
121
+ end
@@ -3,9 +3,9 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  require 'mocha/return_values'
4
4
 
5
5
  class ReturnValuesTest < Test::Unit::TestCase
6
-
6
+
7
7
  include Mocha
8
-
8
+
9
9
  def test_should_return_nil
10
10
  values = ReturnValues.new
11
11
  assert_nil values.next
@@ -43,14 +43,14 @@ class ReturnValuesTest < Test::Unit::TestCase
43
43
  assert_equal 'value_2', values.next
44
44
  assert_equal 'value_2', values.next
45
45
  end
46
-
46
+
47
47
  def test_should_build_single_return_values_for_each_values
48
48
  values = ReturnValues.build('value_1', 'value_2', 'value_3').values
49
49
  assert_equal 'value_1', values[0].evaluate
50
50
  assert_equal 'value_2', values[1].evaluate
51
51
  assert_equal 'value_3', values[2].evaluate
52
52
  end
53
-
53
+
54
54
  def test_should_combine_two_sets_of_return_values
55
55
  values_1 = ReturnValues.build('value_1')
56
56
  values_2 = ReturnValues.build('value_2a', 'value_2b')
@@ -60,4 +60,4 @@ class ReturnValuesTest < Test::Unit::TestCase
60
60
  assert_equal 'value_2b', values[2].evaluate
61
61
  end
62
62
 
63
- end
63
+ end
@@ -3,28 +3,28 @@ require 'mocha/sequence'
3
3
  require 'mocha/expectation'
4
4
 
5
5
  class SequenceTest < Test::Unit::TestCase
6
-
6
+
7
7
  include Mocha
8
-
8
+
9
9
  class FakeExpectation
10
-
10
+
11
11
  attr_reader :ordering_constraints
12
-
12
+
13
13
  def initialize(satisfied = false)
14
14
  @satisfied = satisfied
15
15
  @ordering_constraints = []
16
16
  end
17
-
17
+
18
18
  def add_ordering_constraint(ordering_constraint)
19
19
  @ordering_constraints << ordering_constraint
20
20
  end
21
-
21
+
22
22
  def satisfied?
23
23
  @satisfied
24
24
  end
25
-
25
+
26
26
  end
27
-
27
+
28
28
  def test_should_be_satisfied_if_no_expectations_added
29
29
  sequence = Sequence.new('name')
30
30
  assert sequence.satisfied_to_index?(0)
@@ -68,7 +68,7 @@ class SequenceTest < Test::Unit::TestCase
68
68
  sequence.constrain_as_next_in_sequence(expectation_two)
69
69
  assert sequence.satisfied_to_index?(2)
70
70
  end
71
-
71
+
72
72
  def test_should_add_ordering_constraint_to_expectation
73
73
  sequence = Sequence.new('name')
74
74
  expectation = FakeExpectation.new
@@ -101,4 +101,4 @@ class SequenceTest < Test::Unit::TestCase
101
101
  assert_equal "in sequence 'wibble'", expectation.ordering_constraints[0].mocha_inspect
102
102
  end
103
103
 
104
- end
104
+ end
@@ -3,12 +3,12 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  require 'mocha/single_return_value'
4
4
 
5
5
  class SingleReturnValueTest < Test::Unit::TestCase
6
-
6
+
7
7
  include Mocha
8
-
8
+
9
9
  def test_should_return_value
10
10
  value = SingleReturnValue.new('value')
11
11
  assert_equal 'value', value.evaluate
12
12
  end
13
-
13
+
14
14
  end
@@ -3,7 +3,7 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  require 'mocha/single_yield'
4
4
 
5
5
  class SingleYieldTest < Test::Unit::TestCase
6
-
6
+
7
7
  include Mocha
8
8
 
9
9
  def test_should_provide_parameters_for_single_yield_in_single_invocation
@@ -14,5 +14,5 @@ class SingleYieldTest < Test::Unit::TestCase
14
14
  end
15
15
  assert_equal [[1, 2, 3]], parameter_groups
16
16
  end
17
-
17
+
18
18
  end
@@ -3,9 +3,9 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  require 'mocha/state_machine'
4
4
 
5
5
  class StateMachineTest < Test::Unit::TestCase
6
-
6
+
7
7
  include Mocha
8
-
8
+
9
9
  def test_should_initially_be_in_no_state
10
10
  state_machine = StateMachine.new('name')
11
11
  any_state.each do |state|
@@ -13,14 +13,14 @@ class StateMachineTest < Test::Unit::TestCase
13
13
  assert state_machine.is_not(state).active?
14
14
  end
15
15
  end
16
-
16
+
17
17
  def test_should_be_able_to_enter_a_state
18
18
  state_machine = StateMachine.new('name')
19
19
  state = 'A'
20
20
  other_states = any_state.reject { |s| s == state }
21
-
21
+
22
22
  state_machine.is(state).activate
23
-
23
+
24
24
  assert state_machine.is(state).active?
25
25
  assert !state_machine.is_not(state).active?
26
26
  other_states.each do |s|
@@ -28,15 +28,15 @@ class StateMachineTest < Test::Unit::TestCase
28
28
  assert state_machine.is_not(s).active?
29
29
  end
30
30
  end
31
-
31
+
32
32
  def test_should_be_able_to_change_state
33
33
  state_machine = StateMachine.new('name')
34
34
  state = 'B'
35
35
  other_states = any_state.reject { |s| s == state }
36
-
36
+
37
37
  state_machine.is('A').activate
38
38
  state_machine.is(state).activate
39
-
39
+
40
40
  assert state_machine.is(state).active?
41
41
  assert !state_machine.is_not(state).active?
42
42
  other_states.each do |s|
@@ -44,14 +44,14 @@ class StateMachineTest < Test::Unit::TestCase
44
44
  assert state_machine.is_not(s).active?
45
45
  end
46
46
  end
47
-
47
+
48
48
  def test_should_be_put_into_an_initial_state
49
49
  state_machine = StateMachine.new('name')
50
50
  initial_state = 'A'
51
51
  other_states = any_state.reject { |s| s == initial_state }
52
-
52
+
53
53
  state_machine.starts_as(initial_state)
54
-
54
+
55
55
  assert state_machine.is(initial_state).active?
56
56
  assert !state_machine.is_not(initial_state).active?
57
57
  other_states.each do |state|
@@ -59,15 +59,15 @@ class StateMachineTest < Test::Unit::TestCase
59
59
  assert state_machine.is_not(state).active?
60
60
  end
61
61
  end
62
-
62
+
63
63
  def test_should_be_put_into_a_new_state
64
64
  next_state = 'B'
65
-
65
+
66
66
  other_states = any_state.reject { |s| s == next_state }
67
67
  state_machine = StateMachine.new('name').starts_as('A')
68
-
68
+
69
69
  state_machine.become(next_state)
70
-
70
+
71
71
  assert state_machine.is(next_state).active?
72
72
  assert !state_machine.is_not(next_state).active?
73
73
  other_states.each do |state|
@@ -75,7 +75,7 @@ class StateMachineTest < Test::Unit::TestCase
75
75
  assert state_machine.is_not(state).active?
76
76
  end
77
77
  end
78
-
78
+
79
79
  def test_should_describe_itself_as_name_and_current_state
80
80
  state_machine = StateMachine.new('state_machine_name')
81
81
  assert_equal 'state_machine_name has no current state', state_machine.mocha_inspect
@@ -83,16 +83,16 @@ class StateMachineTest < Test::Unit::TestCase
83
83
  state_machine.is(inspectable_state).activate
84
84
  assert_equal "state_machine_name is 'inspectable_state'", state_machine.mocha_inspect
85
85
  end
86
-
86
+
87
87
  def test_should_have_self_describing_states
88
88
  state_machine = StateMachine.new('state_machine_name')
89
89
  inspectable_state = Class.new { define_method(:mocha_inspect) { "'inspectable_state'" } }.new
90
90
  assert_equal "state_machine_name is 'inspectable_state'", state_machine.is(inspectable_state).mocha_inspect
91
91
  assert_equal "state_machine_name is not 'inspectable_state'", state_machine.is_not(inspectable_state).mocha_inspect
92
92
  end
93
-
93
+
94
94
  def any_state
95
95
  %w(A B C D)
96
96
  end
97
-
97
+
98
98
  end