rspec 1.2.8 → 1.2.9

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 (238) hide show
  1. data/History.rdoc +41 -2
  2. data/Manifest.txt +11 -10
  3. data/Rakefile +47 -22
  4. data/Ruby1.9.rdoc +1 -2
  5. data/Upgrade.rdoc +56 -7
  6. data/bin/spec +2 -1
  7. data/cucumber.yml +3 -1
  8. data/examples/failing/README.txt +7 -3
  9. data/examples/failing/failing_implicit_docstrings_example.rb +0 -2
  10. data/examples/failing/mocking_example.rb +0 -2
  11. data/examples/failing/partial_mock_example.rb +0 -2
  12. data/examples/failing/pending_example.rb +0 -2
  13. data/examples/failing/predicate_example.rb +0 -2
  14. data/examples/failing/team_spec.rb +0 -3
  15. data/examples/failing/timeout_behaviour.rb +0 -2
  16. data/examples/passing/custom_formatter.rb +0 -1
  17. data/examples/passing/dynamic_spec.rb +0 -2
  18. data/examples/passing/file_accessor.rb +1 -2
  19. data/examples/passing/file_accessor_spec.rb +1 -2
  20. data/examples/passing/filtered_formatter.rb +0 -1
  21. data/examples/passing/greeter_spec.rb +0 -1
  22. data/examples/passing/helper_method_example.rb +0 -2
  23. data/examples/passing/implicit_docstrings_example.rb +0 -2
  24. data/examples/passing/io_processor_spec.rb +1 -2
  25. data/examples/passing/mocking_example.rb +0 -2
  26. data/examples/passing/nested_classes_example.rb +1 -2
  27. data/examples/passing/options_example.rb +0 -2
  28. data/examples/passing/partial_mock_example.rb +0 -2
  29. data/examples/passing/pending_example.rb +0 -2
  30. data/examples/passing/predicate_example.rb +0 -2
  31. data/examples/passing/shared_example_group_example.rb +0 -2
  32. data/examples/passing/simple_matcher_example.rb +0 -2
  33. data/examples/passing/stack_spec.rb +2 -3
  34. data/examples/passing/stack_spec_with_nested_example_groups.rb +2 -3
  35. data/examples/passing/stubbing_example.rb +0 -2
  36. data/examples/passing/yielding_example.rb +0 -2
  37. data/features/before_and_after_blocks/before_and_after_blocks.feature +4 -4
  38. data/features/command_line/line_number_option.feature +14 -14
  39. data/features/command_line/line_number_option_with_example_with_no_name.feature +2 -2
  40. data/features/example_groups/define_example_attribute.feature +41 -0
  41. data/features/example_groups/example_group_with_should_methods.feature +1 -1
  42. data/features/example_groups/implicit_docstrings.feature +7 -7
  43. data/features/example_groups/nested_groups.feature +2 -2
  44. data/features/expectations/customized_message.feature +4 -4
  45. data/features/expectations/expect_change.feature +4 -4
  46. data/features/expectations/expect_error.feature +4 -4
  47. data/features/extensions/custom_example_group.feature +10 -10
  48. data/features/formatters/custom_formatter.feature +3 -3
  49. data/features/interop/examples_and_tests_together.feature +10 -6
  50. data/features/interop/rspec_output.feature +1 -1
  51. data/features/interop/test_case_with_should_methods.feature +1 -1
  52. data/features/load_paths/add_lib_to_load_path.feature +20 -0
  53. data/features/load_paths/add_spec_to_load_path.feature +20 -0
  54. data/features/matchers/define_diffable_matcher.feature +2 -2
  55. data/features/matchers/define_matcher.feature +19 -19
  56. data/features/matchers/define_matcher_outside_rspec.feature +2 -3
  57. data/features/matchers/define_matcher_with_fluent_interface.feature +2 -2
  58. data/features/matchers/define_wrapped_matcher.feature +29 -0
  59. data/features/mock_framework_integration/use_flexmock.feature +1 -1
  60. data/features/mock_framework_integration/use_mocha.feature +1 -1
  61. data/features/mock_framework_integration/use_rr.feature +1 -1
  62. data/features/mocks/mix_stubs_and_mocks.feature +2 -2
  63. data/features/mocks/stub_implementation.feature +1 -1
  64. data/features/pending/pending_examples.feature +16 -16
  65. data/features/runner/specify_line_number.feature +4 -4
  66. data/features/spec_helper/spec_helper.feature +25 -0
  67. data/features/step_definitions/running_rspec_steps.rb +4 -2
  68. data/features/subject/explicit_subject.feature +2 -2
  69. data/features/subject/implicit_subject.feature +14 -2
  70. data/features/support/env.rb +6 -3
  71. data/lib/spec/adapters/mock_frameworks/mocha.rb +6 -1
  72. data/lib/spec/example/example_group_methods.rb +7 -0
  73. data/lib/spec/example/example_methods.rb +1 -1
  74. data/lib/spec/example/subject.rb +8 -0
  75. data/lib/spec/interop/test.rb +27 -1
  76. data/lib/spec/interop/test/unit/testcase.rb +1 -1
  77. data/lib/spec/matchers/exist.rb +2 -2
  78. data/lib/spec/matchers/extensions/instance_exec.rb +28 -20
  79. data/lib/spec/matchers/matcher.rb +21 -20
  80. data/lib/spec/mocks/argument_matchers.rb +17 -13
  81. data/lib/spec/mocks/error_generator.rb +14 -3
  82. data/lib/spec/mocks/{spec_methods.rb → example_methods.rb} +25 -11
  83. data/lib/spec/mocks/framework.rb +1 -1
  84. data/lib/spec/mocks/methods.rb +15 -0
  85. data/lib/spec/mocks/mock.rb +16 -10
  86. data/lib/spec/mocks/proxy.rb +1 -1
  87. data/lib/spec/rake/spectask.rb +3 -3
  88. data/lib/spec/runner/backtrace_tweaker.rb +41 -22
  89. data/lib/spec/runner/configuration.rb +18 -1
  90. data/lib/spec/runner/differs/default.rb +1 -1
  91. data/lib/spec/runner/drb_command_line.rb +5 -2
  92. data/lib/spec/runner/formatter/base_text_formatter.rb +8 -3
  93. data/lib/spec/runner/option_parser.rb +21 -15
  94. data/lib/spec/runner/options.rb +54 -23
  95. data/lib/spec/version.rb +3 -3
  96. data/resources/helpers/cmdline.rb +0 -1
  97. data/spec/autotest/autotest_helper.rb +4 -6
  98. data/spec/autotest/discover_spec.rb +2 -2
  99. data/spec/autotest/failed_results_re_spec.rb +1 -1
  100. data/spec/autotest/rspec_spec.rb +1 -1
  101. data/spec/spec/dsl/main_spec.rb +1 -1
  102. data/spec/spec/example/example_group_class_definition_spec.rb +1 -1
  103. data/spec/spec/example/example_group_factory_spec.rb +1 -1
  104. data/spec/spec/example/example_group_methods_spec.rb +21 -1
  105. data/spec/spec/example/example_group_proxy_spec.rb +1 -1
  106. data/spec/spec/example/example_group_spec.rb +1 -1
  107. data/spec/spec/example/example_matcher_spec.rb +1 -1
  108. data/spec/spec/example/example_methods_spec.rb +1 -1
  109. data/spec/spec/example/example_proxy_spec.rb +1 -1
  110. data/spec/spec/example/helper_method_spec.rb +1 -1
  111. data/spec/spec/example/nested_example_group_spec.rb +1 -1
  112. data/spec/spec/example/predicate_matcher_spec.rb +1 -1
  113. data/spec/spec/example/shared_example_group_spec.rb +1 -1
  114. data/spec/spec/example/subclassing_example_group_spec.rb +1 -1
  115. data/spec/spec/example/subject_spec.rb +17 -1
  116. data/spec/spec/expectations/differs/default_spec.rb +16 -3
  117. data/spec/spec/expectations/extensions/kernel_spec.rb +1 -1
  118. data/spec/spec/expectations/fail_with_spec.rb +1 -1
  119. data/spec/spec/expectations/handler_spec.rb +1 -1
  120. data/spec/spec/expectations/wrap_expectation_spec.rb +1 -1
  121. data/spec/spec/interop/test/unit/resources/test_case_with_various_names.rb +22 -0
  122. data/spec/spec/interop/test/unit/spec_spec.rb +1 -1
  123. data/spec/spec/interop/test/unit/test_unit_spec_helper.rb +2 -2
  124. data/spec/spec/interop/test/unit/testcase_spec.rb +7 -2
  125. data/spec/spec/interop/test/unit/testsuite_adapter_spec.rb +1 -1
  126. data/spec/spec/matchers/be_close_spec.rb +1 -1
  127. data/spec/spec/matchers/be_instance_of_spec.rb +1 -1
  128. data/spec/spec/matchers/be_kind_of_spec.rb +1 -1
  129. data/spec/spec/matchers/be_spec.rb +13 -1
  130. data/spec/spec/matchers/change_spec.rb +1 -1
  131. data/spec/spec/matchers/compatibility_spec.rb +1 -1
  132. data/spec/spec/matchers/description_generation_spec.rb +1 -1
  133. data/spec/spec/matchers/dsl_spec.rb +1 -1
  134. data/spec/spec/matchers/eql_spec.rb +1 -1
  135. data/spec/spec/matchers/equal_spec.rb +1 -1
  136. data/spec/spec/matchers/exist_spec.rb +6 -2
  137. data/spec/spec/matchers/has_spec.rb +19 -1
  138. data/spec/spec/matchers/have_spec.rb +1 -1
  139. data/spec/spec/matchers/include_spec.rb +1 -1
  140. data/spec/spec/matchers/match_array_spec.rb +1 -1
  141. data/spec/spec/matchers/match_spec.rb +1 -1
  142. data/spec/spec/matchers/matcher_methods_spec.rb +1 -1
  143. data/spec/spec/matchers/matcher_spec.rb +55 -28
  144. data/spec/spec/matchers/matchers_spec.rb +1 -1
  145. data/spec/spec/matchers/operator_matcher_spec.rb +1 -1
  146. data/spec/spec/matchers/raise_error_spec.rb +1 -1
  147. data/spec/spec/matchers/respond_to_spec.rb +1 -1
  148. data/spec/spec/matchers/satisfy_spec.rb +1 -1
  149. data/spec/spec/matchers/simple_matcher_spec.rb +1 -1
  150. data/spec/spec/matchers/throw_symbol_spec.rb +1 -1
  151. data/spec/spec/mocks/any_number_of_times_spec.rb +1 -1
  152. data/spec/spec/mocks/argument_expectation_spec.rb +1 -1
  153. data/spec/spec/mocks/argument_matchers_spec.rb +19 -0
  154. data/spec/spec/mocks/at_least_spec.rb +1 -1
  155. data/spec/spec/mocks/at_most_spec.rb +1 -1
  156. data/spec/spec/mocks/bug_report_10260_spec.rb +1 -1
  157. data/spec/spec/mocks/bug_report_10263_spec.rb +1 -1
  158. data/spec/spec/mocks/bug_report_11545_spec.rb +1 -1
  159. data/spec/spec/mocks/bug_report_15719_spec.rb +3 -3
  160. data/spec/spec/mocks/bug_report_496_spec.rb +1 -1
  161. data/spec/spec/mocks/bug_report_600_spec.rb +1 -1
  162. data/spec/spec/mocks/bug_report_7611_spec.rb +1 -1
  163. data/spec/spec/mocks/bug_report_7805_spec.rb +1 -1
  164. data/spec/spec/mocks/bug_report_8165_spec.rb +1 -1
  165. data/spec/spec/mocks/bug_report_8302_spec.rb +1 -1
  166. data/spec/spec/mocks/bug_report_830_spec.rb +1 -1
  167. data/spec/spec/mocks/double_spec.rb +12 -0
  168. data/spec/spec/mocks/failing_argument_matchers_spec.rb +6 -6
  169. data/spec/spec/mocks/hash_including_matcher_spec.rb +1 -1
  170. data/spec/spec/mocks/hash_not_including_matcher_spec.rb +1 -1
  171. data/spec/spec/mocks/mock_ordering_spec.rb +4 -4
  172. data/spec/spec/mocks/mock_space_spec.rb +1 -1
  173. data/spec/spec/mocks/mock_spec.rb +20 -24
  174. data/spec/spec/mocks/multiple_return_value_spec.rb +8 -8
  175. data/spec/spec/mocks/nil_expectation_warning_spec.rb +1 -1
  176. data/spec/spec/mocks/null_object_mock_spec.rb +1 -1
  177. data/spec/spec/mocks/once_counts_spec.rb +1 -1
  178. data/spec/spec/mocks/options_hash_spec.rb +1 -1
  179. data/spec/spec/mocks/partial_mock_spec.rb +1 -1
  180. data/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +1 -1
  181. data/spec/spec/mocks/passing_argument_matchers_spec.rb +1 -1
  182. data/spec/spec/mocks/precise_counts_spec.rb +1 -1
  183. data/spec/spec/mocks/record_messages_spec.rb +1 -1
  184. data/spec/spec/mocks/stub_chain_spec.rb +1 -1
  185. data/spec/spec/mocks/stub_implementation_spec.rb +1 -1
  186. data/spec/spec/mocks/stub_spec.rb +14 -9
  187. data/spec/spec/mocks/stubbed_message_expectations_spec.rb +2 -2
  188. data/spec/spec/mocks/twice_counts_spec.rb +1 -1
  189. data/spec/spec/mocks/unstub_spec.rb +1 -1
  190. data/spec/spec/package/bin_spec_spec.rb +4 -10
  191. data/spec/spec/rake/spectask_spec.rb +2 -2
  192. data/spec/spec/runner/class_and_argument_parser_spec.rb +1 -1
  193. data/spec/spec/runner/command_line_spec.rb +1 -1
  194. data/spec/spec/runner/configuration_spec.rb +15 -6
  195. data/spec/spec/runner/drb_command_line_spec.rb +1 -1
  196. data/spec/spec/runner/example_group_runner_spec.rb +1 -1
  197. data/spec/spec/runner/formatter/base_formatter_spec.rb +1 -1
  198. data/spec/spec/runner/formatter/base_text_formatter_spec.rb +10 -1
  199. data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +1 -1
  200. data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +1 -1
  201. data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +72 -76
  202. data/spec/spec/runner/formatter/html_formatted-1.8.6.html +50 -50
  203. data/spec/spec/runner/formatter/html_formatted-1.8.7.html +50 -50
  204. data/spec/spec/runner/formatter/html_formatted-1.9.1.html +61 -69
  205. data/spec/spec/runner/formatter/html_formatter_spec.rb +26 -26
  206. data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +1 -1
  207. data/spec/spec/runner/formatter/profile_formatter_spec.rb +1 -1
  208. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +13 -9
  209. data/spec/spec/runner/formatter/snippet_extractor_spec.rb +1 -1
  210. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +1 -1
  211. data/spec/spec/runner/formatter/{text_mate_formatted-1.8.4.html → text_mate_formatted-1.8.6-jruby.html} +64 -59
  212. data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +46 -46
  213. data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +46 -46
  214. data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +55 -63
  215. data/spec/spec/runner/formatter/text_mate_formatter_spec.rb +3 -3
  216. data/spec/spec/runner/heckle_runner_spec.rb +1 -1
  217. data/spec/spec/runner/heckler_spec.rb +1 -1
  218. data/spec/spec/runner/line_number_query/line_number_query_fixture.rb +1 -1
  219. data/spec/spec/runner/line_number_query_spec.rb +10 -1
  220. data/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +22 -16
  221. data/spec/spec/runner/option_parser_spec.rb +48 -14
  222. data/spec/spec/runner/options_spec.rb +16 -2
  223. data/spec/spec/runner/output_one_time_fixture.rb +1 -1
  224. data/spec/spec/runner/output_one_time_fixture_runner.rb +2 -3
  225. data/spec/spec/runner/output_one_time_spec.rb +6 -7
  226. data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +65 -22
  227. data/spec/spec/runner/reporter_spec.rb +1 -1
  228. data/spec/spec/runner_spec.rb +1 -1
  229. data/spec/spec_helper.rb +5 -7
  230. data/spec/{spec → support}/spec_classes.rb +0 -0
  231. metadata +58 -17
  232. data/examples/failing/spec_helper.rb +0 -3
  233. data/examples/passing/spec_helper.rb +0 -3
  234. data/features/heckle/heckle.feature +0 -56
  235. data/spec/rspec_suite.rb +0 -6
  236. data/spec/spec/runner/formatter/html_formatted-1.8.4.html +0 -366
  237. data/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +0 -387
  238. data/spec/spec/runner/formatter/html_formatted-1.8.5.html +0 -372
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module BugReport496
4
4
  class BaseClass
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module BugReport600
4
4
  class ExampleClass
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Bug7611
4
4
  class Foo
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Bug7805
4
4
  #This is really a duplicate of 8302
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  describe "An object where respond_to? is true and does not have method" do
4
4
  # When should_receive(:sym) is sent to any object, the Proxy sends
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Bug8302
4
4
  class Foo
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe "double" do
4
+ it "is an alias for stub and mock" do
5
+ double().should be_a(Spec::Mocks::Mock)
6
+ end
7
+
8
+ it "uses 'Double' in failure messages" do
9
+ double = double('name')
10
+ expect {double.foo}.to raise_error(/Double "name" received/)
11
+ end
12
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -52,35 +52,35 @@ module Spec
52
52
  @mock.should_receive(:random_call).with(:a => "b", :c => "d")
53
53
  lambda do
54
54
  @mock.random_call(:a => "b", :c => "e")
55
- end.should raise_error(MockExpectationError, /Mock 'test mock' expected :random_call with \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\) but received it with \(\{(:a=>\"b\", :c=>\"e\"|:c=>\"e\", :a=>\"b\")\}\)/)
55
+ end.should raise_error(MockExpectationError, /Mock "test mock" received :random_call with unexpected arguments\n expected: \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\)\n got: \(\{(:a=>\"b\", :c=>\"e\"|:c=>\"e\", :a=>\"b\")\}\)/)
56
56
  end
57
57
 
58
58
  it "should fail for a hash w/ wrong keys" do
59
59
  @mock.should_receive(:random_call).with(:a => "b", :c => "d")
60
60
  lambda do
61
61
  @mock.random_call("a" => "b", "c" => "d")
62
- end.should raise_error(MockExpectationError, /Mock 'test mock' expected :random_call with \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\) but received it with \(\{(\"a\"=>\"b\", \"c\"=>\"d\"|\"c\"=>\"d\", \"a\"=>\"b\")\}\)/)
62
+ end.should raise_error(MockExpectationError, /Mock "test mock" received :random_call with unexpected arguments\n expected: \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\)\n got: \(\{(\"a\"=>\"b\", \"c\"=>\"d\"|\"c\"=>\"d\", \"a\"=>\"b\")\}\)/)
63
63
  end
64
64
 
65
65
  it "should match against a Matcher" do
66
66
  lambda do
67
67
  @mock.should_receive(:msg).with(equal(3))
68
68
  @mock.msg(37)
69
- end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (equal 3) but received it with (37)")
69
+ end.should raise_error(MockExpectationError, "Mock \"test mock\" received :msg with unexpected arguments\n expected: (equal 3)\n got: (37)")
70
70
  end
71
71
 
72
72
  it "should fail no_args with one arg" do
73
73
  lambda do
74
74
  @mock.should_receive(:msg).with(no_args)
75
75
  @mock.msg(37)
76
- end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (no args) but received it with (37)")
76
+ end.should raise_error(MockExpectationError, "Mock \"test mock\" received :msg with unexpected arguments\n expected: (no args)\n got: (37)")
77
77
  end
78
78
 
79
79
  it "should fail hash_including with missing key" do
80
80
  lambda do
81
81
  @mock.should_receive(:msg).with(hash_including(:a => 1))
82
82
  @mock.msg({})
83
- end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (hash_including(:a=>1)) but received it with ({})")
83
+ end.should raise_error(MockExpectationError, "Mock \"test mock\" received :msg with unexpected arguments\n expected: (hash_including(:a=>1))\n got: ({})")
84
84
  end
85
85
 
86
86
  it "should fail with block matchers" do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -36,7 +36,7 @@ module Spec
36
36
  @mock.should_receive(:two).ordered
37
37
  lambda do
38
38
  @mock.two
39
- end.should raise_error(MockExpectationError, "Mock 'test mock' received :two out of order")
39
+ end.should raise_error(MockExpectationError, "Mock \"test mock\" received :two out of order")
40
40
  end
41
41
 
42
42
  it "should fail if third call comes first" do
@@ -46,7 +46,7 @@ module Spec
46
46
  @mock.one
47
47
  lambda do
48
48
  @mock.three
49
- end.should raise_error(MockExpectationError, "Mock 'test mock' received :three out of order")
49
+ end.should raise_error(MockExpectationError, "Mock \"test mock\" received :three out of order")
50
50
  end
51
51
 
52
52
  it "should fail if third call comes second" do
@@ -56,7 +56,7 @@ module Spec
56
56
  @mock.one
57
57
  lambda do
58
58
  @mock.three
59
- end.should raise_error(MockExpectationError, "Mock 'test mock' received :three out of order")
59
+ end.should raise_error(MockExpectationError, "Mock \"test mock\" received :three out of order")
60
60
  end
61
61
 
62
62
  it "should ignore order of non ordered calls" do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
  require 'spec/mocks'
3
3
 
4
4
  module Spec
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -68,7 +68,7 @@ module Spec
68
68
  lambda {
69
69
  @mock.not_expected
70
70
  violated
71
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
71
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once")
72
72
  end
73
73
 
74
74
  it "should fail when receiving message specified as not to be received with args" do
@@ -76,7 +76,7 @@ module Spec
76
76
  lambda {
77
77
  @mock.not_expected("unexpected text")
78
78
  violated
79
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (\"unexpected text\") 0 times, but received it once")
79
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (\"unexpected text\") 0 times, but received it once")
80
80
  end
81
81
 
82
82
  it "should pass when receiving message specified as not to be received with wrong args" do
@@ -108,7 +108,7 @@ module Spec
108
108
  lambda {
109
109
  @mock.something("a","d","c")
110
110
  violated
111
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
111
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: (\"a\", \"d\", \"c\")")
112
112
  end
113
113
 
114
114
  it "should raise exception if args don't match when method called even when the method is stubbed" do
@@ -117,7 +117,7 @@ module Spec
117
117
  lambda {
118
118
  @mock.something("a","d","c")
119
119
  @mock.rspec_verify
120
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with ([\"a\", \"d\", \"c\"])")
120
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: ([\"a\", \"d\", \"c\"])")
121
121
  end
122
122
 
123
123
  it "should raise exception if args don't match when method called even when using null_object" do
@@ -126,14 +126,14 @@ module Spec
126
126
  lambda {
127
127
  @mock.something("a","d","c")
128
128
  @mock.rspec_verify
129
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with ([\"a\", \"d\", \"c\"])")
129
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: ([\"a\", \"d\", \"c\"])")
130
130
  end
131
131
 
132
132
  it "should fail if unexpected method called" do
133
133
  lambda {
134
134
  @mock.something("a","b","c")
135
135
  violated
136
- }.should raise_error(MockExpectationError, "Mock 'test mock' received unexpected message :something with (\"a\", \"b\", \"c\")")
136
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" received unexpected message :something with (\"a\", \"b\", \"c\")")
137
137
  end
138
138
 
139
139
  it "should use block for expectation if provided" do
@@ -150,21 +150,21 @@ module Spec
150
150
  @mock.should_receive(:something) {| bool | bool.should be_true}
151
151
  lambda {
152
152
  @mock.something false
153
- }.should raise_error(MockExpectationError, /Mock 'test mock' received :something but passed block failed with: expected true, got false/)
153
+ }.should raise_error(MockExpectationError, /Mock "test mock" received :something but passed block failed with: expected true, got false/)
154
154
  end
155
155
 
156
156
  it "should fail right away when method defined as never is received" do
157
157
  @mock.should_receive(:not_expected).never
158
158
  lambda {
159
159
  @mock.not_expected
160
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
160
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once")
161
161
  end
162
162
 
163
163
  it "should eventually fail when method defined as never is received" do
164
164
  @mock.should_receive(:not_expected).never
165
165
  lambda {
166
166
  @mock.not_expected
167
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
167
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once")
168
168
  end
169
169
 
170
170
  it "should raise when told to" do
@@ -224,14 +224,14 @@ module Spec
224
224
  @mock.should_receive(:something).with(no_args())
225
225
  lambda {
226
226
  @mock.something 1
227
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (no args) but received it with (1)")
227
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (no args)\n got: (1)")
228
228
  end
229
229
 
230
230
  it "should fail when args are expected but none are received" do
231
231
  @mock.should_receive(:something).with(1)
232
232
  lambda {
233
233
  @mock.something
234
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (1) but received it with (no args)")
234
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (1)\n got: (no args)")
235
235
  end
236
236
 
237
237
  it "should return value from block by default" do
@@ -339,7 +339,7 @@ module Spec
339
339
  @mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup')
340
340
  lambda {
341
341
  @mock.yield_back {|a|}
342
- }.should raise_error(MockExpectationError, "Mock 'test mock' yielded |\"wha\", \"zup\"| to block with arity of 1")
342
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" yielded |\"wha\", \"zup\"| to block with arity of 1")
343
343
  end
344
344
 
345
345
  it "should fail when calling yielding method consecutively with wrong arity" do
@@ -350,14 +350,14 @@ module Spec
350
350
  a, b = nil
351
351
  c = []
352
352
  @mock.yield_back {|a,b| c << [a, b]}
353
- }.should raise_error(MockExpectationError, "Mock 'test mock' yielded |\"down\"| to block with arity of 2")
353
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" yielded |\"down\"| to block with arity of 2")
354
354
  end
355
355
 
356
356
  it "should fail when calling yielding method without block" do
357
357
  @mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup')
358
358
  lambda {
359
359
  @mock.yield_back
360
- }.should raise_error(MockExpectationError, "Mock 'test mock' asked to yield |[\"wha\", \"zup\"]| but no block was passed")
360
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" asked to yield |[\"wha\", \"zup\"]| but no block was passed")
361
361
  end
362
362
 
363
363
  it "should be able to mock send" do
@@ -384,7 +384,7 @@ module Spec
384
384
  @mock.rspec_verify
385
385
  lambda {
386
386
  @mock.foobar
387
- }.should raise_error(MockExpectationError, "Mock 'test mock' received unexpected message :foobar with (no args)")
387
+ }.should raise_error(MockExpectationError, "Mock \"test mock\" received unexpected message :foobar with (no args)")
388
388
  end
389
389
 
390
390
  it "should restore objects to their original state on rspec_reset" do
@@ -569,15 +569,11 @@ module Spec
569
569
  end
570
570
 
571
571
  describe "mock created with no name" do
572
- it "should name itself 'mock'" do
573
- mock.to_s.should include('mock')
572
+ it "should not use a name in a failure message" do
573
+ mock = mock()
574
+ expect {mock.foo}.to raise_error(/Mock received/)
574
575
  end
575
-
576
- it "should name itself after initially stubbed methods" do
577
- string = mock(:foo => "woo", :bar => "car").to_s
578
- string.should include('foo: \"woo\"', 'bar: \"car\"')
579
- end
580
-
576
+
581
577
  it "should respond to initially stubbed methods" do
582
578
  mock = mock(:foo => "woo", :bar => "car")
583
579
  mock.foo.should == "woo"
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -20,7 +20,7 @@ module Spec
20
20
  third = Object.new
21
21
  @mock.message.should == @return_values[0]
22
22
  @mock.message.should == @return_values[1]
23
- lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it twice")
23
+ lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it twice")
24
24
  end
25
25
 
26
26
  it "should complain when there are too many calls" do
@@ -29,7 +29,7 @@ module Spec
29
29
  @mock.message.should == @return_values[1]
30
30
  @mock.message.should == @return_values[2]
31
31
  @mock.message.should == @return_values[2]
32
- lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times")
32
+ lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times")
33
33
  end
34
34
  end
35
35
 
@@ -51,7 +51,7 @@ module Spec
51
51
  third = Object.new
52
52
  @mock.message.should == @return_values[0]
53
53
  @mock.message.should == @return_values[1]
54
- lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it twice")
54
+ lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it twice")
55
55
  end
56
56
 
57
57
  it "should complain when there are too many calls" do
@@ -60,7 +60,7 @@ module Spec
60
60
  @mock.message.should == @return_values[1]
61
61
  @mock.message.should == @return_values[2]
62
62
  @mock.message.should == @return_values[2]
63
- lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times")
63
+ lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times")
64
64
  end
65
65
  end
66
66
 
@@ -79,7 +79,7 @@ module Spec
79
79
 
80
80
  it "should fail when called less than the specified number" do
81
81
  @mock.message.should equal(11)
82
- lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (no args) twice, but received it once")
82
+ lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (no args) twice, but received it once")
83
83
  end
84
84
  end
85
85
  describe "a Mock expectation with multiple return values with a specified count larger than the number of values" do
@@ -97,7 +97,7 @@ module Spec
97
97
 
98
98
  it "should fail when called less than the specified number" do
99
99
  @mock.message.should equal(11)
100
- lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it once")
100
+ lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it once")
101
101
  end
102
102
 
103
103
  it "should fail when called greater than the specified number" do
@@ -105,7 +105,7 @@ module Spec
105
105
  @mock.message.should equal(22)
106
106
  @mock.message.should equal(22)
107
107
  @mock.message.should equal(22)
108
- lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock 'mock' expected :message with (any args) 3 times, but received it 4 times")
108
+ lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times")
109
109
  end
110
110
  end
111
111
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  module Spec
4
4
  module Mocks