rspec 1.1.12 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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
@@ -1,40 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
- $global = 0
3
-
4
- describe "State created in before(:all)" do
5
- before :all do
6
- @sideeffect = 1
7
- $global +=1
8
- end
9
-
10
- before :each do
11
- @isolated = 1
12
- end
13
-
14
- it "should be accessible from example" do
15
- @sideeffect.should == 1
16
- $global.should == 1
17
- @isolated.should == 1
18
-
19
- @sideeffect += 1
20
- @isolated += 1
21
- end
22
-
23
- it "should not have sideffects" do
24
- @sideeffect.should == 1
25
- $global.should == 2
26
- @isolated.should == 1
27
-
28
- @sideeffect += 1
29
- @isolated += 1
30
- end
31
-
32
- after :each do
33
- $global += 1
34
- end
35
-
36
- after :all do
37
- $global.should == 3
38
- $global = 0
39
- end
40
- end
@@ -1,45 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- def behave_as_electric_musician
4
- respond_to(:read_notes, :turn_down_amp)
5
- end
6
-
7
- def behave_as_musician
8
- respond_to(:read_notes)
9
- end
10
-
11
- module BehaveAsExample
12
-
13
- class BluesGuitarist
14
- def read_notes; end
15
- def turn_down_amp; end
16
- end
17
-
18
- class RockGuitarist
19
- def read_notes; end
20
- def turn_down_amp; end
21
- end
22
-
23
- class ClassicGuitarist
24
- def read_notes; end
25
- end
26
-
27
- describe BluesGuitarist do
28
- it "should behave as guitarist" do
29
- BluesGuitarist.new.should behave_as_electric_musician
30
- end
31
- end
32
-
33
- describe RockGuitarist do
34
- it "should behave as guitarist" do
35
- RockGuitarist.new.should behave_as_electric_musician
36
- end
37
- end
38
-
39
- describe ClassicGuitarist do
40
- it "should not behave as guitarist" do
41
- ClassicGuitarist.new.should behave_as_musician
42
- end
43
- end
44
-
45
- end
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
- context "A legacy spec" do
3
- setup do
4
- end
5
-
6
- specify "should work fine" do
7
- end
8
-
9
- teardown do
10
- end
11
- end
@@ -1 +0,0 @@
1
- examples/custom_expectation_matchers.rb
@@ -1,16 +0,0 @@
1
- require 'spec/story'
2
- require File.dirname(__FILE__) + '/../../../spec/ruby_forker'
3
-
4
- module StoryHelper
5
- include RubyForker
6
-
7
- def spec(args, stderr)
8
- ruby("#{File.dirname(__FILE__) + '/../../../bin/spec'} #{args}", stderr)
9
- end
10
-
11
- def cmdline(args, stderr)
12
- ruby("#{File.dirname(__FILE__) + '/../../resources/helpers/cmdline.rb'} #{args}", stderr)
13
- end
14
-
15
- Spec::Story::World.__send__ :include, self
16
- end
@@ -1,17 +0,0 @@
1
- module Spec
2
- module Expectations
3
- module StringHelpers
4
- def starts_with?(prefix)
5
- to_s[0..(prefix.to_s.length - 1)] == prefix.to_s
6
- end
7
- end
8
- end
9
- end
10
-
11
- class String
12
- include Spec::Expectations::StringHelpers
13
- end
14
-
15
- class Symbol
16
- include Spec::Expectations::StringHelpers
17
- end
@@ -1,174 +0,0 @@
1
- require 'erb'
2
- require 'spec/runner/formatter/base_text_formatter'
3
-
4
- module Spec
5
- module Runner
6
- module Formatter
7
- module Story
8
- class HtmlFormatter < BaseTextFormatter
9
- include ERB::Util
10
-
11
- def initialize(options, where)
12
- super
13
- @previous_type = nil
14
- @scenario_text = ""
15
- @story_text = ""
16
- @scenario_failed = false
17
- @story_failed = false
18
- end
19
-
20
- def run_started(count)
21
- @output.puts <<-EOF
22
- <?xml version="1.0" encoding="UTF-8"?>
23
- <!DOCTYPE html
24
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
25
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
26
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
27
- <head>
28
- <title>Stories</title>
29
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
30
- <meta http-equiv="Expires" content="-1" />
31
- <meta http-equiv="Pragma" content="no-cache" />
32
- <script src="javascripts/prototype.js" type="text/javascript"></script>
33
- <script src="javascripts/scriptaculous.js" type="text/javascript"></script>
34
- <script src="javascripts/rspec.js" type="text/javascript"></script>
35
- <link href="stylesheets/rspec.css" rel="stylesheet" type="text/css" />
36
- </head>
37
- <body>
38
- <div id="container">
39
- EOF
40
- end
41
-
42
- def collected_steps(steps)
43
- unless steps.empty?
44
- @output.puts " <ul id=\"stock_steps\" style=\"display: none;\">"
45
- steps.each do |step|
46
- @output.puts " <li>#{step}</li>"
47
- end
48
- @output.puts " </ul>"
49
- end
50
- end
51
-
52
- def run_ended
53
- @output.puts <<-EOF
54
- </div>
55
- </body>
56
- </head>
57
- EOF
58
- end
59
-
60
- def story_started(title, narrative)
61
- @story_failed = false
62
- @story_text = <<-EOF
63
- <dt>Story: #{h title}</dt>
64
- <dd>
65
- <p>
66
- #{h(narrative).split("\n").join("<br />")}
67
- </p>
68
- EOF
69
- end
70
-
71
- def story_ended(title, narrative)
72
- if @story_failed
73
- @output.puts <<-EOF
74
- <dl class="story failed">
75
- EOF
76
- else
77
- @output.puts <<-EOF
78
- <dl class="story passed">
79
- EOF
80
- end
81
- @output.puts <<-EOF
82
- #{@story_text}
83
- </dd>
84
- </dl>
85
- EOF
86
- end
87
-
88
- def scenario_started(story_title, scenario_name)
89
- @previous_type = nil
90
- @scenario_failed = false
91
- @scenario_text = <<-EOF
92
- <dt>Scenario: #{h scenario_name}</dt>
93
- <dd>
94
- <ul class="steps">
95
- EOF
96
- end
97
-
98
- def scenario_ended
99
- if @scenario_failed
100
- @story_text += <<-EOF
101
- <dl class="failed">
102
- EOF
103
- else
104
- @story_text += <<-EOF
105
- <dl class="passed">
106
- EOF
107
- end
108
-
109
- @story_text += <<-EOF
110
- #{@scenario_text}
111
- </ul>
112
- </dd>
113
- </dl>
114
- EOF
115
- end
116
-
117
- def found_scenario(type, description)
118
- end
119
-
120
- def scenario_succeeded(story_title, scenario_name)
121
- scenario_ended
122
- end
123
-
124
- def scenario_pending(story_title, scenario_name, reason)
125
- scenario_ended
126
- end
127
-
128
- def scenario_failed(story_title, scenario_name, err)
129
- @scenario_failed = true
130
- @story_failed = true
131
- scenario_ended
132
- end
133
-
134
- def step_upcoming(type, description, *args)
135
- end
136
-
137
- def step_succeeded(type, description, *args)
138
- print_step('passed', type, description, *args) # TODO: uses succeeded CSS class
139
- end
140
-
141
- def step_pending(type, description, *args)
142
- print_step('pending', type, description, *args)
143
- end
144
-
145
- def step_failed(type, description, *args)
146
- print_step('failed', type, description, *args)
147
- end
148
-
149
- def print_step(klass, type, description, *args)
150
- spans = args.map { |arg| "<span class=\"param\">#{arg}</span>" }
151
- desc_string = description.step_name
152
- arg_regexp = description.arg_regexp
153
- inner = if(type == @previous_type)
154
- "And "
155
- else
156
- "#{type.to_s.capitalize} "
157
- end
158
- i = -1
159
- inner += desc_string.gsub(arg_regexp) { |param| spans[i+=1] }
160
-
161
- @scenario_text += " <li class=\"#{klass}\">#{inner}</li>\n"
162
-
163
- if type == :'given scenario'
164
- @previous_type = :given
165
- else
166
- @previous_type = type
167
- end
168
-
169
- end
170
- end
171
- end
172
- end
173
- end
174
- end
@@ -1,194 +0,0 @@
1
- require 'spec/runner/formatter/base_text_formatter'
2
-
3
- module Spec
4
- module Runner
5
- module Formatter
6
- module Story
7
- class PlainTextFormatter < BaseTextFormatter
8
- def initialize(options, where)
9
- super
10
- @successful_scenario_count = 0
11
- @pending_scenario_count = 0
12
-
13
- @pre_story_pending_count = 0
14
- @pre_story_successful_count = 0
15
-
16
- @failed_scenarios = []
17
- @pending_steps = []
18
- @previous_type = nil
19
-
20
- @scenario_body_text = ""
21
- @story_body_text = ""
22
-
23
- @scenario_head_text = ""
24
- @story_head_text = ""
25
-
26
- @scenario_failed = false
27
- @story_failed = false
28
- end
29
-
30
- def run_started(count)
31
- @count = count
32
- @output.puts "Running #@count scenarios\n\n"
33
- end
34
-
35
- def story_started(title, narrative)
36
- @pre_story_pending_count = @pending_scenario_count
37
- @pre_story_successful_count = @successful_scenario_count
38
-
39
- @current_story_title = title
40
- @story_failed = false
41
- @story_body_text = ""
42
- @story_head_text = "Story: #{title}\n\n"
43
-
44
- narrative.each_line do |line|
45
- @story_head_text += " "
46
- @story_head_text += line
47
- end
48
- end
49
-
50
- def story_ended(title, narrative)
51
- if @story_failed
52
- @output.print red(@story_head_text)
53
- elsif @pre_story_successful_count == @successful_scenario_count &&
54
- @pending_scenario_count >= @pre_story_pending_count
55
- @output.print yellow(@story_head_text)
56
- else
57
- @output.print green(@story_head_text)
58
- end
59
- @output.print @story_body_text
60
- @output.puts
61
- @output.puts
62
- end
63
-
64
- def scenario_started(story_title, scenario_name)
65
- @current_scenario_name = scenario_name
66
- @scenario_already_failed = false
67
- @scenario_head_text = "\n\n Scenario: #{scenario_name}"
68
- @scenario_body_text = ""
69
- @scenario_ok = true
70
- @scenario_pending = false
71
- @scenario_failed = false
72
- end
73
-
74
- def scenario_succeeded(story_title, scenario_name)
75
- @successful_scenario_count += 1
76
- scenario_ended
77
- end
78
-
79
- def scenario_failed(story_title, scenario_name, err)
80
- @options.backtrace_tweaker.tweak_backtrace(err)
81
- @failed_scenarios << [story_title, scenario_name, err] unless @scenario_already_failed
82
- @scenario_already_failed = true
83
- @story_failed = true
84
- @scenario_failed = true
85
- scenario_ended
86
- end
87
-
88
- def scenario_pending(story_title, scenario_name, msg)
89
- @pending_scenario_count += 1 unless @scenario_already_failed
90
- @scenario_pending = true
91
- @scenario_already_failed = true
92
- scenario_ended
93
- end
94
-
95
- def scenario_ended
96
- if @scenario_failed
97
- @story_body_text += red(@scenario_head_text)
98
- elsif @scenario_pending
99
- @story_body_text += yellow(@scenario_head_text)
100
- else
101
- @story_body_text += green(@scenario_head_text)
102
- end
103
- @story_body_text += @scenario_body_text
104
- end
105
-
106
- def run_ended
107
- summary_text = "#@count scenarios: #@successful_scenario_count succeeded, #{@failed_scenarios.size} failed, #@pending_scenario_count pending"
108
- if !@failed_scenarios.empty?
109
- @output.puts red(summary_text)
110
- elsif !@pending_steps.empty?
111
- @output.puts yellow(summary_text)
112
- else
113
- @output.puts green(summary_text)
114
- end
115
- unless @pending_steps.empty?
116
- @output.puts "\nPending Steps:"
117
- @pending_steps.each_with_index do |pending, i|
118
- story_name, scenario_name, msg = pending
119
- @output.puts "#{i+1}) #{story_name} (#{scenario_name}): #{msg}"
120
- end
121
- end
122
- unless @failed_scenarios.empty?
123
- @output.print "\nFAILURES:"
124
- @failed_scenarios.each_with_index do |failure, i|
125
- title, scenario_name, err = failure
126
- @output.print "\n #{i+1}) "
127
- @output.print red("#{title} (#{scenario_name}) FAILED")
128
- @output.print red("\n #{err.class}: #{err.message}")
129
- @output.print "\n #{err.backtrace.join("\n")}\n"
130
- end
131
- end
132
- end
133
-
134
- def step_upcoming(type, description, *args)
135
- end
136
-
137
- def step_succeeded(type, description, *args)
138
- found_step(type, description, false, false, *args)
139
- end
140
-
141
- def step_pending(type, description, *args)
142
- found_step(type, description, false, true, *args)
143
- @pending_steps << [@current_story_title, @current_scenario_name, description]
144
- @scenario_body_text += yellow(" (PENDING)")
145
- @scenario_pending = true
146
- @scenario_ok = false
147
- end
148
-
149
- def step_failed(type, description, *args)
150
- found_step(type, description, true, @scenario_pending, *args)
151
- if @scenario_pending
152
- @scenario_body_text += yellow(" (SKIPPED)")
153
- else
154
- @scenario_body_text += red(@scenario_ok ? " (FAILED)" : " (SKIPPED)")
155
- end
156
- @scenario_ok = false
157
- end
158
-
159
- def collected_steps(steps)
160
- end
161
-
162
- def method_missing(sym, *args, &block) #:nodoc:
163
- # noop - ignore unknown messages
164
- end
165
-
166
- private
167
-
168
- def found_step(type, description, failed, pending, *args)
169
- desc_string = description.step_name
170
- arg_regexp = description.arg_regexp
171
- text = if(type == @previous_type)
172
- "\n And "
173
- else
174
- "\n\n #{type.to_s.capitalize} "
175
- end
176
- i = -1
177
- text << desc_string.gsub(arg_regexp) { |param| args[i+=1] }
178
- if pending
179
- @scenario_body_text += yellow(text)
180
- else
181
- @scenario_body_text += (failed ? red(text) : green(text))
182
- end
183
-
184
- if type == :'given scenario'
185
- @previous_type = :given
186
- else
187
- @previous_type = type
188
- end
189
- end
190
- end
191
- end
192
- end
193
- end
194
- end