rspec 1.0.8 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. data/CHANGES +122 -2
  2. data/README +10 -9
  3. data/Rakefile +22 -49
  4. data/TODO +2 -0
  5. data/bin/spec +1 -1
  6. data/bin/spec_translator +8 -8
  7. data/examples/{auto_spec_description_example.rb → pure/autogenerated_docstrings_example.rb} +0 -0
  8. data/examples/{before_and_after_example.rb → pure/before_and_after_example.rb} +1 -0
  9. data/examples/{behave_as_example.rb → pure/behave_as_example.rb} +0 -0
  10. data/examples/{custom_expectation_matchers.rb → pure/custom_expectation_matchers.rb} +0 -0
  11. data/examples/{custom_formatter.rb → pure/custom_formatter.rb} +1 -0
  12. data/examples/{dynamic_spec.rb → pure/dynamic_spec.rb} +0 -0
  13. data/examples/{file_accessor.rb → pure/file_accessor.rb} +1 -0
  14. data/examples/{file_accessor_spec.rb → pure/file_accessor_spec.rb} +0 -0
  15. data/examples/{greeter_spec.rb → pure/greeter_spec.rb} +1 -0
  16. data/examples/{helper_method_example.rb → pure/helper_method_example.rb} +0 -0
  17. data/examples/{io_processor.rb → pure/io_processor.rb} +0 -0
  18. data/examples/{io_processor_spec.rb → pure/io_processor_spec.rb} +0 -0
  19. data/examples/{legacy_spec.rb → pure/legacy_spec.rb} +1 -0
  20. data/examples/{mocking_example.rb → pure/mocking_example.rb} +0 -0
  21. data/examples/pure/multi_threaded_behaviour_runner.rb +28 -0
  22. data/examples/pure/nested_classes_example.rb +36 -0
  23. data/examples/{partial_mock_example.rb → pure/partial_mock_example.rb} +0 -0
  24. data/examples/{pending_example.rb → pure/pending_example.rb} +0 -0
  25. data/examples/{predicate_example.rb → pure/predicate_example.rb} +0 -0
  26. data/examples/{priority.txt → pure/priority.txt} +0 -0
  27. data/examples/pure/shared_example_group_example.rb +66 -0
  28. data/examples/pure/shared_stack_examples.rb +38 -0
  29. data/examples/pure/spec_helper.rb +3 -0
  30. data/examples/{stack.rb → pure/stack.rb} +0 -0
  31. data/examples/{stack_spec.rb → pure/stack_spec.rb} +1 -35
  32. data/examples/pure/stack_spec_with_nested_example_groups.rb +67 -0
  33. data/examples/{stubbing_example.rb → pure/stubbing_example.rb} +0 -0
  34. data/examples/stories/adder.rb +13 -0
  35. data/examples/stories/addition +34 -0
  36. data/examples/stories/addition.rb +9 -0
  37. data/examples/stories/calculator.rb +65 -0
  38. data/examples/stories/game-of-life/README.txt +21 -0
  39. data/examples/stories/game-of-life/behaviour/everything.rb +6 -0
  40. data/examples/stories/game-of-life/behaviour/examples/examples.rb +3 -0
  41. data/examples/stories/game-of-life/behaviour/examples/game_behaviour.rb +35 -0
  42. data/examples/stories/game-of-life/behaviour/examples/grid_behaviour.rb +66 -0
  43. data/examples/stories/game-of-life/behaviour/stories/CellsWithLessThanTwoNeighboursDie.story +21 -0
  44. data/examples/stories/game-of-life/behaviour/stories/CellsWithMoreThanThreeNeighboursDie.story +21 -0
  45. data/examples/stories/game-of-life/behaviour/stories/EmptySpacesWithThreeNeighboursCreateACell.story +42 -0
  46. data/examples/stories/game-of-life/behaviour/stories/ICanCreateACell.story +42 -0
  47. data/examples/stories/game-of-life/behaviour/stories/ICanKillACell.story +17 -0
  48. data/examples/stories/game-of-life/behaviour/stories/TheGridWraps.story +53 -0
  49. data/examples/stories/game-of-life/behaviour/stories/create_a_cell.rb +52 -0
  50. data/examples/stories/game-of-life/behaviour/stories/helper.rb +6 -0
  51. data/examples/stories/game-of-life/behaviour/stories/kill_a_cell.rb +26 -0
  52. data/examples/stories/game-of-life/behaviour/stories/steps.rb +5 -0
  53. data/examples/stories/game-of-life/behaviour/stories/stories.rb +3 -0
  54. data/examples/stories/game-of-life/behaviour/stories/stories.txt +22 -0
  55. data/examples/stories/game-of-life/life.rb +3 -0
  56. data/examples/stories/game-of-life/life/game.rb +23 -0
  57. data/examples/stories/game-of-life/life/grid.rb +43 -0
  58. data/examples/stories/helper.rb +9 -0
  59. data/examples/stories/steps/addition_steps.rb +18 -0
  60. data/lib/autotest/rspec.rb +1 -2
  61. data/lib/spec.rb +30 -6
  62. data/lib/spec/example.rb +12 -0
  63. data/lib/spec/{dsl → example}/configuration.rb +48 -39
  64. data/lib/spec/{dsl → example}/errors.rb +2 -2
  65. data/lib/spec/example/example_group.rb +16 -0
  66. data/lib/spec/example/example_group_factory.rb +62 -0
  67. data/lib/spec/example/example_group_methods.rb +412 -0
  68. data/lib/spec/example/example_matcher.rb +42 -0
  69. data/lib/spec/example/example_methods.rb +101 -0
  70. data/lib/spec/example/module_reopening_fix.rb +21 -0
  71. data/lib/spec/example/pending.rb +18 -0
  72. data/lib/spec/example/shared_example_group.rb +58 -0
  73. data/lib/spec/expectations/differs/default.rb +15 -10
  74. data/lib/spec/expectations/errors.rb +7 -1
  75. data/lib/spec/expectations/extensions/object.rb +12 -7
  76. data/lib/spec/expectations/handler.rb +13 -4
  77. data/lib/spec/extensions.rb +2 -0
  78. data/lib/spec/extensions/class.rb +24 -0
  79. data/lib/spec/extensions/main.rb +54 -0
  80. data/lib/spec/extensions/object.rb +5 -1
  81. data/lib/spec/interop/test.rb +10 -0
  82. data/lib/spec/interop/test/unit/autorunner.rb +6 -0
  83. data/lib/spec/interop/test/unit/testcase.rb +61 -0
  84. data/lib/spec/interop/test/unit/testresult.rb +6 -0
  85. data/lib/spec/interop/test/unit/testsuite_adapter.rb +34 -0
  86. data/lib/spec/interop/test/unit/ui/console/testrunner.rb +60 -0
  87. data/lib/spec/matchers.rb +11 -15
  88. data/lib/spec/matchers/be.rb +23 -6
  89. data/lib/spec/matchers/change.rb +25 -1
  90. data/lib/spec/matchers/exist.rb +17 -0
  91. data/lib/spec/matchers/operator_matcher.rb +1 -0
  92. data/lib/spec/matchers/simple_matcher.rb +29 -0
  93. data/lib/spec/matchers/throw_symbol.rb +2 -0
  94. data/lib/spec/mocks.rb +5 -2
  95. data/lib/spec/mocks/argument_expectation.rb +1 -1
  96. data/lib/spec/mocks/message_expectation.rb +62 -44
  97. data/lib/spec/mocks/methods.rb +2 -2
  98. data/lib/spec/mocks/mock.rb +24 -3
  99. data/lib/spec/mocks/proxy.rb +26 -23
  100. data/lib/spec/mocks/space.rb +1 -1
  101. data/lib/spec/mocks/spec_methods.rb +20 -12
  102. data/lib/spec/rake/spectask.rb +19 -1
  103. data/lib/spec/rake/verify_rcov.rb +1 -1
  104. data/lib/spec/runner.rb +33 -10
  105. data/lib/spec/runner/backtrace_tweaker.rb +3 -3
  106. data/lib/spec/runner/class_and_arguments_parser.rb +16 -0
  107. data/lib/spec/runner/command_line.rb +18 -12
  108. data/lib/spec/runner/drb_command_line.rb +4 -5
  109. data/lib/spec/runner/example_group_runner.rb +59 -0
  110. data/lib/spec/runner/formatter/base_formatter.rb +10 -8
  111. data/lib/spec/runner/formatter/base_text_formatter.rb +18 -18
  112. data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +31 -0
  113. data/lib/spec/runner/formatter/failing_examples_formatter.rb +3 -5
  114. data/lib/spec/runner/formatter/html_formatter.rb +37 -27
  115. data/lib/spec/runner/formatter/profile_formatter.rb +47 -0
  116. data/lib/spec/runner/formatter/progress_bar_formatter.rb +3 -4
  117. data/lib/spec/runner/formatter/specdoc_formatter.rb +27 -13
  118. data/lib/spec/runner/formatter/story/html_formatter.rb +124 -0
  119. data/lib/spec/runner/formatter/story/plain_text_formatter.rb +123 -0
  120. data/lib/spec/runner/formatter/text_mate_formatter.rb +16 -0
  121. data/lib/spec/runner/heckle_runner.rb +9 -9
  122. data/lib/spec/runner/option_parser.rb +140 -138
  123. data/lib/spec/runner/options.rb +168 -90
  124. data/lib/spec/runner/reporter.rb +58 -40
  125. data/lib/spec/runner/spec_parser.rb +11 -8
  126. data/lib/spec/story.rb +10 -0
  127. data/lib/spec/story/extensions.rb +1 -0
  128. data/lib/spec/story/extensions/main.rb +86 -0
  129. data/lib/spec/story/given_scenario.rb +14 -0
  130. data/lib/spec/story/runner.rb +58 -0
  131. data/lib/spec/story/runner/plain_text_story_runner.rb +48 -0
  132. data/lib/spec/story/runner/scenario_collector.rb +18 -0
  133. data/lib/spec/story/runner/scenario_runner.rb +46 -0
  134. data/lib/spec/story/runner/story_mediator.rb +123 -0
  135. data/lib/spec/story/runner/story_parser.rb +227 -0
  136. data/lib/spec/story/runner/story_runner.rb +67 -0
  137. data/lib/spec/story/scenario.rb +14 -0
  138. data/lib/spec/story/step.rb +48 -0
  139. data/lib/spec/story/step_group.rb +89 -0
  140. data/lib/spec/story/step_mother.rb +37 -0
  141. data/lib/spec/story/story.rb +42 -0
  142. data/lib/spec/story/world.rb +124 -0
  143. data/lib/spec/version.rb +4 -5
  144. data/plugins/mock_frameworks/rspec.rb +1 -1
  145. data/spec/autotest/rspec_spec.rb +13 -7
  146. data/spec/autotest_helper.rb +4 -3
  147. data/spec/rspec_suite.rb +7 -0
  148. data/spec/ruby_forker.rb +13 -0
  149. data/spec/spec/example/configuration_spec.rb +290 -0
  150. data/spec/spec/example/example_group_class_definition_spec.rb +48 -0
  151. data/spec/spec/example/example_group_factory_spec.rb +129 -0
  152. data/spec/spec/example/example_group_methods_spec.rb +465 -0
  153. data/spec/spec/example/example_group_spec.rb +711 -0
  154. data/spec/spec/{dsl → example}/example_matcher_spec.rb +23 -18
  155. data/spec/spec/example/example_methods_spec.rb +75 -0
  156. data/spec/spec/example/example_runner_spec.rb +194 -0
  157. data/spec/spec/example/example_spec.rb +53 -0
  158. data/spec/spec/example/nested_example_group_spec.rb +59 -0
  159. data/spec/spec/example/pending_module_spec.rb +31 -0
  160. data/spec/spec/{dsl → example}/predicate_matcher_spec.rb +1 -1
  161. data/spec/spec/example/shared_example_group_spec.rb +265 -0
  162. data/spec/spec/example/subclassing_example_group_spec.rb +25 -0
  163. data/spec/spec/expectations/differs/default_spec.rb +5 -3
  164. data/spec/spec/expectations/extensions/object_spec.rb +63 -2
  165. data/spec/spec/extensions/main_spec.rb +50 -0
  166. data/spec/spec/interop/test/unit/test_unit_spec_helper.rb +14 -0
  167. data/spec/spec/interop/test/unit/testcase_spec.rb +10 -0
  168. data/spec/spec/interop/test/unit/testcase_spec_with_test_unit.rb +20 -0
  169. data/spec/spec/interop/test/unit/testsuite_adapter_spec.rb +9 -0
  170. data/spec/spec/interop/test/unit/testsuite_adapter_spec_with_test_unit.rb +34 -0
  171. data/spec/spec/matchers/be_spec.rb +15 -0
  172. data/spec/spec/matchers/change_spec.rb +87 -0
  173. data/spec/spec/matchers/description_generation_spec.rb +31 -37
  174. data/spec/spec/matchers/exist_spec.rb +31 -22
  175. data/spec/spec/matchers/handler_spec.rb +42 -1
  176. data/spec/spec/matchers/have_spec.rb +1 -1
  177. data/spec/spec/matchers/mock_constraint_matchers_spec.rb +1 -1
  178. data/spec/spec/matchers/operator_matcher_spec.rb +1 -1
  179. data/spec/spec/matchers/simple_matcher_spec.rb +31 -0
  180. data/spec/spec/matchers/throw_symbol_spec.rb +4 -1
  181. data/spec/spec/mocks/bug_report_10263.rb +24 -0
  182. data/spec/spec/mocks/bug_report_15719_spec.rb +30 -0
  183. data/spec/spec/mocks/bug_report_8165_spec.rb +2 -2
  184. data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +1 -0
  185. data/spec/spec/mocks/mock_spec.rb +200 -102
  186. data/spec/spec/mocks/multiple_return_value_spec.rb +1 -1
  187. data/spec/spec/mocks/options_hash_spec.rb +19 -7
  188. data/spec/spec/mocks/partial_mock_spec.rb +31 -9
  189. data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +6 -0
  190. data/spec/spec/mocks/stub_spec.rb +120 -98
  191. data/spec/spec/package/bin_spec_spec.rb +7 -5
  192. data/spec/spec/runner/class_and_argument_parser_spec.rb +23 -0
  193. data/spec/spec/runner/command_line_spec.rb +140 -27
  194. data/spec/spec/runner/drb_command_line_spec.rb +39 -31
  195. data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +44 -0
  196. data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +16 -11
  197. data/spec/spec/runner/formatter/html_formatter_spec.rb +60 -50
  198. data/spec/spec/runner/formatter/profile_formatter_spec.rb +65 -0
  199. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +29 -13
  200. data/spec/spec/runner/formatter/snippet_extractor_spec.rb +14 -7
  201. data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +103 -0
  202. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +103 -39
  203. data/spec/spec/runner/formatter/story/html_formatter_spec.rb +56 -0
  204. data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +289 -0
  205. data/spec/spec/runner/heckle_runner_spec.rb +29 -14
  206. data/spec/spec/runner/heckler_spec.rb +4 -5
  207. data/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +5 -5
  208. data/spec/spec/runner/option_parser_spec.rb +86 -58
  209. data/spec/spec/runner/options_spec.rb +239 -120
  210. data/spec/spec/runner/output_one_time_fixture.rb +7 -0
  211. data/spec/spec/runner/output_one_time_fixture_runner.rb +8 -0
  212. data/spec/spec/runner/output_one_time_spec.rb +16 -0
  213. data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +6 -6
  214. data/spec/spec/runner/reporter_spec.rb +147 -163
  215. data/spec/spec/runner/spec_parser_spec.rb +31 -0
  216. data/spec/spec/runner_spec.rb +11 -0
  217. data/spec/spec/spec_classes.rb +12 -5
  218. data/spec/spec/story/builders.rb +46 -0
  219. data/spec/spec/story/extensions/main_spec.rb +161 -0
  220. data/spec/spec/story/extensions_spec.rb +14 -0
  221. data/spec/spec/story/given_scenario_spec.rb +27 -0
  222. data/spec/spec/story/runner/plain_text_story_runner_spec.rb +92 -0
  223. data/spec/spec/story/runner/scenario_collector_spec.rb +27 -0
  224. data/spec/spec/story/runner/scenario_runner_spec.rb +142 -0
  225. data/spec/spec/story/runner/story_mediator_spec.rb +133 -0
  226. data/spec/spec/story/runner/story_parser_spec.rb +384 -0
  227. data/spec/spec/story/runner/story_runner_spec.rb +219 -0
  228. data/spec/spec/story/runner_spec.rb +106 -0
  229. data/spec/spec/story/scenario_spec.rb +20 -0
  230. data/spec/spec/story/step_group_spec.rb +157 -0
  231. data/spec/spec/story/step_mother_spec.rb +72 -0
  232. data/spec/spec/story/step_spec.rb +147 -0
  233. data/spec/spec/story/story_helper.rb +2 -0
  234. data/spec/spec/story/story_spec.rb +86 -0
  235. data/spec/spec/story/world_spec.rb +416 -0
  236. data/spec/spec/translator_spec.rb +2 -1
  237. data/spec/spec_helper.rb +59 -2
  238. data/stories/all.rb +5 -0
  239. data/stories/example_groups/autogenerated_docstrings +26 -0
  240. data/stories/example_groups/example_group_with_should_methods +17 -0
  241. data/stories/example_groups/nested_groups +17 -0
  242. data/stories/example_groups/output +20 -0
  243. data/stories/example_groups/stories.rb +7 -0
  244. data/stories/helper.rb +6 -0
  245. data/stories/interop/examples_and_tests_together +30 -0
  246. data/stories/interop/stories.rb +7 -0
  247. data/stories/interop/test_case_with_should_methods +17 -0
  248. data/stories/pending_stories/README +3 -0
  249. data/stories/resources/helpers/cmdline.rb +9 -0
  250. data/stories/resources/helpers/story_helper.rb +16 -0
  251. data/stories/resources/matchers/smart_match.rb +37 -0
  252. data/stories/resources/spec/example_group_with_should_methods.rb +12 -0
  253. data/stories/resources/spec/simple_spec.rb +8 -0
  254. data/stories/resources/steps/running_rspec.rb +50 -0
  255. data/stories/resources/test/spec_and_test_together.rb +57 -0
  256. data/stories/resources/test/test_case_with_should_methods.rb +30 -0
  257. metadata +232 -106
  258. data/EXAMPLES.rd +0 -111
  259. data/examples/multi_threaded_behaviour_runner.rb +0 -25
  260. data/examples/shared_behaviours_example.rb +0 -39
  261. data/examples/spec_helper.rb +0 -1
  262. data/examples/test_case_adapter_example.rb +0 -26
  263. data/examples/test_case_spec.rb +0 -65
  264. data/lib/spec/dsl.rb +0 -11
  265. data/lib/spec/dsl/behaviour.rb +0 -220
  266. data/lib/spec/dsl/behaviour_callbacks.rb +0 -82
  267. data/lib/spec/dsl/behaviour_eval.rb +0 -231
  268. data/lib/spec/dsl/behaviour_factory.rb +0 -42
  269. data/lib/spec/dsl/composite_proc_builder.rb +0 -33
  270. data/lib/spec/dsl/description.rb +0 -76
  271. data/lib/spec/dsl/example.rb +0 -135
  272. data/lib/spec/dsl/example_matcher.rb +0 -40
  273. data/lib/spec/dsl/example_should_raise_handler.rb +0 -74
  274. data/lib/spec/runner/behaviour_runner.rb +0 -123
  275. data/lib/spec/runner/extensions/kernel.rb +0 -50
  276. data/lib/spec/runner/extensions/object.rb +0 -32
  277. data/lib/spec/runner/formatter.rb +0 -9
  278. data/lib/spec/runner/formatter/failing_behaviours_formatter.rb +0 -29
  279. data/lib/spec/runner/formatter/rdoc_formatter.rb +0 -24
  280. data/lib/spec/test_case_adapter.rb +0 -10
  281. data/spec/spec/dsl/behaviour_eval_spec.rb +0 -79
  282. data/spec/spec/dsl/behaviour_factory_spec.rb +0 -48
  283. data/spec/spec/dsl/behaviour_spec.rb +0 -661
  284. data/spec/spec/dsl/composite_proc_builder_spec.rb +0 -44
  285. data/spec/spec/dsl/configuration_spec.rb +0 -55
  286. data/spec/spec/dsl/description_spec.rb +0 -89
  287. data/spec/spec/dsl/example_class_spec.rb +0 -24
  288. data/spec/spec/dsl/example_instance_spec.rb +0 -160
  289. data/spec/spec/dsl/example_should_raise_spec.rb +0 -137
  290. data/spec/spec/dsl/shared_behaviour_spec.rb +0 -252
  291. data/spec/spec/runner/behaviour_runner_spec.rb +0 -229
  292. data/spec/spec/runner/context_matching_spec.rb +0 -27
  293. data/spec/spec/runner/extensions/bug_report_10577_spec.rb +0 -35
  294. data/spec/spec/runner/extensions/kernel_spec.rb +0 -36
  295. data/spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb +0 -40
  296. data/spec/spec/runner/formatter/progress_bar_formatter_dry_run_spec.rb +0 -20
  297. data/spec/spec/runner/formatter/progress_bar_formatter_failure_dump_spec.rb +0 -36
  298. data/spec/spec/runner/formatter/rdoc_formatter_dry_run_spec.rb +0 -19
  299. data/spec/spec/runner/formatter/rdoc_formatter_spec.rb +0 -46
  300. data/spec/spec/runner/formatter/specdoc_formatter_dry_run_spec.rb +0 -21
  301. data/spec/spec/runner/object_ext_spec.rb +0 -11
@@ -1,18 +1,16 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+ require 'fileutils'
2
3
 
3
4
  describe "OptionParser" do
4
5
  before(:each) do
5
6
  @out = StringIO.new
6
7
  @err = StringIO.new
7
- @parser = Spec::Runner::OptionParser.new
8
+ @parser = Spec::Runner::OptionParser.new(@err, @out)
8
9
  end
9
10
 
10
11
  def parse(args)
11
- @parser.parse(args, @err, @out, true)
12
- end
13
-
14
- def behaviour_runner(args)
15
- @parser.create_behaviour_runner(args, @err, @out, true)
12
+ @parser.parse(args)
13
+ @parser.options
16
14
  end
17
15
 
18
16
  it "should accept dry run option" do
@@ -48,6 +46,14 @@ describe "OptionParser" do
48
46
  options.colour.should == false
49
47
  end
50
48
 
49
+ it "should print help to stdout if no args" do
50
+ pending 'A regression since 1.0.8' do
51
+ options = parse([])
52
+ @out.rewind
53
+ @out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
54
+ end
55
+ end
56
+
51
57
  it "should print help to stdout" do
52
58
  options = parse(["--help"])
53
59
  @out.rewind
@@ -55,19 +61,17 @@ describe "OptionParser" do
55
61
  end
56
62
 
57
63
  it "should print instructions about how to require missing formatter" do
58
- lambda { options = parse(["--format", "Custom::MissingFormatter"]) }.should raise_error(NameError)
64
+ lambda do
65
+ options = parse(["--format", "Custom::MissingFormatter"])
66
+ options.formatters
67
+ end.should raise_error(NameError)
59
68
  @err.string.should match(/Couldn't find formatter class Custom::MissingFormatter/n)
60
69
  end
61
70
 
62
- it "should print usage to err if no dir specified" do
63
- options = parse([])
64
- @err.string.should match(/Usage: spec/)
65
- end
66
-
67
71
  it "should print version to stdout" do
68
72
  options = parse(["--version"])
69
73
  @out.rewind
70
- @out.read.should match(/RSpec-\d+\.\d+\.\d+.*\(r\d+\) - BDD for Ruby\nhttp:\/\/rspec.rubyforge.org\/\n/n)
74
+ @out.read.should match(/RSpec-\d+\.\d+\.\d+.*\(build \d+\) - BDD for Ruby\nhttp:\/\/rspec.rubyforge.org\/\n/n)
71
75
  end
72
76
 
73
77
  it "should require file when require specified" do
@@ -123,14 +127,25 @@ describe "OptionParser" do
123
127
  options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
124
128
  end
125
129
 
130
+ it "should use html story formatter when format is h" do
131
+ options = parse(["--format", "h"])
132
+ options.story_formatters[0].class.should equal(Spec::Runner::Formatter::Story::HtmlFormatter)
133
+ end
134
+
126
135
  it "should use html formatter when format is html" do
127
136
  options = parse(["--format", "html"])
128
137
  options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
129
138
  end
130
139
 
140
+ it "should use html story formatter when format is html" do
141
+ options = parse(["--format", "html"])
142
+ options.story_formatters[0].class.should equal(Spec::Runner::Formatter::Story::HtmlFormatter)
143
+ end
144
+
131
145
  it "should use html formatter with explicit output when format is html:test.html" do
132
146
  FileUtils.rm 'test.html' if File.exist?('test.html')
133
147
  options = parse(["--format", "html:test.html"])
148
+ options.formatters # creates the file
134
149
  File.should be_exist('test.html')
135
150
  options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
136
151
  options.formatters[0].close
@@ -157,16 +172,6 @@ describe "OptionParser" do
157
172
  options.formatters[0].class.should equal(Spec::Runner::Formatter::ProgressBarFormatter)
158
173
  end
159
174
 
160
- it "should use rdoc formatter when format is r" do
161
- options = parse(["--format", "r"])
162
- options.formatters[0].class.should equal(Spec::Runner::Formatter::RdocFormatter)
163
- end
164
-
165
- it "should use rdoc formatter when format is rdoc" do
166
- options = parse(["--format", "rdoc"])
167
- options.formatters[0].class.should equal(Spec::Runner::Formatter::RdocFormatter)
168
- end
169
-
170
175
  it "should use specdoc formatter when format is s" do
171
176
  options = parse(["--format", "s"])
172
177
  options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter)
@@ -195,9 +200,13 @@ describe "OptionParser" do
195
200
  end
196
201
 
197
202
  it "should use custom diff format option when format is a custom format" do
198
- options = parse(["--diff", "Custom::Formatter"])
203
+ Spec::Expectations.differ.should_not be_instance_of(Custom::Differ)
204
+
205
+ options = parse(["--diff", "Custom::Differ"])
206
+ options.parse_diff "Custom::Differ"
199
207
  options.diff_format.should == :custom
200
- options.differ_class.should == Custom::Formatter
208
+ options.differ_class.should == Custom::Differ
209
+ Spec::Expectations.differ.should be_instance_of(Custom::Differ)
201
210
  end
202
211
 
203
212
  it "should print instructions about how to fix missing differ" do
@@ -234,7 +243,7 @@ describe "OptionParser" do
234
243
  @err.string.should match(/You must specify one file, not a directory when using the --line option/n)
235
244
  end
236
245
 
237
- it "should fail with error message if file is dir along with --line" do
246
+ it "should fail with error message if file does not exist along with --line" do
238
247
  spec_parser = mock("spec_parser")
239
248
  @parser.instance_variable_set('@spec_parser', spec_parser)
240
249
 
@@ -277,18 +286,21 @@ describe "OptionParser" do
277
286
  end
278
287
 
279
288
  it "should read options from file when --options is specified" do
280
- Spec::Runner::CommandLine.should_receive(:run).with(["--diff", "--colour"], @err, @out, true, true)
281
289
  options = parse(["--options", File.dirname(__FILE__) + "/spec.opts"])
290
+ options.diff_format.should_not be_nil
291
+ options.colour.should be_true
282
292
  end
283
293
 
284
- it "should append options from file when --options is specified" do
285
- Spec::Runner::CommandLine.should_receive(:run).with(["some/spec.rb", "--diff", "--colour"], @err, @out, true, true)
286
- options = parse(["some/spec.rb", "--options", File.dirname(__FILE__) + "/spec.opts"])
294
+ it "should default the formatter to ProgressBarFormatter when using options file" do
295
+ options = parse(["--options", File.dirname(__FILE__) + "/spec.opts"])
296
+ options.formatters.first.should be_instance_of(::Spec::Runner::Formatter::ProgressBarFormatter)
287
297
  end
288
-
298
+
289
299
  it "should read spaced and multi-line options from file when --options is specified" do
290
- Spec::Runner::CommandLine.should_receive(:run).with(["--diff", "--colour", "--format", "s"], @err, @out, true, true)
291
300
  options = parse(["--options", File.dirname(__FILE__) + "/spec_spaced.opts"])
301
+ options.diff_format.should_not be_nil
302
+ options.colour.should be_true
303
+ options.formatters.first.should be_instance_of(::Spec::Runner::Formatter::SpecdocFormatter)
292
304
  end
293
305
 
294
306
  it "should save config to file when --generate-options is specified" do
@@ -298,52 +310,68 @@ describe "OptionParser" do
298
310
  FileUtils.rm 'test.spec.opts'
299
311
  end
300
312
 
301
- it "should call DrbCommandLine when --drb is specified" do
302
- Spec::Runner::DrbCommandLine.should_receive(:run).with(["some/spec.rb", "--diff", "--colour"], @err, @out, true, true)
303
- options = parse(["some/spec.rb", "--diff", "--drb", "--colour"])
304
- end
305
-
306
- it "should not return an Options object when --drb is specified" do
307
- Spec::Runner::DrbCommandLine.stub!(:run)
308
- parse(["some/spec.rb", "--drb"]).should be_nil
313
+ it "should save config to file when -G is specified" do
314
+ FileUtils.rm 'test.spec.opts' if File.exist?('test.spec.opts')
315
+ options = parse(["--colour", "-G", "test.spec.opts", "--diff"])
316
+ IO.read('test.spec.opts').should == "--colour\n--diff\n"
317
+ FileUtils.rm 'test.spec.opts'
309
318
  end
310
319
 
320
+ it "when --drb is specified, calls DrbCommandLine all of the other ARGV arguments" do
321
+ options = Spec::Runner::OptionParser.parse([
322
+ "some/spec.rb", "--diff", "--colour"
323
+ ], @err, @out)
324
+ Spec::Runner::DrbCommandLine.should_receive(:run).and_return do |options|
325
+ options.argv.should == ["some/spec.rb", "--diff", "--colour"]
326
+ end
327
+ parse(["some/spec.rb", "--diff", "--drb", "--colour"])
328
+ end
329
+
311
330
  it "should reverse spec order when --reverse is specified" do
312
331
  options = parse(["some/spec.rb", "--reverse"])
313
332
  end
314
333
 
315
334
  it "should set an mtime comparator when --loadby mtime" do
316
- behaviour_runner = behaviour_runner(["--loadby", 'mtime'])
335
+ options = parse(["--loadby", 'mtime'])
336
+ runner = Spec::Runner::ExampleGroupRunner.new(options)
337
+ Spec::Runner::ExampleGroupRunner.should_receive(:new).
338
+ with(options).
339
+ and_return(runner)
340
+ runner.should_receive(:load_files).with(["most_recent_spec.rb", "command_line_spec.rb"])
341
+
317
342
  Dir.chdir(File.dirname(__FILE__)) do
343
+ options.files << 'command_line_spec.rb'
344
+ options.files << 'most_recent_spec.rb'
318
345
  FileUtils.touch "most_recent_spec.rb"
319
- all_files = ['command_line_spec.rb', 'most_recent_spec.rb']
320
- sorted_files = behaviour_runner.sort_paths(all_files)
321
- sorted_files.should == ["most_recent_spec.rb", "command_line_spec.rb"]
346
+ options.run_examples
322
347
  FileUtils.rm "most_recent_spec.rb"
323
348
  end
324
349
  end
325
350
 
326
351
  it "should use the standard runner by default" do
352
+ runner = ::Spec::Runner::ExampleGroupRunner.new(@parser.options)
353
+ ::Spec::Runner::ExampleGroupRunner.should_receive(:new).
354
+ with(@parser.options).
355
+ and_return(runner)
327
356
  options = parse([])
328
- options.create_behaviour_runner.class.should equal(Spec::Runner::BehaviourRunner)
357
+ options.run_examples
329
358
  end
330
359
 
331
360
  it "should use a custom runner when given" do
332
- options = parse(["--runner", "Custom::BehaviourRunner"])
333
- options.create_behaviour_runner.class.should equal(Custom::BehaviourRunner)
361
+ runner = Custom::ExampleGroupRunner.new(@parser.options, nil)
362
+ Custom::ExampleGroupRunner.should_receive(:new).
363
+ with(@parser.options, nil).
364
+ and_return(runner)
365
+ options = parse(["--runner", "Custom::ExampleGroupRunner"])
366
+ options.run_examples
334
367
  end
335
368
 
336
369
  it "should use a custom runner with extra options" do
337
- options = parse(["--runner", "Custom::BehaviourRunner:something"])
338
- options.create_behaviour_runner.class.should equal(Custom::BehaviourRunner)
370
+ runner = Custom::ExampleGroupRunner.new(@parser.options, 'something')
371
+ Custom::ExampleGroupRunner.should_receive(:new).
372
+ with(@parser.options, 'something').
373
+ and_return(runner)
374
+ options = parse(["--runner", "Custom::ExampleGroupRunner:something"])
375
+ options.run_examples
339
376
  end
340
-
341
- it "should return the correct default behaviour runner" do
342
- @parser.create_behaviour_runner([], @err, @out, true).should be_instance_of(Spec::Runner::BehaviourRunner)
343
- end
344
-
345
- it "should return the correct default behaviour runner" do
346
- @parser.create_behaviour_runner(["--runner", "Custom::BehaviourRunner"], @err, @out, true).should be_instance_of(Custom::BehaviourRunner)
347
- end
348
-
349
377
  end
@@ -3,172 +3,291 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
3
3
  module Spec
4
4
  module Runner
5
5
  describe Options do
6
- before do
6
+ before(:each) do
7
7
  @err = StringIO.new('')
8
8
  @out = StringIO.new('')
9
9
  @options = Options.new(@err, @out)
10
10
  end
11
11
 
12
- it "instantiates empty arrays" do
13
- @options.examples.should == []
14
- @options.formatters.should == []
12
+ after(:each) do
13
+ Spec::Expectations.differ = nil
15
14
  end
16
15
 
17
- it "defaults to QuietBacktraceTweaker" do
18
- @options.backtrace_tweaker.class.should == QuietBacktraceTweaker
16
+ describe "#examples" do
17
+ it "should default to empty array" do
18
+ @options.examples.should == []
19
+ end
19
20
  end
20
21
 
21
- it "defaults to no dry_run" do
22
- @options.dry_run.should == false
22
+ describe "#backtrace_tweaker" do
23
+ it "should default to QuietBacktraceTweaker" do
24
+ @options.backtrace_tweaker.class.should == QuietBacktraceTweaker
25
+ end
23
26
  end
24
27
 
25
- it "parse_diff sets context_lines" do
26
- @options.parse_diff nil
27
- @options.context_lines.should == 3
28
+ describe "#dry_run" do
29
+ it "should default to false" do
30
+ @options.dry_run.should == false
31
+ end
28
32
  end
29
33
 
30
- it "defaults diff to unified" do
31
- @options.parse_diff nil
32
- @options.diff_format.should == :unified
34
+ describe "#context_lines" do
35
+ it "should default to 3" do
36
+ @options.context_lines.should == 3
37
+ end
33
38
  end
34
39
 
35
- it "should use unified diff format option when format is unified" do
36
- @options.parse_diff 'unified'
37
- @options.diff_format.should == :unified
38
- @options.differ_class.should equal(Spec::Expectations::Differs::Default)
39
- end
40
+ describe "#parse_diff with nil" do
41
+ before(:each) do
42
+ @options.parse_diff nil
43
+ end
40
44
 
41
- it "should use context diff format option when format is context" do
42
- @options.parse_diff 'context'
43
- @options.diff_format.should == :context
44
- @options.differ_class.should == Spec::Expectations::Differs::Default
45
- end
45
+ it "should make diff_format unified" do
46
+ @options.diff_format.should == :unified
47
+ end
46
48
 
47
- it "should use custom diff format option when format is a custom format" do
48
- @options.parse_diff "Custom::Formatter"
49
- @options.diff_format.should == :custom
50
- @options.differ_class.should == Custom::Formatter
49
+ it "should set Spec::Expectations.differ to be a default differ" do
50
+ Spec::Expectations.differ.class.should ==
51
+ ::Spec::Expectations::Differs::Default
52
+ end
51
53
  end
52
54
 
53
- it "should print instructions about how to fix missing differ" do
54
- lambda { @options.parse_diff "Custom::MissingDiffer" }.should raise_error(NameError)
55
- @err.string.should match(/Couldn't find differ class Custom::MissingDiffer/n)
56
- end
55
+ describe "#parse_diff with 'unified'" do
56
+ before(:each) do
57
+ @options.parse_diff 'unified'
58
+ end
57
59
 
58
- it "should print instructions about how to fix bad formatter" do
59
- lambda do
60
- @options.parse_format "Custom::BadFormatter"
61
- end.should raise_error(NameError, /undefined local variable or method `bad_method'/)
62
- end
60
+ it "should make diff_format unified and uses default differ_class" do
61
+ @options.diff_format.should == :unified
62
+ @options.differ_class.should equal(Spec::Expectations::Differs::Default)
63
+ end
63
64
 
64
- it "parse_example sets single example when argument not a file" do
65
- example = "something or other"
66
- File.file?(example).should == false
67
- @options.parse_example example
68
- @options.examples.should eql(["something or other"])
65
+ it "should set Spec::Expectations.differ to be a default differ" do
66
+ Spec::Expectations.differ.class.should ==
67
+ ::Spec::Expectations::Differs::Default
68
+ end
69
69
  end
70
70
 
71
- it "parse_example sets examples to contents of file" do
72
- example = "#{File.dirname(__FILE__)}/examples.txt"
73
- File.should_receive(:file?).with(example).and_return(true)
74
- file = StringIO.new("Sir, if you were my husband, I would poison your drink.\nMadam, if you were my wife, I would drink it.")
75
- File.should_receive(:open).with(example).and_return(file)
76
-
77
- @options.parse_example example
78
- @options.examples.should eql([
79
- "Sir, if you were my husband, I would poison your drink.",
80
- "Madam, if you were my wife, I would drink it."
81
- ])
82
- end
83
- end
71
+ describe "#parse_diff with 'context'" do
72
+ before(:each) do
73
+ @options.parse_diff 'context'
74
+ end
84
75
 
85
- describe Options, "splitting class names and args" do
86
- before do
87
- @err = StringIO.new('')
88
- @out = StringIO.new('')
89
- @options = Options.new(@err, @out)
90
- end
91
-
92
- it "should split class names with args" do
93
- @options.split_at_colon('Foo').should == ['Foo', nil]
94
- @options.split_at_colon('Foo:arg').should == ['Foo', 'arg']
95
- @options.split_at_colon('Foo::Bar::Zap:arg').should == ['Foo::Bar::Zap', 'arg']
96
- @options.split_at_colon('Foo:arg1,arg2').should == ['Foo', 'arg1,arg2']
97
- @options.split_at_colon('Foo::Bar::Zap:arg1,arg2').should == ['Foo::Bar::Zap', 'arg1,arg2']
98
- @options.split_at_colon('Foo::Bar::Zap:drb://foo,drb://bar').should == ['Foo::Bar::Zap', 'drb://foo,drb://bar']
99
- end
76
+ it "should make diff_format context and uses default differ_class" do
77
+ @options.diff_format.should == :context
78
+ @options.differ_class.should == Spec::Expectations::Differs::Default
79
+ end
100
80
 
101
- it "should raise error when splitting something starting with a number" do
102
- lambda { @options.split_at_colon('') }.should raise_error("Couldn't parse \"\"")
81
+ it "should set Spec::Expectations.differ to be a default differ" do
82
+ Spec::Expectations.differ.class.should ==
83
+ ::Spec::Expectations::Differs::Default
84
+ end
103
85
  end
104
86
 
105
- it "should raise error when not class name" do
106
- lambda do
107
- @options.load_class('foo', 'fruit', '--food')
108
- end.should raise_error('"foo" is not a valid class name')
87
+ describe "#parse_diff with Custom::Differ" do
88
+ before(:each) do
89
+ @options.parse_diff 'Custom::Differ'
90
+ end
91
+
92
+ it "should use custom differ_class" do
93
+ @options.diff_format.should == :custom
94
+ @options.differ_class.should == Custom::Differ
95
+ Spec::Expectations.differ.should be_instance_of(Custom::Differ)
96
+ end
97
+
98
+ it "should set Spec::Expectations.differ to be a default differ" do
99
+ Spec::Expectations.differ.class.should ==
100
+ ::Custom::Differ
101
+ end
109
102
  end
110
- end
111
103
 
112
- describe Options, "receiving create_behaviour_runner" do
113
- before do
114
- @err = StringIO.new
115
- @out = StringIO.new
116
- @options = Options.new(@err, @out)
104
+ describe "#parse_diff with missing class name" do
105
+ it "should raise error" do
106
+ lambda { @options.parse_diff "Custom::MissingDiffer" }.should raise_error(NameError)
107
+ @err.string.should match(/Couldn't find differ class Custom::MissingDiffer/n)
108
+ end
117
109
  end
118
110
 
119
- it "should fail when custom runner not found" do
120
- @options.runner_arg = "Whatever"
121
- lambda { @options.create_behaviour_runner }.should raise_error(NameError)
122
- @err.string.should match(/Couldn't find behaviour runner class/)
111
+ describe "#parse_example" do
112
+ it "with argument thats not a file path, sets argument as the example" do
113
+ example = "something or other"
114
+ File.file?(example).should == false
115
+ @options.parse_example example
116
+ @options.examples.should eql(["something or other"])
117
+ end
118
+
119
+ it "with argument that is a file path, sets examples to contents of the file" do
120
+ example = "#{File.dirname(__FILE__)}/examples.txt"
121
+ File.should_receive(:file?).with(example).and_return(true)
122
+ file = StringIO.new("Sir, if you were my husband, I would poison your drink.\nMadam, if you were my wife, I would drink it.")
123
+ File.should_receive(:open).with(example).and_return(file)
124
+
125
+ @options.parse_example example
126
+ @options.examples.should eql([
127
+ "Sir, if you were my husband, I would poison your drink.",
128
+ "Madam, if you were my wife, I would drink it."
129
+ ])
130
+ end
123
131
  end
124
132
 
125
- it "should fail when custom runner not valid class name" do
126
- @options.runner_arg = "whatever"
127
- lambda { @options.create_behaviour_runner }.should raise_error('"whatever" is not a valid class name')
128
- @err.string.should match(/"whatever" is not a valid class name/)
133
+ describe "#examples_should_not_be_run" do
134
+ it "should cause #run_examples to return true and do nothing" do
135
+ @options.examples_should_not_be_run
136
+ ExampleGroupRunner.should_not_receive(:new)
137
+
138
+ @options.run_examples.should be_true
139
+ end
129
140
  end
130
141
 
131
- it "returns nil when generate is true" do
132
- @options.generate = true
133
- @options.create_behaviour_runner.should == nil
142
+ describe "#load_class" do
143
+ it "should raise error when not class name" do
144
+ lambda do
145
+ @options.send(:load_class, 'foo', 'fruit', '--food')
146
+ end.should raise_error('"foo" is not a valid class name')
147
+ end
134
148
  end
135
149
 
136
- it "returns a BehaviourRunner by default" do
137
- runner = @options.create_behaviour_runner
138
- runner.class.should == BehaviourRunner
150
+ describe "#reporter" do
151
+ it "returns a Reporter" do
152
+ @options.reporter.should be_instance_of(Reporter)
153
+ @options.reporter.options.should === @options
154
+ end
139
155
  end
140
156
 
141
- it "does not set Expectations differ when differ_class is not set" do
142
- @options.differ_class = nil
143
- Spec::Expectations.should_not_receive(:differ=)
144
- @options.create_behaviour_runner
157
+ describe "#add_example_group affecting passed in example_group" do
158
+ it "runs all examples when options.examples is nil" do
159
+ example_1_has_run = false
160
+ example_2_has_run = false
161
+ @example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do
162
+ it "runs 1" do
163
+ example_1_has_run = true
164
+ end
165
+ it "runs 2" do
166
+ example_2_has_run = true
167
+ end
168
+ end
169
+
170
+ @options.examples = nil
171
+
172
+ @options.add_example_group @example_group
173
+ @options.run_examples
174
+ example_1_has_run.should be_true
175
+ example_2_has_run.should be_true
176
+ end
177
+
178
+ it "keeps all example_definitions when options.examples is empty" do
179
+ example_1_has_run = false
180
+ example_2_has_run = false
181
+ @example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do
182
+ it "runs 1" do
183
+ example_1_has_run = true
184
+ end
185
+ it "runs 2" do
186
+ example_2_has_run = true
187
+ end
188
+ end
189
+
190
+ @options.examples = []
191
+
192
+ @options.add_example_group @example_group
193
+ @options.run_examples
194
+ example_1_has_run.should be_true
195
+ example_2_has_run.should be_true
196
+ end
145
197
  end
146
198
 
147
- it "sets Expectations differ when differ_class is set" do
148
- @options.differ_class = Spec::Expectations::Differs::Default
149
- Spec::Expectations.should_receive(:differ=).with(anything()).and_return do |arg|
150
- arg.class.should == Spec::Expectations::Differs::Default
199
+ describe "#add_example_group affecting example_group" do
200
+ it "adds example_group when example_group has example_definitions and is not shared" do
201
+ @example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do
202
+ it "uses this example_group" do
203
+ end
204
+ end
205
+
206
+ @options.number_of_examples.should == 0
207
+ @options.add_example_group @example_group
208
+ @options.number_of_examples.should == 1
209
+ @options.example_groups.length.should == 1
151
210
  end
152
- @options.configure
153
211
  end
154
212
 
155
- it "creates a Reporter" do
156
- formatter = ::Spec::Runner::Formatter::BaseFormatter.new(:somewhere)
157
- @options.formatters << formatter
158
- reporter = Reporter.new(@formatters, @backtrace_tweaker)
159
- Reporter.should_receive(:new).with(@options.formatters, @options.backtrace_tweaker).and_return(reporter)
160
- @options.configure
161
- @options.reporter.should === reporter
213
+ describe "#remove_example_group" do
214
+ it "should remove the ExampleGroup from the list of ExampleGroups" do
215
+ @example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do
216
+ end
217
+ @options.add_example_group @example_group
218
+ @options.example_groups.should include(@example_group)
219
+
220
+ @options.remove_example_group @example_group
221
+ @options.example_groups.should_not include(@example_group)
222
+ end
162
223
  end
163
224
 
164
- it "sets colour and dry_run on the formatters" do
165
- @options.colour = true
166
- @options.dry_run = true
167
- formatter = ::Spec::Runner::Formatter::BaseTextFormatter.new(:somewhere)
168
- formatter.should_receive(:colour=).with(true)
169
- formatter.should_receive(:dry_run=).with(true)
170
- @options.formatters << formatter
171
- @options.configure
225
+ describe "#run_examples" do
226
+ it "should use the standard runner by default" do
227
+ runner = ::Spec::Runner::ExampleGroupRunner.new(@options)
228
+ ::Spec::Runner::ExampleGroupRunner.should_receive(:new).
229
+ with(@options).
230
+ and_return(runner)
231
+ @options.user_input_for_runner = nil
232
+
233
+ @options.run_examples
234
+ end
235
+
236
+ it "should use a custom runner when given" do
237
+ runner = Custom::ExampleGroupRunner.new(@options, nil)
238
+ Custom::ExampleGroupRunner.should_receive(:new).
239
+ with(@options, nil).
240
+ and_return(runner)
241
+ @options.user_input_for_runner = "Custom::ExampleGroupRunner"
242
+
243
+ @options.run_examples
244
+ end
245
+
246
+ it "should use a custom runner with extra options" do
247
+ runner = Custom::ExampleGroupRunner.new(@options, 'something')
248
+ Custom::ExampleGroupRunner.should_receive(:new).
249
+ with(@options, 'something').
250
+ and_return(runner)
251
+ @options.user_input_for_runner = "Custom::ExampleGroupRunner:something"
252
+
253
+ @options.run_examples
254
+ end
255
+
256
+ describe "#run_examples when there are example_group" do
257
+ before(:each) do
258
+ @options.add_example_group Class.new(::Spec::Example::ExampleGroup)
259
+ @options.formatters << Formatter::BaseTextFormatter.new(@options, @out)
260
+ end
261
+
262
+ it "runs the Examples and outputs the result" do
263
+ @options.run_examples
264
+ @out.string.should include("0 examples, 0 failures")
265
+ end
266
+
267
+ it "sets #examples_run? to true" do
268
+ @options.examples_run?.should be_false
269
+ @options.run_examples
270
+ @options.examples_run?.should be_true
271
+ end
272
+ end
273
+
274
+ describe "#run_examples when there are no example_group" do
275
+ before(:each) do
276
+ @options.formatters << Formatter::BaseTextFormatter.new(@options, @out)
277
+ end
278
+
279
+ it "does not run Examples and does not output a result" do
280
+ @options.run_examples
281
+ @out.string.should_not include("examples")
282
+ @out.string.should_not include("failures")
283
+ end
284
+
285
+ it "sets #examples_run? to false" do
286
+ @options.examples_run?.should be_false
287
+ @options.run_examples
288
+ @options.examples_run?.should be_false
289
+ end
290
+ end
172
291
  end
173
292
  end
174
293
  end