rspec 1.2.8 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -18,13 +18,13 @@ Feature: custom formatters
18
18
  end
19
19
  """
20
20
  And a file named "simple_example_spec.rb" with:
21
- """
21
+ """
22
22
  describe "my group" do
23
23
  specify "my example" do
24
24
  end
25
25
  end
26
- """
26
+ """
27
27
 
28
28
  When I run "spec simple_example_spec.rb --require custom_formatter.rb --format CustomFormatter"
29
29
  Then the exit code should be 0
30
- And the stdout should match "example: my example"
30
+ And the stdout should include "example: my example"
@@ -61,18 +61,22 @@ Feature: Spec and test together
61
61
  def test_should_fail_with_before_block_variable
62
62
  @from_before.should == 50
63
63
  end
64
+
65
+ define_method :"test: should run with strange name" do
66
+ assert true
67
+ end
64
68
  end
65
69
  """
66
70
 
67
71
  When I run "<Command> spec_and_test_together.rb -fs"
68
72
 
69
73
  Then the exit code should be 256
70
- And the stdout should match "ATest"
71
- And the stdout should match "Test::Unit::AssertionFailedError in 'An Example should fail with assert'"
72
- And the stdout should match "'An Example should fail with should' FAILED"
73
- And the stdout should match "10 examples, 6 failures"
74
- And the stdout should match /expected: 40,\s*got: 4/m
75
- And the stdout should match /expected: 50,\s*got: 5/m
74
+ And the stdout should include "ATest"
75
+ And the stdout should include "Test::Unit::AssertionFailedError in 'An Example should fail with assert'"
76
+ And the stdout should include "'An Example should fail with should' FAILED"
77
+ And the stdout should include "11 examples, 6 failures"
78
+ And the stdout should include /expected: 40,\s*got: 4/m
79
+ And the stdout should include /expected: 50,\s*got: 5/m
76
80
 
77
81
  Scenarios: run with ruby and spec
78
82
  | Command |
@@ -17,7 +17,7 @@ Feature: spec output
17
17
  When I run "<Command> simple_spec.rb"
18
18
  Then the exit code should be 0
19
19
  And the stdout should not match /\d+ tests, \d+ assertions, \d+ failures, \d+ errors/m
20
- And the stdout should match "1 example, 0 failures"
20
+ And the stdout should include "1 example, 0 failures"
21
21
 
22
22
  Scenarios: Run with ruby and CommandLine object
23
23
  | Command |
@@ -38,7 +38,7 @@ Story: Test::Unit::TestCase extended by rspec with should methods
38
38
  """
39
39
  When I run "<Command> test_case_with_should_methods.rb"
40
40
  Then the exit code should be 256
41
- And the stdout should match "5 examples, 3 failures"
41
+ And the stdout should include "5 examples, 3 failures"
42
42
 
43
43
  Scenarios: Run with ruby and spec
44
44
  | Command |
@@ -0,0 +1,20 @@
1
+ Feature: add ./lib to load path
2
+ In order to ...
3
+ As a spec author
4
+ I want rspec to add ./lib to the load path
5
+
6
+ Scenario: spec helper
7
+ Given a directory named "spec"
8
+ And a file named "example.rb" with:
9
+ """
10
+ describe $LOAD_PATH do
11
+ it "begins with 'lib' in the current directory in the load path" do
12
+ libdir = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
13
+ $LOAD_PATH.should include(libdir)
14
+ end
15
+ end
16
+ """
17
+ When I run "spec example.rb"
18
+ Then the stdout should include "1 example, 0 failures"
19
+ And the exit code should be 0
20
+
@@ -0,0 +1,20 @@
1
+ Feature: add 'spec' to load path
2
+ In order to ...
3
+ As a spec author
4
+ I want rspec to add 'spec to the load path
5
+
6
+ Scenario: add 'spec' to load path
7
+ Given a directory named "spec"
8
+ And a file named "example.rb" with:
9
+ """
10
+ describe $LOAD_PATH do
11
+ it "includes with 'spec' in the current directory in the load path" do
12
+ specdir = File.expand_path(File.join(File.dirname(__FILE__), 'spec'))
13
+ $LOAD_PATH.should include(specdir)
14
+ end
15
+ end
16
+ """
17
+ When I run "spec example.rb"
18
+ Then the stdout should include "1 example, 0 failures"
19
+ And the exit code should be 0
20
+
@@ -22,5 +22,5 @@ Feature: define diffable matcher
22
22
  When I run "spec diffable_matcher_spec.rb --diff"
23
23
  Then the exit code should be 256
24
24
 
25
- And the stdout should match "should be just like \"that\""
26
- And the stdout should match "Diff:\n@@ -1,2 +1,2 @@\n-that\n+this"
25
+ And the stdout should include "should be just like \"that\""
26
+ And the stdout should include "Diff:\n@@ -1,2 +1,2 @@\n-that\n+this"
@@ -35,14 +35,14 @@ Feature: define matcher
35
35
  When I run "spec matcher_with_default_message_spec.rb --format specdoc"
36
36
  Then the exit code should be 256
37
37
 
38
- And the stdout should match "should be a multiple of 3"
39
- And the stdout should match "should not be a multiple of 4"
40
- And the stdout should match "should be a multiple of 4 (FAILED - 1)"
41
- And the stdout should match "should not be a multiple of 3 (FAILED - 2)"
38
+ And the stdout should include "should be a multiple of 3"
39
+ And the stdout should include "should not be a multiple of 4"
40
+ And the stdout should include "should be a multiple of 4 (FAILED - 1)"
41
+ And the stdout should include "should not be a multiple of 3 (FAILED - 2)"
42
42
 
43
- And the stdout should match "4 examples, 2 failures"
44
- And the stdout should match "expected 9 to be a multiple of 4"
45
- And the stdout should match "expected 9 not to be a multiple of 3"
43
+ And the stdout should include "4 examples, 2 failures"
44
+ And the stdout should include "expected 9 to be a multiple of 4"
45
+ And the stdout should include "expected 9 not to be a multiple of 3"
46
46
 
47
47
  Scenario: overriding the failure_message_for_should
48
48
  Given a file named "matcher_with_failure_message_spec.rb" with:
@@ -63,8 +63,8 @@ Feature: define matcher
63
63
  """
64
64
  When I run "spec matcher_with_failure_message_spec.rb"
65
65
  Then the exit code should be 256
66
- And the stdout should match "1 example, 1 failure"
67
- And the stdout should match "expected that 9 would be a multiple of 4"
66
+ And the stdout should include "1 example, 1 failure"
67
+ And the stdout should include "expected that 9 would be a multiple of 4"
68
68
 
69
69
  Scenario: overriding the failure_message_for_should_not
70
70
  Given a file named "matcher_with_failure_for_message_spec.rb" with:
@@ -85,8 +85,8 @@ Feature: define matcher
85
85
  """
86
86
  When I run "spec matcher_with_failure_for_message_spec.rb"
87
87
  Then the exit code should be 256
88
- And the stdout should match "1 example, 1 failure"
89
- And the stdout should match "expected that 9 would not be a multiple of 3"
88
+ And the stdout should include "1 example, 1 failure"
89
+ And the stdout should include "expected that 9 would not be a multiple of 3"
90
90
 
91
91
  Scenario: overriding the description
92
92
  Given a file named "matcher_overriding_description_spec.rb" with:
@@ -110,9 +110,9 @@ Feature: define matcher
110
110
  """
111
111
  When I run "spec matcher_overriding_description_spec.rb --format specdoc"
112
112
  Then the exit code should be 0
113
- And the stdout should match "2 examples, 0 failures"
114
- And the stdout should match "should be multiple of 3"
115
- And the stdout should match "should not be multiple of 4"
113
+ And the stdout should include "2 examples, 0 failures"
114
+ And the stdout should include "should be multiple of 3"
115
+ And the stdout should include "should not be multiple of 4"
116
116
 
117
117
  Scenario: with no args
118
118
  Given a file named "matcher_with_no_args_spec.rb" with:
@@ -133,8 +133,8 @@ Feature: define matcher
133
133
  """
134
134
  When I run "spec matcher_with_no_args_spec.rb --format specdoc"
135
135
  Then the exit code should be 0
136
- And the stdout should match "1 example, 0 failures"
137
- And the stdout should match "should have 7 fingers"
136
+ And the stdout should include "1 example, 0 failures"
137
+ And the stdout should include "should have 7 fingers"
138
138
 
139
139
  Scenario: with multiple args
140
140
  Given a file named "matcher_with_multiple_args_spec.rb" with:
@@ -151,8 +151,8 @@ Feature: define matcher
151
151
  """
152
152
  When I run "spec matcher_with_multiple_args_spec.rb --format specdoc"
153
153
  Then the exit code should be 0
154
- And the stdout should match "1 example, 0 failures"
155
- And the stdout should match "should be the sum of 1, 2, 3, and 4"
154
+ And the stdout should include "1 example, 0 failures"
155
+ And the stdout should include "should be the sum of 1, 2, 3, and 4"
156
156
 
157
157
  Scenario: with helper methods
158
158
  Given a file named "matcher_with_internal_helper_spec.rb" with:
@@ -175,5 +175,5 @@ Feature: define matcher
175
175
  """
176
176
  When I run "spec matcher_with_internal_helper_spec.rb"
177
177
  Then the exit code should be 0
178
- And the stdout should match "1 example, 0 failures"
178
+ And the stdout should include "1 example, 0 failures"
179
179
 
@@ -7,7 +7,6 @@ Feature: define matcher outside rspec
7
7
  Scenario: define a matcher with default messages
8
8
  Given a file named "test_multiples.rb" with:
9
9
  """
10
- $:.unshift File.join(File.dirname(__FILE__), "/../../lib")
11
10
  require 'test/unit'
12
11
  require 'spec/expectations'
13
12
 
@@ -35,5 +34,5 @@ Feature: define matcher outside rspec
35
34
  """
36
35
  When I run "ruby test_multiples.rb"
37
36
  Then the exit code should be 256
38
- And the stdout should match "expected 9 to be a multiple of 4"
39
- And the stdout should match "2 tests, 0 assertions, 1 failures, 0 errors"
37
+ And the stdout should include "expected 9 to be a multiple of 4"
38
+ And the stdout should include "2 tests, 0 assertions, 1 failures, 0 errors"
@@ -23,5 +23,5 @@ Feature: define matcher
23
23
  end
24
24
  """
25
25
  When I run "spec between_spec.rb --format specdoc"
26
- Then the stdout should match "1 example, 0 failures"
27
- And the stdout should match "should be bigger than 4"
26
+ Then the stdout should include "1 example, 0 failures"
27
+ And the stdout should include "should be bigger than 4"
@@ -0,0 +1,29 @@
1
+ Feature: define wrapped matcher
2
+
3
+ In order to reuse existing matchers
4
+ As an RSpec user
5
+ I want to define matchers that wrap other matchers
6
+
7
+ Scenario: one additional method
8
+ Given a file named "new_model_spec.rb" with:
9
+ """
10
+ Spec::Matchers.define :have_tag do |tag|
11
+ match do |markup|
12
+ markup =~ /<#{tag}>.*<\/#{tag}>/
13
+ end
14
+ end
15
+
16
+ Spec::Matchers.define :have_button do
17
+ match do |markup|
18
+ markup.should have_tag('button')
19
+ end
20
+ end
21
+
22
+ describe "some markup" do
23
+ it "has a button" do
24
+ "<button>Label</button>".should have_button
25
+ end
26
+ end
27
+ """
28
+ When I run "spec new_model_spec.rb --format specdoc"
29
+ Then the stdout should include "1 example, 0 failures"
@@ -24,4 +24,4 @@ Feature: mock with flexmock
24
24
  """
25
25
  When I run "spec flexmock_example_spec.rb"
26
26
  Then the exit code should be 0
27
- And the stdout should match "2 examples, 0 failures"
27
+ And the stdout should include "2 examples, 0 failures"
@@ -24,4 +24,4 @@ Feature: mock with mocha
24
24
  """
25
25
  When I run "spec mocha_example_spec.rb"
26
26
  Then the exit code should be 0
27
- And the stdout should match "2 examples, 0 failures"
27
+ And the stdout should include "2 examples, 0 failures"
@@ -24,4 +24,4 @@ Feature: mock with rr
24
24
  """
25
25
  When I run "spec rr_example_spec.rb"
26
26
  Then the exit code should be 0
27
- And the stdout should match "2 examples, 0 failures"
27
+ And the stdout should include "2 examples, 0 failures"
@@ -1,4 +1,4 @@
1
- Feature: Spec and test together
1
+ Feature: stub and mock together
2
2
 
3
3
  As an RSpec user
4
4
  I want to use stubs and mocks together
@@ -19,4 +19,4 @@ Feature: Spec and test together
19
19
  end
20
20
  """
21
21
  When I run "spec stub_and_mocks_spec.rb --format nested"
22
- Then the stdout should match "expected :foo with (\"first\") but received it with ([\"second\"], [\"third\"])"
22
+ Then the stdout should include "received :foo with unexpected arguments\n expected: (\"first\")\n got: ([\"second\"], [\"third\"])"
@@ -23,4 +23,4 @@ Feature: stub implementation
23
23
  end
24
24
  """
25
25
  When I run "spec stub_implementation.rb"
26
- Then the stdout should match "1 example, 0 failures"
26
+ Then the stdout should include "1 example, 0 failures"
@@ -12,9 +12,9 @@ Feature: pending examples
12
12
  """
13
13
  When I run "spec example_without_block_spec.rb"
14
14
  Then the exit code should be 0
15
- And the stdout should match "1 example, 0 failures, 1 pending"
16
- And the stdout should match "Not Yet Implemented"
17
- And the stdout should match "example_without_block_spec.rb:2"
15
+ And the stdout should include "1 example, 0 failures, 1 pending"
16
+ And the stdout should include "Not Yet Implemented"
17
+ And the stdout should include "example_without_block_spec.rb:2"
18
18
 
19
19
  Scenario: pending implementation with spec/test/unit
20
20
  Given a file named "example_without_block_spec.rb" with:
@@ -26,9 +26,9 @@ Feature: pending examples
26
26
  """
27
27
  When I run "spec example_without_block_spec.rb"
28
28
  Then the exit code should be 0
29
- And the stdout should match "1 example, 0 failures, 1 pending"
30
- And the stdout should match "Not Yet Implemented"
31
- And the stdout should match "example_without_block_spec.rb:3"
29
+ And the stdout should include "1 example, 0 failures, 1 pending"
30
+ And the stdout should include "Not Yet Implemented"
31
+ And the stdout should include "example_without_block_spec.rb:3"
32
32
 
33
33
  Scenario: pending any arbitary reason, with no block
34
34
  Given a file named "pending_without_block_spec.rb" with:
@@ -41,9 +41,9 @@ Feature: pending examples
41
41
  """
42
42
  When I run "spec pending_without_block_spec.rb"
43
43
  Then the exit code should be 0
44
- And the stdout should match "1 example, 0 failures, 1 pending"
45
- And the stdout should match "(something else getting finished)"
46
- And the stdout should match "pending_without_block_spec.rb:2"
44
+ And the stdout should include "1 example, 0 failures, 1 pending"
45
+ And the stdout should include "(something else getting finished)"
46
+ And the stdout should include "pending_without_block_spec.rb:2"
47
47
 
48
48
  Scenario: pending any arbitary reason, with a block that fails
49
49
  Given a file named "pending_with_failing_block_spec.rb" with:
@@ -58,9 +58,9 @@ Feature: pending examples
58
58
  """
59
59
  When I run "spec pending_with_failing_block_spec.rb"
60
60
  Then the exit code should be 0
61
- And the stdout should match "1 example, 0 failures, 1 pending"
62
- And the stdout should match "(something else getting finished)"
63
- And the stdout should match "pending_with_failing_block_spec.rb:2"
61
+ And the stdout should include "1 example, 0 failures, 1 pending"
62
+ And the stdout should include "(something else getting finished)"
63
+ And the stdout should include "pending_with_failing_block_spec.rb:2"
64
64
 
65
65
  Scenario: pending any arbitary reason, with a block that passes
66
66
  Given a file named "pending_with_passing_block_spec.rb" with:
@@ -75,7 +75,7 @@ Feature: pending examples
75
75
  """
76
76
  When I run "spec pending_with_passing_block_spec.rb"
77
77
  Then the exit code should be 256
78
- And the stdout should match "1 example, 1 failure"
79
- And the stdout should match "FIXED"
80
- And the stdout should match "Expected pending 'something else getting finished' to fail. No Error was raised."
81
- And the stdout should match "pending_with_passing_block_spec.rb:3"
78
+ And the stdout should include "1 example, 1 failure"
79
+ And the stdout should include "FIXED"
80
+ And the stdout should include "Expected pending 'something else getting finished' to fail. No Error was raised."
81
+ And the stdout should include "pending_with_passing_block_spec.rb:3"
@@ -14,8 +14,8 @@ Feature: run specific examples by line number
14
14
  end
15
15
  """
16
16
  When I run "spec example_spec.rb --line 2"
17
- Then the stdout should match "1 example, 0 failures, 1 pending"
18
- And the stdout should match "example_spec.rb:2"
17
+ Then the stdout should include "1 example, 0 failures, 1 pending"
18
+ And the stdout should include "example_spec.rb:2"
19
19
 
20
20
  Scenario: colon line syntax on single example
21
21
  Given a file named "example_spec.rb" with:
@@ -28,5 +28,5 @@ Feature: run specific examples by line number
28
28
  end
29
29
  """
30
30
  When I run "spec example_spec.rb:2"
31
- Then the stdout should match "1 example, 0 failures, 1 pending"
32
- And the stdout should match "example_spec.rb:2"
31
+ Then the stdout should include "1 example, 0 failures, 1 pending"
32
+ And the stdout should include "example_spec.rb:2"
@@ -0,0 +1,25 @@
1
+ Feature: spec helper
2
+ In order to centralize code needed across most specs
3
+ As a spec author
4
+ I want to require 'spec_helper'
5
+
6
+ Because rspec adds the PROJECT_ROOT/spec directory to the load path, we can
7
+ just require 'spec_helper' and it will be found.
8
+
9
+ Scenario: spec helper
10
+ Given a directory named "spec"
11
+ And a file named "spec/spec_helper.rb" with:
12
+ """
13
+ SOME_CONSTANT = 'some value'
14
+ """
15
+ And a file named "example.rb" with:
16
+ """
17
+ require 'spec_helper'
18
+ describe SOME_CONSTANT do
19
+ it { should == 'some value' }
20
+ end
21
+ """
22
+ When I run "spec example.rb"
23
+ And the stdout should include "1 example, 0 failures"
24
+ And the exit code should be 0
25
+
@@ -2,6 +2,9 @@ Given %r{^a file named "([^"]+)" with:$} do |file_name, code|
2
2
  create_file(file_name, code)
3
3
  end
4
4
 
5
+ Given /^a directory named "([^\"]*)"$/ do |dirname|
6
+ create_directory(dirname)
7
+ end
5
8
 
6
9
  When %r{^I run "spec ([^"]+)"$} do |file_and_args|
7
10
  spec(file_and_args)
@@ -15,8 +18,7 @@ When %r{^I run "cmdline.rb ([^"]+)"$} do |file_and_args|
15
18
  cmdline(file_and_args)
16
19
  end
17
20
 
18
-
19
- Then /^the (.*) should match (.*)$/ do |stream, string_or_regex|
21
+ Then /^the (.*) should include (.*)$/ do |stream, string_or_regex|
20
22
  written = case(stream)
21
23
  when 'stdout' then last_stdout
22
24
  when 'stderr' then last_stderr
@@ -13,7 +13,7 @@ Feature: explicit subject
13
13
  end
14
14
  """
15
15
  When I run "spec top_level_subject_spec.rb"
16
- Then the stdout should match "1 example, 0 failures"
16
+ Then the stdout should include "1 example, 0 failures"
17
17
 
18
18
  Scenario: subject in a nested group
19
19
  Given a file named "nested_subject_spec.rb" with:
@@ -28,4 +28,4 @@ Feature: explicit subject
28
28
  end
29
29
  """
30
30
  When I run "spec nested_subject_spec.rb"
31
- Then the stdout should match "1 example, 0 failures"
31
+ Then the stdout should include "1 example, 0 failures"