rspec 1.1.12 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. data/.autotest +2 -1
  2. data/.document +7 -0
  3. data/History.txt +58 -0
  4. data/License.txt +1 -1
  5. data/Manifest.txt +45 -82
  6. data/README.txt +3 -6
  7. data/Rakefile +33 -13
  8. data/Ruby1.9.markdown +32 -0
  9. data/TODO.txt +10 -4
  10. data/Upgrade.markdown +63 -0
  11. data/bin/spec +1 -1
  12. data/cucumber.yml +3 -0
  13. data/examples/failing/{failing_autogenerated_docstrings_example.rb → failing_implicit_docstrings_example.rb} +0 -0
  14. data/examples/failing/pending_example.rb +9 -0
  15. data/examples/failing/spec_helper.rb +1 -1
  16. data/examples/passing/{custom_expectation_matchers.rb → custom_matchers.rb} +0 -0
  17. data/examples/passing/filtered_formatter.rb +18 -0
  18. data/examples/passing/filtered_formatter_example.rb +31 -0
  19. data/examples/passing/implicit_docstrings_example.rb +18 -0
  20. data/examples/passing/spec_helper.rb +1 -1
  21. data/examples/ruby1.9.compatibility/access_to_constants_spec.rb +17 -18
  22. data/features/before_and_after_blocks/before_and_after_blocks.feature +4 -4
  23. data/features/example_groups/example_group_with_should_methods.feature +1 -1
  24. data/features/example_groups/{autogenerated_docstrings.feature → implicit_docstrings.feature} +7 -9
  25. data/features/example_groups/nested_groups.feature +1 -1
  26. data/features/heckle/heckle.feature +56 -0
  27. data/features/interop/examples_and_tests_together.feature +1 -1
  28. data/features/interop/test_but_not_test_unit.feature +1 -1
  29. data/features/interop/test_case_with_should_methods.feature +1 -1
  30. data/features/matchers/create_matcher.feature +115 -0
  31. data/features/mock_framework_integration/use_flexmock.feature +22 -4
  32. data/features/mock_framework_integration/use_mocha.feature +27 -0
  33. data/features/mock_framework_integration/use_rr.feature +27 -0
  34. data/features/mocks/mix_stubs_and_mocks.feature +22 -0
  35. data/features/pending/pending_examples.feature +81 -0
  36. data/features/step_definitions/running_rspec.rb +5 -3
  37. data/features/support/env.rb +1 -1
  38. data/features/support/matchers/smart_match.rb +2 -2
  39. data/lib/autotest/rspec.rb +1 -1
  40. data/lib/spec.rb +1 -1
  41. data/lib/{adapters → spec/adapters}/mock_frameworks/flexmock.rb +0 -0
  42. data/lib/{adapters → spec/adapters}/mock_frameworks/mocha.rb +0 -0
  43. data/lib/{adapters → spec/adapters}/mock_frameworks/rr.rb +0 -0
  44. data/lib/{adapters → spec/adapters}/mock_frameworks/rspec.rb +0 -1
  45. data/lib/spec/autorun.rb +3 -0
  46. data/lib/spec/dsl.rb +3 -1
  47. data/lib/spec/dsl/matchers.rb +13 -0
  48. data/lib/spec/example.rb +4 -0
  49. data/lib/spec/example/before_and_after_hooks.rb +5 -20
  50. data/lib/spec/example/errors.rb +3 -3
  51. data/lib/spec/example/example_description.rb +15 -0
  52. data/lib/spec/example/example_group.rb +0 -15
  53. data/lib/spec/example/example_group_factory.rb +34 -46
  54. data/lib/spec/example/example_group_hierarchy.rb +53 -0
  55. data/lib/spec/example/example_group_methods.rb +101 -211
  56. data/lib/spec/example/example_methods.rb +61 -81
  57. data/lib/spec/example/module_reopening_fix.rb +23 -1
  58. data/lib/spec/example/pending.rb +3 -2
  59. data/lib/spec/example/predicate_matchers.rb +47 -0
  60. data/lib/spec/example/subject.rb +91 -0
  61. data/lib/spec/expectations.rb +1 -1
  62. data/lib/spec/expectations/differs/default.rb +0 -1
  63. data/lib/spec/expectations/extensions.rb +0 -1
  64. data/lib/spec/expectations/handler.rb +13 -6
  65. data/lib/spec/interop/test.rb +5 -0
  66. data/lib/spec/interop/test/unit/testcase.rb +5 -22
  67. data/lib/spec/matchers.rb +22 -8
  68. data/lib/spec/matchers/be.rb +4 -9
  69. data/lib/spec/matchers/be_close.rb +20 -5
  70. data/lib/spec/matchers/be_instance_of.rb +45 -0
  71. data/lib/spec/matchers/be_kind_of.rb +45 -0
  72. data/lib/spec/matchers/change.rb +8 -6
  73. data/lib/spec/matchers/compatibility.rb +14 -0
  74. data/lib/spec/matchers/eql.rb +24 -6
  75. data/lib/spec/matchers/equal.rb +24 -6
  76. data/lib/spec/matchers/exist.rb +21 -5
  77. data/lib/spec/matchers/extensions/instance_exec.rb +25 -0
  78. data/lib/spec/matchers/generated_descriptions.rb +2 -2
  79. data/lib/spec/matchers/has.rb +28 -11
  80. data/lib/spec/matchers/have.rb +2 -2
  81. data/lib/spec/matchers/include.rb +2 -2
  82. data/lib/spec/matchers/match.rb +25 -7
  83. data/lib/spec/matchers/match_array.rb +3 -3
  84. data/lib/spec/matchers/matcher.rb +51 -0
  85. data/lib/spec/matchers/method_missing.rb +2 -2
  86. data/lib/spec/matchers/operator_matcher.rb +12 -5
  87. data/lib/spec/matchers/raise_error.rb +3 -3
  88. data/lib/spec/matchers/respond_to.rb +3 -3
  89. data/lib/spec/matchers/satisfy.rb +7 -7
  90. data/lib/spec/matchers/throw_symbol.rb +3 -5
  91. data/lib/spec/mocks.rb +3 -3
  92. data/lib/spec/mocks/argument_expectation.rb +15 -15
  93. data/lib/spec/mocks/{argument_constraints.rb → argument_matchers.rb} +19 -23
  94. data/lib/spec/mocks/error_generator.rb +5 -8
  95. data/lib/spec/mocks/framework.rb +1 -1
  96. data/lib/spec/mocks/message_expectation.rb +5 -13
  97. data/lib/spec/mocks/mock.rb +4 -5
  98. data/lib/spec/mocks/proxy.rb +9 -5
  99. data/lib/spec/mocks/spec_methods.rb +10 -1
  100. data/lib/spec/rake/spectask.rb +0 -1
  101. data/lib/spec/runner.rb +6 -28
  102. data/lib/spec/runner/configuration.rb +3 -3
  103. data/lib/spec/runner/drb_command_line.rb +2 -1
  104. data/lib/spec/runner/example_group_runner.rb +3 -2
  105. data/lib/spec/runner/formatter/base_text_formatter.rb +34 -19
  106. data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +3 -5
  107. data/lib/spec/runner/formatter/html_formatter.rb +2 -3
  108. data/lib/spec/runner/formatter/nested_text_formatter.rb +7 -25
  109. data/lib/spec/runner/formatter/progress_bar_formatter.rb +1 -1
  110. data/lib/spec/runner/formatter/snippet_extractor.rb +1 -1
  111. data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -7
  112. data/lib/spec/runner/heckle_runner.rb +3 -6
  113. data/lib/spec/runner/heckle_runner_unsupported.rb +1 -1
  114. data/lib/spec/runner/option_parser.rb +19 -21
  115. data/lib/spec/runner/options.rb +32 -27
  116. data/lib/spec/runner/reporter.rb +8 -9
  117. data/lib/spec/test/unit.rb +10 -0
  118. data/lib/spec/version.rb +2 -2
  119. data/{features/support → resources}/helpers/cmdline.rb +2 -2
  120. data/resources/rake/verify_rcov.rake +1 -1
  121. data/resources/spec/example_group_with_should_methods.rb +1 -1
  122. data/resources/spec/simple_spec.rb +1 -1
  123. data/resources/test/spec_and_test_together.rb +2 -3
  124. data/resources/test/spec_including_test_but_not_unit.rb +1 -1
  125. data/resources/test/test_case_with_should_methods.rb +2 -3
  126. data/spec/autotest/autotest_helper.rb +0 -1
  127. data/spec/autotest/rspec_spec.rb +95 -98
  128. data/spec/spec/dsl/main_spec.rb +3 -3
  129. data/spec/spec/dsl/matchers_spec.rb +25 -0
  130. data/spec/spec/example/example_group_class_definition_spec.rb +14 -15
  131. data/spec/spec/example/example_group_factory_spec.rb +31 -44
  132. data/spec/spec/example/example_group_methods_spec.rb +86 -52
  133. data/spec/spec/example/example_group_spec.rb +32 -79
  134. data/spec/spec/example/example_matcher_spec.rb +10 -10
  135. data/spec/spec/example/example_methods_spec.rb +108 -242
  136. data/spec/spec/example/nested_example_group_spec.rb +2 -2
  137. data/spec/spec/example/pending_module_spec.rb +66 -41
  138. data/spec/spec/example/shared_example_group_spec.rb +4 -4
  139. data/spec/spec/{matchers → expectations}/handler_spec.rb +52 -4
  140. data/spec/spec/interop/test/unit/resources/spec_that_fails.rb +2 -2
  141. data/spec/spec/interop/test/unit/resources/spec_that_passes.rb +2 -2
  142. data/spec/spec/interop/test/unit/resources/spec_with_errors.rb +2 -2
  143. data/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb +2 -2
  144. data/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +2 -2
  145. data/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +2 -2
  146. data/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +2 -2
  147. data/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +2 -2
  148. data/spec/spec/interop/test/unit/testcase_spec.rb +0 -4
  149. data/spec/spec/matchers/be_close_spec.rb +1 -1
  150. data/spec/spec/matchers/be_instance_of_spec.rb +29 -0
  151. data/spec/spec/matchers/be_kind_of_spec.rb +29 -0
  152. data/spec/spec/matchers/change_spec.rb +20 -0
  153. data/spec/spec/matchers/compatibility_spec.rb +34 -0
  154. data/spec/spec/matchers/description_generation_spec.rb +0 -12
  155. data/spec/spec/matchers/eql_spec.rb +2 -2
  156. data/spec/spec/matchers/equal_spec.rb +2 -2
  157. data/spec/spec/matchers/exist_spec.rb +8 -4
  158. data/spec/spec/matchers/have_spec.rb +4 -4
  159. data/spec/spec/matchers/match_spec.rb +2 -2
  160. data/spec/spec/matchers/matcher_methods_spec.rb +1 -1
  161. data/spec/spec/matchers/matcher_spec.rb +97 -0
  162. data/spec/spec/matchers/throw_symbol_spec.rb +8 -8
  163. data/spec/spec/mocks/{bug_report_496.rb → bug_report_496_spec.rb} +0 -0
  164. data/spec/spec/mocks/{failing_mock_argument_constraints_spec.rb → failing_argument_matchers_spec.rb} +2 -2
  165. data/spec/spec/mocks/hash_including_matcher_spec.rb +4 -4
  166. data/spec/spec/mocks/hash_not_including_matcher_spec.rb +3 -3
  167. data/spec/spec/mocks/mock_spec.rb +27 -2
  168. data/spec/spec/mocks/nil_expectation_warning_spec.rb +1 -1
  169. data/spec/spec/mocks/partial_mock_spec.rb +18 -3
  170. data/spec/spec/mocks/{passing_mock_argument_constraints_spec.rb → passing_argument_matchers_spec.rb} +6 -6
  171. data/spec/spec/mocks/stubbed_message_expectations_spec.rb +13 -1
  172. data/spec/spec/package/bin_spec_spec.rb +2 -2
  173. data/spec/spec/runner/configuration_spec.rb +12 -12
  174. data/spec/spec/runner/drb_command_line_spec.rb +71 -73
  175. data/spec/spec/runner/formatter/base_text_formatter_spec.rb +82 -1
  176. data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +8 -8
  177. data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +4 -4
  178. data/spec/spec/runner/formatter/html_formatted-1.8.6.html +8 -8
  179. data/spec/spec/runner/formatter/html_formatted-1.8.7.html +38 -26
  180. data/spec/spec/runner/formatter/html_formatted-1.9.1.html +61 -53
  181. data/spec/spec/runner/formatter/html_formatter_spec.rb +100 -48
  182. data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +20 -34
  183. data/spec/spec/runner/formatter/profile_formatter_spec.rb +2 -1
  184. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +9 -6
  185. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +6 -6
  186. data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +20 -20
  187. data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +38 -26
  188. data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +55 -47
  189. data/spec/spec/runner/formatter/{spec_mate_formatter_spec.rb → text_mate_formatter_spec.rb} +11 -9
  190. data/spec/spec/runner/heckle_runner_spec.rb +1 -1
  191. data/spec/spec/runner/heckler_spec.rb +1 -1
  192. data/spec/spec/runner/option_parser_spec.rb +28 -11
  193. data/spec/spec/runner/options_spec.rb +34 -0
  194. data/spec/spec/runner/reporter_spec.rb +66 -62
  195. data/spec/spec/runner/resources/utf8_encoded.rb +1 -0
  196. data/spec/spec/runner/spec_drb.opts +1 -0
  197. data/spec/spec/runner_spec.rb +7 -5
  198. data/spec/spec_helper.rb +24 -2
  199. metadata +49 -90
  200. data/examples/passing/autogenerated_docstrings_example.rb +0 -25
  201. data/examples/passing/before_and_after_example.rb +0 -40
  202. data/examples/passing/behave_as_example.rb +0 -45
  203. data/examples/passing/legacy_spec.rb +0 -11
  204. data/examples/passing/priority.txt +0 -1
  205. data/features/support/helpers/story_helper.rb +0 -16
  206. data/lib/spec/expectations/extensions/string_and_symbol.rb +0 -17
  207. data/lib/spec/runner/formatter/story/html_formatter.rb +0 -174
  208. data/lib/spec/runner/formatter/story/plain_text_formatter.rb +0 -194
  209. data/lib/spec/runner/formatter/story/progress_bar_formatter.rb +0 -42
  210. data/lib/spec/story.rb +0 -10
  211. data/lib/spec/story/extensions.rb +0 -3
  212. data/lib/spec/story/extensions/main.rb +0 -86
  213. data/lib/spec/story/extensions/regexp.rb +0 -9
  214. data/lib/spec/story/extensions/string.rb +0 -9
  215. data/lib/spec/story/given_scenario.rb +0 -14
  216. data/lib/spec/story/runner.rb +0 -57
  217. data/lib/spec/story/runner/plain_text_story_runner.rb +0 -48
  218. data/lib/spec/story/runner/scenario_collector.rb +0 -18
  219. data/lib/spec/story/runner/scenario_runner.rb +0 -54
  220. data/lib/spec/story/runner/story_mediator.rb +0 -137
  221. data/lib/spec/story/runner/story_parser.rb +0 -247
  222. data/lib/spec/story/runner/story_runner.rb +0 -74
  223. data/lib/spec/story/scenario.rb +0 -14
  224. data/lib/spec/story/step.rb +0 -70
  225. data/lib/spec/story/step_group.rb +0 -89
  226. data/lib/spec/story/step_mother.rb +0 -38
  227. data/lib/spec/story/story.rb +0 -39
  228. data/lib/spec/story/world.rb +0 -124
  229. data/resources/spec/spec_with_flexmock.rb +0 -19
  230. data/rspec.gemspec +0 -32
  231. data/spec/spec/matchers/mock_constraint_matchers_spec.rb +0 -24
  232. data/spec/spec/runner/formatter/story/html_formatter_spec.rb +0 -135
  233. data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +0 -600
  234. data/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb +0 -82
  235. data/spec/spec/spec_spec.rb +0 -21
  236. data/spec/spec/story/builders.rb +0 -46
  237. data/spec/spec/story/extensions/main_spec.rb +0 -161
  238. data/spec/spec/story/extensions_spec.rb +0 -14
  239. data/spec/spec/story/given_scenario_spec.rb +0 -27
  240. data/spec/spec/story/runner/plain_text_story_runner_spec.rb +0 -90
  241. data/spec/spec/story/runner/scenario_collector_spec.rb +0 -27
  242. data/spec/spec/story/runner/scenario_runner_spec.rb +0 -214
  243. data/spec/spec/story/runner/story_mediator_spec.rb +0 -143
  244. data/spec/spec/story/runner/story_parser_spec.rb +0 -401
  245. data/spec/spec/story/runner/story_runner_spec.rb +0 -294
  246. data/spec/spec/story/runner_spec.rb +0 -93
  247. data/spec/spec/story/scenario_spec.rb +0 -18
  248. data/spec/spec/story/step_group_spec.rb +0 -157
  249. data/spec/spec/story/step_mother_spec.rb +0 -84
  250. data/spec/spec/story/step_spec.rb +0 -272
  251. data/spec/spec/story/story_helper.rb +0 -2
  252. data/spec/spec/story/story_spec.rb +0 -84
  253. data/spec/spec/story/world_spec.rb +0 -423
  254. data/story_server/prototype/javascripts/builder.js +0 -136
  255. data/story_server/prototype/javascripts/controls.js +0 -972
  256. data/story_server/prototype/javascripts/dragdrop.js +0 -976
  257. data/story_server/prototype/javascripts/effects.js +0 -1117
  258. data/story_server/prototype/javascripts/prototype.js +0 -4140
  259. data/story_server/prototype/javascripts/rspec.js +0 -149
  260. data/story_server/prototype/javascripts/scriptaculous.js +0 -58
  261. data/story_server/prototype/javascripts/slider.js +0 -276
  262. data/story_server/prototype/javascripts/sound.js +0 -55
  263. data/story_server/prototype/javascripts/unittest.js +0 -568
  264. data/story_server/prototype/lib/server.rb +0 -24
  265. data/story_server/prototype/stories.html +0 -176
  266. data/story_server/prototype/stylesheets/rspec.css +0 -136
  267. data/story_server/prototype/stylesheets/test.css +0 -90
@@ -0,0 +1,34 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ Spec::Matchers.create :have_public_instance_method do |method|
4
+ match do |klass|
5
+ klass.public_instance_methods.include?(method)
6
+ end
7
+ end
8
+
9
+ module Spec
10
+ module Matchers
11
+ describe Spec::Matchers do
12
+ (Spec::Matchers.constants.sort).each do |c|
13
+ if (Class === (klass = Spec::Matchers.const_get(c)))
14
+ describe klass do
15
+ if klass.public_instance_methods.include?('failure_message_for_should')
16
+ describe "called with should" do
17
+ subject { klass }
18
+ it { should have_public_instance_method('failure_message_for_should')}
19
+ it { should have_public_instance_method('failure_message')}
20
+ end
21
+ end
22
+ if klass.public_instance_methods.include?('failure_message_for_should_not')
23
+ describe "called with should not" do
24
+ subject { klass }
25
+ it { should have_public_instance_method('failure_message_for_should_not')}
26
+ it { should have_public_instance_method('negative_failure_message')}
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -50,18 +50,6 @@ describe "Matchers should be able to generate their own descriptions" do
50
50
  Spec::Matchers.generated_description.should == "should be between 0 and 10"
51
51
  end
52
52
 
53
- it "should be_few_words predicate should be transformed to 'be few words'" do
54
- 5.should be_kind_of(Fixnum)
55
- Spec::Matchers.generated_description.should == "should be kind of Fixnum"
56
- end
57
-
58
- it "should preserve a proper prefix for be predicate" do
59
- 5.should be_a_kind_of(Fixnum)
60
- Spec::Matchers.generated_description.should == "should be a kind of Fixnum"
61
- 5.should be_an_instance_of(Fixnum)
62
- Spec::Matchers.generated_description.should == "should be an instance of Fixnum"
63
- end
64
-
65
53
  it "should equal" do
66
54
  expected = "expected"
67
55
  expected.should equal(expected)
@@ -17,12 +17,12 @@ module Spec
17
17
  it "should provide message, expected and actual on #failure_message" do
18
18
  matcher = eql("1")
19
19
  matcher.matches?(1)
20
- matcher.failure_message.should == ["expected \"1\", got 1 (using .eql?)", "1", 1]
20
+ matcher.failure_message_for_should.should == ["expected \"1\", got 1 (using .eql?)", "1", 1]
21
21
  end
22
22
  it "should provide message, expected and actual on #negative_failure_message" do
23
23
  matcher = eql(1)
24
24
  matcher.matches?(1)
25
- matcher.negative_failure_message.should == ["expected 1 not to equal 1 (using .eql?)", 1, 1]
25
+ matcher.failure_message_for_should_not.should == ["expected 1 not to equal 1 (using .eql?)", 1, 1]
26
26
  end
27
27
  end
28
28
  end
@@ -17,12 +17,12 @@ module Spec
17
17
  it "should provide message, expected and actual on #failure_message" do
18
18
  matcher = equal("1")
19
19
  matcher.matches?(1)
20
- matcher.failure_message.should == ["expected \"1\", got 1 (using .equal?)", "1", 1]
20
+ matcher.failure_message_for_should.should == ["expected \"1\", got 1 (using .equal?)", "1", 1]
21
21
  end
22
22
  it "should provide message, expected and actual on #negative_failure_message" do
23
23
  matcher = equal(1)
24
24
  matcher.matches?(1)
25
- matcher.negative_failure_message.should == ["expected 1 not to equal 1 (using .equal?)", 1, 1]
25
+ matcher.failure_message_for_should_not.should == ["expected 1 not to equal 1 (using .equal?)", 1, 1]
26
26
  end
27
27
  end
28
28
  end
@@ -23,7 +23,7 @@ class SubstanceTester
23
23
  end
24
24
  end
25
25
 
26
- describe "should exist," do
26
+ describe "should exist" do
27
27
 
28
28
  before(:each) do
29
29
  @real = Substance.new true, 'something real'
@@ -32,15 +32,19 @@ describe "should exist," do
32
32
 
33
33
  describe "within an example group" do
34
34
 
35
- it "should pass if target exists" do
35
+ it "passes if target exists" do
36
36
  @real.should exist
37
37
  end
38
38
 
39
- it "should fail if target does not exist" do
39
+ it "fails if target does not exist" do
40
40
  lambda { @imaginary.should exist }.should fail
41
41
  end
42
42
 
43
- it "should pass if target doesn't exist" do
43
+ it "describes itself" do
44
+ exist.description.should == "exists"
45
+ end
46
+
47
+ it "passes should_not exist if target doesn't exist" do
44
48
  lambda { @real.should_not exist }.should fail
45
49
  end
46
50
  end
@@ -212,7 +212,7 @@ describe "should have_at_least(n).items" do
212
212
  size_matcher.matches?(owner)
213
213
 
214
214
  #then
215
- length_matcher.negative_failure_message.should == <<-EOF
215
+ length_matcher.failure_message_for_should_not.should == <<-EOF
216
216
  Isn't life confusing enough?
217
217
  Instead of having to figure out the meaning of this:
218
218
  should_not have_at_least(3).items_in_collection_with_length_method
@@ -220,7 +220,7 @@ We recommend that you use this instead:
220
220
  should have_at_most(2).items_in_collection_with_length_method
221
221
  EOF
222
222
 
223
- size_matcher.negative_failure_message.should == <<-EOF
223
+ size_matcher.failure_message_for_should_not.should == <<-EOF
224
224
  Isn't life confusing enough?
225
225
  Instead of having to figure out the meaning of this:
226
226
  should_not have_at_least(3).items_in_collection_with_size_method
@@ -266,7 +266,7 @@ describe "should have_at_most(n).items" do
266
266
  size_matcher.matches?(owner)
267
267
 
268
268
  #then
269
- length_matcher.negative_failure_message.should == <<-EOF
269
+ length_matcher.failure_message_for_should_not.should == <<-EOF
270
270
  Isn't life confusing enough?
271
271
  Instead of having to figure out the meaning of this:
272
272
  should_not have_at_most(3).items_in_collection_with_length_method
@@ -274,7 +274,7 @@ We recommend that you use this instead:
274
274
  should have_at_least(4).items_in_collection_with_length_method
275
275
  EOF
276
276
 
277
- size_matcher.negative_failure_message.should == <<-EOF
277
+ size_matcher.failure_message_for_should_not.should == <<-EOF
278
278
  Isn't life confusing enough?
279
279
  Instead of having to figure out the meaning of this:
280
280
  should_not have_at_most(3).items_in_collection_with_size_method
@@ -14,7 +14,7 @@ describe "should match(expected)" do
14
14
  it "should provide message, expected and actual on failure" do
15
15
  matcher = match(/rings/)
16
16
  matcher.matches?("string")
17
- matcher.failure_message.should == ["expected \"string\" to match /rings/", /rings/, "string"]
17
+ matcher.failure_message_for_should.should == ["expected \"string\" to match /rings/", /rings/, "string"]
18
18
  end
19
19
  end
20
20
 
@@ -32,6 +32,6 @@ describe "should_not match(expected)" do
32
32
  it "should provide message, expected and actual on failure" do
33
33
  matcher = match(/tri/)
34
34
  matcher.matches?("string")
35
- matcher.negative_failure_message.should == ["expected \"string\" not to match /tri/", /tri/, "string"]
35
+ matcher.failure_message_for_should_not.should == ["expected \"string\" not to match /tri/", /tri/, "string"]
36
36
  end
37
37
  end
@@ -58,7 +58,7 @@ This module should provide the following methods, each of which returns a Matche
58
58
  end
59
59
 
60
60
  it "should convert have_xyz to Has(:have_xyz)" do
61
- self.should_receive(:has).with(:have_whatever)
61
+ Has.should_receive(:new).with(:have_whatever)
62
62
  have_whatever
63
63
  end
64
64
  end
@@ -0,0 +1,97 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Spec
4
+ module Matchers
5
+ describe Spec::Matchers::Matcher do
6
+ context "without overrides" do
7
+ before(:each) do
8
+ @matcher = Spec::Matchers::Matcher.new(:be_a_multiple_of, 3) do |multiple|
9
+ match do |actual|
10
+ actual % multiple == 0
11
+ end
12
+ end
13
+ end
14
+
15
+ it "provides a default description" do
16
+ @matcher.matches?(0)
17
+ @matcher.description.should == "be a multiple of 3"
18
+ end
19
+
20
+ it "provides a default failure message for #should" do
21
+ @matcher.matches?(8)
22
+ @matcher.failure_message_for_should.should == "expected 8 to be a multiple of 3"
23
+ end
24
+
25
+ it "provides a default failure message for #should_not" do
26
+ @matcher.matches?(9)
27
+ @matcher.failure_message_for_should_not.should == "expected 9 not to be a multiple of 3"
28
+ end
29
+ end
30
+
31
+ context "with overrides" do
32
+ before(:each) do
33
+ @matcher = Spec::Matchers::Matcher.new(:be_boolean, true) do |boolean|
34
+ match do |actual|
35
+ actual
36
+ end
37
+ description do
38
+ "be the boolean #{boolean}"
39
+ end
40
+ failure_message_for_should do |actual|
41
+ "expected #{actual} to be the boolean #{boolean}"
42
+ end
43
+ failure_message_for_should_not do |actual|
44
+ "expected #{actual} not to be the boolean #{boolean}"
45
+ end
46
+ end
47
+ end
48
+
49
+ it "does not hide result of match block when true" do
50
+ @matcher.matches?(true).should be_true
51
+ end
52
+
53
+ it "does not hide result of match block when false" do
54
+ @matcher.matches?(false).should be_false
55
+ end
56
+
57
+ it "overrides the description" do
58
+ @matcher.matches?(true)
59
+ @matcher.description.should == "be the boolean true"
60
+ end
61
+
62
+ it "overrides the failure message for #should" do
63
+ @matcher.matches?(false)
64
+ @matcher.failure_message_for_should.should == "expected false to be the boolean true"
65
+ end
66
+
67
+ it "overrides the failure message for #should_not" do
68
+ @matcher.matches?(true)
69
+ @matcher.failure_message_for_should_not.should == "expected true not to be the boolean true"
70
+ end
71
+ end
72
+
73
+ context "#new" do
74
+ it "passes matches? arg to match block" do
75
+ matcher = Spec::Matchers::Matcher.new(:ignore) do
76
+ match do |actual|
77
+ actual == 5
78
+ end
79
+ end
80
+ matcher.matches?(5).should be_true
81
+ end
82
+
83
+ it "exposes arg submitted through #new to matcher block" do
84
+ matcher = Spec::Matchers::Matcher.new(:ignore, 4) do |expected|
85
+ match do |actual|
86
+ actual > expected
87
+ end
88
+ end
89
+ matcher.matches?(5).should be_true
90
+ end
91
+ end
92
+
93
+ context "matching with overrides" do
94
+ end
95
+ end
96
+ end
97
+ end
@@ -17,11 +17,11 @@ module Spec
17
17
  end
18
18
  it "should provide a failure message" do
19
19
  @matcher.matches?(lambda{})
20
- @matcher.failure_message.should == "expected a Symbol but nothing was thrown"
20
+ @matcher.failure_message_for_should.should == "expected a Symbol but nothing was thrown"
21
21
  end
22
22
  it "should provide a negative failure message" do
23
23
  @matcher.matches?(lambda{ throw :sym})
24
- @matcher.negative_failure_message.should == "expected no Symbol, got :sym"
24
+ @matcher.failure_message_for_should_not.should == "expected no Symbol, got :sym"
25
25
  end
26
26
  end
27
27
 
@@ -42,15 +42,15 @@ module Spec
42
42
  end
43
43
  it "should provide a failure message when no Symbol is thrown" do
44
44
  @matcher.matches?(lambda{})
45
- @matcher.failure_message.should == "expected :sym but nothing was thrown"
45
+ @matcher.failure_message_for_should.should == "expected :sym but nothing was thrown"
46
46
  end
47
47
  it "should provide a failure message when wrong Symbol is thrown" do
48
48
  @matcher.matches?(lambda{ throw :other_sym })
49
- @matcher.failure_message.should == "expected :sym, got :other_sym"
49
+ @matcher.failure_message_for_should.should == "expected :sym, got :other_sym"
50
50
  end
51
51
  it "should provide a negative failure message" do
52
52
  @matcher.matches?(lambda{ throw :sym })
53
- @matcher.negative_failure_message.should == "expected :sym not to be thrown"
53
+ @matcher.failure_message_for_should_not.should == "expected :sym not to be thrown"
54
54
  end
55
55
  it "should only match NameErrors raised by uncaught throws" do
56
56
  @matcher.matches?(lambda{ sym }).should be_false
@@ -77,15 +77,15 @@ module Spec
77
77
  end
78
78
  it "should provide a failure message when no Symbol is thrown" do
79
79
  @matcher.matches?(lambda{})
80
- @matcher.failure_message.should == %q[expected :sym with "a" but nothing was thrown]
80
+ @matcher.failure_message_for_should.should == %q[expected :sym with "a" but nothing was thrown]
81
81
  end
82
82
  it "should provide a failure message when wrong Symbol is thrown" do
83
83
  @matcher.matches?(lambda{ throw :other_sym })
84
- @matcher.failure_message.should == %q[expected :sym with "a", got :other_sym]
84
+ @matcher.failure_message_for_should.should == %q[expected :sym with "a", got :other_sym]
85
85
  end
86
86
  it "should provide a negative failure message" do
87
87
  @matcher.matches?(lambda{ throw :sym })
88
- @matcher.negative_failure_message.should == %q[expected :sym with "a" not to be thrown]
88
+ @matcher.failure_message_for_should_not.should == %q[expected :sym with "a" not to be thrown]
89
89
  end
90
90
  it "should only match NameErrors raised by uncaught throws" do
91
91
  @matcher.matches?(lambda{ sym }).should be_false
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  module Spec
4
4
  module Mocks
5
- describe "failing MockArgumentConstraints" do
5
+ describe "failing MockArgumentMatchers" do
6
6
  before(:each) do
7
7
  @mock = mock("test mock")
8
8
  @reporter = Mock.new("reporter", :null_object => true)
@@ -83,7 +83,7 @@ module Spec
83
83
  end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (hash_including(:a=>1)) but received it with ({})")
84
84
  end
85
85
 
86
- it "should fail with block constraints" do
86
+ it "should fail with block matchers" do
87
87
  lambda do
88
88
  @mock.should_receive(:msg).with {|arg| arg.should == :received }
89
89
  @mock.msg :no_msg_for_you
@@ -2,11 +2,11 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  module Spec
4
4
  module Mocks
5
- module ArgumentConstraints
6
- describe HashIncludingConstraint do
5
+ module ArgumentMatchers
6
+ describe HashIncludingMatcher do
7
7
 
8
8
  it "should describe itself properly" do
9
- HashIncludingConstraint.new(:a => 1).description.should == "hash_including(:a=>1)"
9
+ HashIncludingMatcher.new(:a => 1).description.should == "hash_including(:a=>1)"
10
10
  end
11
11
 
12
12
  describe "passing" do
@@ -18,7 +18,7 @@ module Spec
18
18
  hash_including(:a => 1).should == {:a => 1, :b => 2}
19
19
  end
20
20
 
21
- describe "when matching against other constraints" do
21
+ describe "when matching against other matchers" do
22
22
  it "should match an int against anything()" do
23
23
  hash_including(:a => anything, :b => 2).should == {:a => 1, :b => 2}
24
24
  end
@@ -2,11 +2,11 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  module Spec
4
4
  module Mocks
5
- module ArgumentConstraints
6
- describe HashNotIncludingConstraint do
5
+ module ArgumentMatchers
6
+ describe HashNotIncludingMatcher do
7
7
 
8
8
  it "should describe itself properly" do
9
- HashNotIncludingConstraint.new(:a => 5).description.should == "hash_not_including(:a=>5)"
9
+ HashNotIncludingMatcher.new(:a => 5).description.should == "hash_not_including(:a=>5)"
10
10
  end
11
11
 
12
12
  describe "passing" do
@@ -11,6 +11,21 @@ module Spec
11
11
  @mock.rspec_reset
12
12
  end
13
13
 
14
+ describe "deprecated #stub_everything method" do
15
+ before(:each) do
16
+ Kernel.stub!(:warn)
17
+ end
18
+
19
+ it "creates a mock that behaves as a null object" do
20
+ stub_everything.should be_null_object
21
+ end
22
+
23
+ it "provides deprecation warning" do
24
+ Kernel.should_receive(:warn).with(/DEPRECATION: stub_everything.* is deprecated./)
25
+ stub_everything
26
+ end
27
+ end
28
+
14
29
  it "should report line number of expectation of unreceived message" do
15
30
  expected_error_line = __LINE__; @mock.should_receive(:wont_happen).with("x", 3)
16
31
  begin
@@ -100,7 +115,7 @@ module Spec
100
115
  lambda {
101
116
  @mock.something("a","d","c")
102
117
  @mock.rspec_verify
103
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
118
+ }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with ([\"a\", \"d\", \"c\"])")
104
119
  end
105
120
 
106
121
  it "should raise exception if args don't match when method called even when using null_object" do
@@ -109,7 +124,7 @@ module Spec
109
124
  lambda {
110
125
  @mock.something("a","d","c")
111
126
  @mock.rspec_verify
112
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
127
+ }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with ([\"a\", \"d\", \"c\"])")
113
128
  end
114
129
 
115
130
  it "should fail if unexpected method called" do
@@ -550,5 +565,15 @@ module Spec
550
565
  valid_html_str.should_not include('<')
551
566
  end
552
567
  end
568
+
569
+ describe "==" do
570
+ it "sends '== self' to the comparison object" do
571
+ first = mock('first')
572
+ second = mock('second')
573
+
574
+ first.should_receive(:==).with(second)
575
+ second == first
576
+ end
577
+ end
553
578
  end
554
579
  end
@@ -33,7 +33,7 @@ module Spec
33
33
  describe "#allow_message_expectations_on_nil" do
34
34
 
35
35
  it "should not effect subsequent examples" do
36
- example_group = Class.new(ExampleGroup)
36
+ example_group = Class.new(::Spec::Example::ExampleGroupDouble)
37
37
  example_group.it("when called in one example that doesn't end up setting an expectation on nil") do
38
38
  allow_message_expectations_on_nil
39
39
  end