rspec 1.1.12 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. data/.autotest +2 -1
  2. data/.document +7 -0
  3. data/History.txt +58 -0
  4. data/License.txt +1 -1
  5. data/Manifest.txt +45 -82
  6. data/README.txt +3 -6
  7. data/Rakefile +33 -13
  8. data/Ruby1.9.markdown +32 -0
  9. data/TODO.txt +10 -4
  10. data/Upgrade.markdown +63 -0
  11. data/bin/spec +1 -1
  12. data/cucumber.yml +3 -0
  13. data/examples/failing/{failing_autogenerated_docstrings_example.rb → failing_implicit_docstrings_example.rb} +0 -0
  14. data/examples/failing/pending_example.rb +9 -0
  15. data/examples/failing/spec_helper.rb +1 -1
  16. data/examples/passing/{custom_expectation_matchers.rb → custom_matchers.rb} +0 -0
  17. data/examples/passing/filtered_formatter.rb +18 -0
  18. data/examples/passing/filtered_formatter_example.rb +31 -0
  19. data/examples/passing/implicit_docstrings_example.rb +18 -0
  20. data/examples/passing/spec_helper.rb +1 -1
  21. data/examples/ruby1.9.compatibility/access_to_constants_spec.rb +17 -18
  22. data/features/before_and_after_blocks/before_and_after_blocks.feature +4 -4
  23. data/features/example_groups/example_group_with_should_methods.feature +1 -1
  24. data/features/example_groups/{autogenerated_docstrings.feature → implicit_docstrings.feature} +7 -9
  25. data/features/example_groups/nested_groups.feature +1 -1
  26. data/features/heckle/heckle.feature +56 -0
  27. data/features/interop/examples_and_tests_together.feature +1 -1
  28. data/features/interop/test_but_not_test_unit.feature +1 -1
  29. data/features/interop/test_case_with_should_methods.feature +1 -1
  30. data/features/matchers/create_matcher.feature +115 -0
  31. data/features/mock_framework_integration/use_flexmock.feature +22 -4
  32. data/features/mock_framework_integration/use_mocha.feature +27 -0
  33. data/features/mock_framework_integration/use_rr.feature +27 -0
  34. data/features/mocks/mix_stubs_and_mocks.feature +22 -0
  35. data/features/pending/pending_examples.feature +81 -0
  36. data/features/step_definitions/running_rspec.rb +5 -3
  37. data/features/support/env.rb +1 -1
  38. data/features/support/matchers/smart_match.rb +2 -2
  39. data/lib/autotest/rspec.rb +1 -1
  40. data/lib/spec.rb +1 -1
  41. data/lib/{adapters → spec/adapters}/mock_frameworks/flexmock.rb +0 -0
  42. data/lib/{adapters → spec/adapters}/mock_frameworks/mocha.rb +0 -0
  43. data/lib/{adapters → spec/adapters}/mock_frameworks/rr.rb +0 -0
  44. data/lib/{adapters → spec/adapters}/mock_frameworks/rspec.rb +0 -1
  45. data/lib/spec/autorun.rb +3 -0
  46. data/lib/spec/dsl.rb +3 -1
  47. data/lib/spec/dsl/matchers.rb +13 -0
  48. data/lib/spec/example.rb +4 -0
  49. data/lib/spec/example/before_and_after_hooks.rb +5 -20
  50. data/lib/spec/example/errors.rb +3 -3
  51. data/lib/spec/example/example_description.rb +15 -0
  52. data/lib/spec/example/example_group.rb +0 -15
  53. data/lib/spec/example/example_group_factory.rb +34 -46
  54. data/lib/spec/example/example_group_hierarchy.rb +53 -0
  55. data/lib/spec/example/example_group_methods.rb +101 -211
  56. data/lib/spec/example/example_methods.rb +61 -81
  57. data/lib/spec/example/module_reopening_fix.rb +23 -1
  58. data/lib/spec/example/pending.rb +3 -2
  59. data/lib/spec/example/predicate_matchers.rb +47 -0
  60. data/lib/spec/example/subject.rb +91 -0
  61. data/lib/spec/expectations.rb +1 -1
  62. data/lib/spec/expectations/differs/default.rb +0 -1
  63. data/lib/spec/expectations/extensions.rb +0 -1
  64. data/lib/spec/expectations/handler.rb +13 -6
  65. data/lib/spec/interop/test.rb +5 -0
  66. data/lib/spec/interop/test/unit/testcase.rb +5 -22
  67. data/lib/spec/matchers.rb +22 -8
  68. data/lib/spec/matchers/be.rb +4 -9
  69. data/lib/spec/matchers/be_close.rb +20 -5
  70. data/lib/spec/matchers/be_instance_of.rb +45 -0
  71. data/lib/spec/matchers/be_kind_of.rb +45 -0
  72. data/lib/spec/matchers/change.rb +8 -6
  73. data/lib/spec/matchers/compatibility.rb +14 -0
  74. data/lib/spec/matchers/eql.rb +24 -6
  75. data/lib/spec/matchers/equal.rb +24 -6
  76. data/lib/spec/matchers/exist.rb +21 -5
  77. data/lib/spec/matchers/extensions/instance_exec.rb +25 -0
  78. data/lib/spec/matchers/generated_descriptions.rb +2 -2
  79. data/lib/spec/matchers/has.rb +28 -11
  80. data/lib/spec/matchers/have.rb +2 -2
  81. data/lib/spec/matchers/include.rb +2 -2
  82. data/lib/spec/matchers/match.rb +25 -7
  83. data/lib/spec/matchers/match_array.rb +3 -3
  84. data/lib/spec/matchers/matcher.rb +51 -0
  85. data/lib/spec/matchers/method_missing.rb +2 -2
  86. data/lib/spec/matchers/operator_matcher.rb +12 -5
  87. data/lib/spec/matchers/raise_error.rb +3 -3
  88. data/lib/spec/matchers/respond_to.rb +3 -3
  89. data/lib/spec/matchers/satisfy.rb +7 -7
  90. data/lib/spec/matchers/throw_symbol.rb +3 -5
  91. data/lib/spec/mocks.rb +3 -3
  92. data/lib/spec/mocks/argument_expectation.rb +15 -15
  93. data/lib/spec/mocks/{argument_constraints.rb → argument_matchers.rb} +19 -23
  94. data/lib/spec/mocks/error_generator.rb +5 -8
  95. data/lib/spec/mocks/framework.rb +1 -1
  96. data/lib/spec/mocks/message_expectation.rb +5 -13
  97. data/lib/spec/mocks/mock.rb +4 -5
  98. data/lib/spec/mocks/proxy.rb +9 -5
  99. data/lib/spec/mocks/spec_methods.rb +10 -1
  100. data/lib/spec/rake/spectask.rb +0 -1
  101. data/lib/spec/runner.rb +6 -28
  102. data/lib/spec/runner/configuration.rb +3 -3
  103. data/lib/spec/runner/drb_command_line.rb +2 -1
  104. data/lib/spec/runner/example_group_runner.rb +3 -2
  105. data/lib/spec/runner/formatter/base_text_formatter.rb +34 -19
  106. data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +3 -5
  107. data/lib/spec/runner/formatter/html_formatter.rb +2 -3
  108. data/lib/spec/runner/formatter/nested_text_formatter.rb +7 -25
  109. data/lib/spec/runner/formatter/progress_bar_formatter.rb +1 -1
  110. data/lib/spec/runner/formatter/snippet_extractor.rb +1 -1
  111. data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -7
  112. data/lib/spec/runner/heckle_runner.rb +3 -6
  113. data/lib/spec/runner/heckle_runner_unsupported.rb +1 -1
  114. data/lib/spec/runner/option_parser.rb +19 -21
  115. data/lib/spec/runner/options.rb +32 -27
  116. data/lib/spec/runner/reporter.rb +8 -9
  117. data/lib/spec/test/unit.rb +10 -0
  118. data/lib/spec/version.rb +2 -2
  119. data/{features/support → resources}/helpers/cmdline.rb +2 -2
  120. data/resources/rake/verify_rcov.rake +1 -1
  121. data/resources/spec/example_group_with_should_methods.rb +1 -1
  122. data/resources/spec/simple_spec.rb +1 -1
  123. data/resources/test/spec_and_test_together.rb +2 -3
  124. data/resources/test/spec_including_test_but_not_unit.rb +1 -1
  125. data/resources/test/test_case_with_should_methods.rb +2 -3
  126. data/spec/autotest/autotest_helper.rb +0 -1
  127. data/spec/autotest/rspec_spec.rb +95 -98
  128. data/spec/spec/dsl/main_spec.rb +3 -3
  129. data/spec/spec/dsl/matchers_spec.rb +25 -0
  130. data/spec/spec/example/example_group_class_definition_spec.rb +14 -15
  131. data/spec/spec/example/example_group_factory_spec.rb +31 -44
  132. data/spec/spec/example/example_group_methods_spec.rb +86 -52
  133. data/spec/spec/example/example_group_spec.rb +32 -79
  134. data/spec/spec/example/example_matcher_spec.rb +10 -10
  135. data/spec/spec/example/example_methods_spec.rb +108 -242
  136. data/spec/spec/example/nested_example_group_spec.rb +2 -2
  137. data/spec/spec/example/pending_module_spec.rb +66 -41
  138. data/spec/spec/example/shared_example_group_spec.rb +4 -4
  139. data/spec/spec/{matchers → expectations}/handler_spec.rb +52 -4
  140. data/spec/spec/interop/test/unit/resources/spec_that_fails.rb +2 -2
  141. data/spec/spec/interop/test/unit/resources/spec_that_passes.rb +2 -2
  142. data/spec/spec/interop/test/unit/resources/spec_with_errors.rb +2 -2
  143. data/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb +2 -2
  144. data/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +2 -2
  145. data/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +2 -2
  146. data/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +2 -2
  147. data/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +2 -2
  148. data/spec/spec/interop/test/unit/testcase_spec.rb +0 -4
  149. data/spec/spec/matchers/be_close_spec.rb +1 -1
  150. data/spec/spec/matchers/be_instance_of_spec.rb +29 -0
  151. data/spec/spec/matchers/be_kind_of_spec.rb +29 -0
  152. data/spec/spec/matchers/change_spec.rb +20 -0
  153. data/spec/spec/matchers/compatibility_spec.rb +34 -0
  154. data/spec/spec/matchers/description_generation_spec.rb +0 -12
  155. data/spec/spec/matchers/eql_spec.rb +2 -2
  156. data/spec/spec/matchers/equal_spec.rb +2 -2
  157. data/spec/spec/matchers/exist_spec.rb +8 -4
  158. data/spec/spec/matchers/have_spec.rb +4 -4
  159. data/spec/spec/matchers/match_spec.rb +2 -2
  160. data/spec/spec/matchers/matcher_methods_spec.rb +1 -1
  161. data/spec/spec/matchers/matcher_spec.rb +97 -0
  162. data/spec/spec/matchers/throw_symbol_spec.rb +8 -8
  163. data/spec/spec/mocks/{bug_report_496.rb → bug_report_496_spec.rb} +0 -0
  164. data/spec/spec/mocks/{failing_mock_argument_constraints_spec.rb → failing_argument_matchers_spec.rb} +2 -2
  165. data/spec/spec/mocks/hash_including_matcher_spec.rb +4 -4
  166. data/spec/spec/mocks/hash_not_including_matcher_spec.rb +3 -3
  167. data/spec/spec/mocks/mock_spec.rb +27 -2
  168. data/spec/spec/mocks/nil_expectation_warning_spec.rb +1 -1
  169. data/spec/spec/mocks/partial_mock_spec.rb +18 -3
  170. data/spec/spec/mocks/{passing_mock_argument_constraints_spec.rb → passing_argument_matchers_spec.rb} +6 -6
  171. data/spec/spec/mocks/stubbed_message_expectations_spec.rb +13 -1
  172. data/spec/spec/package/bin_spec_spec.rb +2 -2
  173. data/spec/spec/runner/configuration_spec.rb +12 -12
  174. data/spec/spec/runner/drb_command_line_spec.rb +71 -73
  175. data/spec/spec/runner/formatter/base_text_formatter_spec.rb +82 -1
  176. data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +8 -8
  177. data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +4 -4
  178. data/spec/spec/runner/formatter/html_formatted-1.8.6.html +8 -8
  179. data/spec/spec/runner/formatter/html_formatted-1.8.7.html +38 -26
  180. data/spec/spec/runner/formatter/html_formatted-1.9.1.html +61 -53
  181. data/spec/spec/runner/formatter/html_formatter_spec.rb +100 -48
  182. data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +20 -34
  183. data/spec/spec/runner/formatter/profile_formatter_spec.rb +2 -1
  184. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +9 -6
  185. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +6 -6
  186. data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +20 -20
  187. data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +38 -26
  188. data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +55 -47
  189. data/spec/spec/runner/formatter/{spec_mate_formatter_spec.rb → text_mate_formatter_spec.rb} +11 -9
  190. data/spec/spec/runner/heckle_runner_spec.rb +1 -1
  191. data/spec/spec/runner/heckler_spec.rb +1 -1
  192. data/spec/spec/runner/option_parser_spec.rb +28 -11
  193. data/spec/spec/runner/options_spec.rb +34 -0
  194. data/spec/spec/runner/reporter_spec.rb +66 -62
  195. data/spec/spec/runner/resources/utf8_encoded.rb +1 -0
  196. data/spec/spec/runner/spec_drb.opts +1 -0
  197. data/spec/spec/runner_spec.rb +7 -5
  198. data/spec/spec_helper.rb +24 -2
  199. metadata +49 -90
  200. data/examples/passing/autogenerated_docstrings_example.rb +0 -25
  201. data/examples/passing/before_and_after_example.rb +0 -40
  202. data/examples/passing/behave_as_example.rb +0 -45
  203. data/examples/passing/legacy_spec.rb +0 -11
  204. data/examples/passing/priority.txt +0 -1
  205. data/features/support/helpers/story_helper.rb +0 -16
  206. data/lib/spec/expectations/extensions/string_and_symbol.rb +0 -17
  207. data/lib/spec/runner/formatter/story/html_formatter.rb +0 -174
  208. data/lib/spec/runner/formatter/story/plain_text_formatter.rb +0 -194
  209. data/lib/spec/runner/formatter/story/progress_bar_formatter.rb +0 -42
  210. data/lib/spec/story.rb +0 -10
  211. data/lib/spec/story/extensions.rb +0 -3
  212. data/lib/spec/story/extensions/main.rb +0 -86
  213. data/lib/spec/story/extensions/regexp.rb +0 -9
  214. data/lib/spec/story/extensions/string.rb +0 -9
  215. data/lib/spec/story/given_scenario.rb +0 -14
  216. data/lib/spec/story/runner.rb +0 -57
  217. data/lib/spec/story/runner/plain_text_story_runner.rb +0 -48
  218. data/lib/spec/story/runner/scenario_collector.rb +0 -18
  219. data/lib/spec/story/runner/scenario_runner.rb +0 -54
  220. data/lib/spec/story/runner/story_mediator.rb +0 -137
  221. data/lib/spec/story/runner/story_parser.rb +0 -247
  222. data/lib/spec/story/runner/story_runner.rb +0 -74
  223. data/lib/spec/story/scenario.rb +0 -14
  224. data/lib/spec/story/step.rb +0 -70
  225. data/lib/spec/story/step_group.rb +0 -89
  226. data/lib/spec/story/step_mother.rb +0 -38
  227. data/lib/spec/story/story.rb +0 -39
  228. data/lib/spec/story/world.rb +0 -124
  229. data/resources/spec/spec_with_flexmock.rb +0 -19
  230. data/rspec.gemspec +0 -32
  231. data/spec/spec/matchers/mock_constraint_matchers_spec.rb +0 -24
  232. data/spec/spec/runner/formatter/story/html_formatter_spec.rb +0 -135
  233. data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +0 -600
  234. data/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb +0 -82
  235. data/spec/spec/spec_spec.rb +0 -21
  236. data/spec/spec/story/builders.rb +0 -46
  237. data/spec/spec/story/extensions/main_spec.rb +0 -161
  238. data/spec/spec/story/extensions_spec.rb +0 -14
  239. data/spec/spec/story/given_scenario_spec.rb +0 -27
  240. data/spec/spec/story/runner/plain_text_story_runner_spec.rb +0 -90
  241. data/spec/spec/story/runner/scenario_collector_spec.rb +0 -27
  242. data/spec/spec/story/runner/scenario_runner_spec.rb +0 -214
  243. data/spec/spec/story/runner/story_mediator_spec.rb +0 -143
  244. data/spec/spec/story/runner/story_parser_spec.rb +0 -401
  245. data/spec/spec/story/runner/story_runner_spec.rb +0 -294
  246. data/spec/spec/story/runner_spec.rb +0 -93
  247. data/spec/spec/story/scenario_spec.rb +0 -18
  248. data/spec/spec/story/step_group_spec.rb +0 -157
  249. data/spec/spec/story/step_mother_spec.rb +0 -84
  250. data/spec/spec/story/step_spec.rb +0 -272
  251. data/spec/spec/story/story_helper.rb +0 -2
  252. data/spec/spec/story/story_spec.rb +0 -84
  253. data/spec/spec/story/world_spec.rb +0 -423
  254. data/story_server/prototype/javascripts/builder.js +0 -136
  255. data/story_server/prototype/javascripts/controls.js +0 -972
  256. data/story_server/prototype/javascripts/dragdrop.js +0 -976
  257. data/story_server/prototype/javascripts/effects.js +0 -1117
  258. data/story_server/prototype/javascripts/prototype.js +0 -4140
  259. data/story_server/prototype/javascripts/rspec.js +0 -149
  260. data/story_server/prototype/javascripts/scriptaculous.js +0 -58
  261. data/story_server/prototype/javascripts/slider.js +0 -276
  262. data/story_server/prototype/javascripts/sound.js +0 -55
  263. data/story_server/prototype/javascripts/unittest.js +0 -568
  264. data/story_server/prototype/lib/server.rb +0 -24
  265. data/story_server/prototype/stories.html +0 -176
  266. data/story_server/prototype/stylesheets/rspec.css +0 -136
  267. data/story_server/prototype/stylesheets/test.css +0 -90
@@ -1,82 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../../spec_helper'
2
- require 'spec/runner/formatter/story/progress_bar_formatter'
3
-
4
- module Spec
5
- module Runner
6
- module Formatter
7
- module Story
8
- describe ProgressBarFormatter do
9
- before :each do
10
- # given
11
- @out = StringIO.new
12
- @out.stub!(:tty?).and_return(true)
13
- @tweaker = mock('tweaker')
14
- @tweaker.stub!(:tweak_backtrace)
15
- @options = mock('options')
16
- @options.stub!(:colour).and_return(true)
17
- @options.stub!(:backtrace_tweaker).and_return(@tweaker)
18
-
19
- @formatter = ProgressBarFormatter.new(@options, @out)
20
- end
21
-
22
- it 'should print some white space before test summary' do
23
- #when
24
- @formatter.run_started(1)
25
- @formatter.run_ended
26
-
27
- #then
28
- @out.string.should =~ /^\n{2}/
29
- end
30
-
31
- it "should print how long tests took to complete" do
32
- #when
33
- now = Time.now
34
- future = now+1
35
- Time.stub!(:now).and_return(now)
36
- @formatter.run_started(1)
37
- Time.stub!(:now).and_return(future)
38
- @formatter.run_ended
39
-
40
- #then
41
- @out.string.should include("Finished in %f seconds" % (future-now))
42
- end
43
-
44
-
45
- it "should push green dot for passing scenario" do
46
- #when
47
- @formatter.scenario_started('','')
48
- @formatter.step_succeeded('', '')
49
- @formatter.scenario_ended
50
- @formatter.story_ended '', ''
51
-
52
- #then
53
- @out.string.should eql("\e[32m.\e[0m")
54
- end
55
-
56
- it "should push red F for failure scenario" do
57
- #when
58
- @formatter.scenario_started('','')
59
- @formatter.step_failed('', '')
60
- @formatter.scenario_failed('', '', '')
61
- @formatter.story_ended '', ''
62
-
63
- #then
64
- @out.string.should eql("\e[31mF\e[0m")
65
- end
66
-
67
- it "should push yellow P for pending scenario" do
68
- #when
69
- @formatter.scenario_started('','')
70
- @formatter.step_pending('', '')
71
- @formatter.scenario_pending('story', '', '')
72
- @formatter.story_ended '', ''
73
-
74
- #then
75
- @out.string.should eql("\e[33mP\e[0m")
76
- end
77
-
78
- end
79
- end
80
- end
81
- end
82
- end
@@ -1,21 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- describe Spec::Runner, "#exit?" do
4
- describe "when ::Test is absent during loading but present when running exit?" do
5
- # believe it or not, this can happen when ActiveSupport is loaded after RSpec is,
6
- # since it loads active_support/core_ext/test/unit/assertions.rb which defines
7
- # Test::Unit but doesn't actually load test/unit
8
-
9
- before(:each) do
10
- Object.const_set(:Test, Module.new)
11
- end
12
-
13
- it "does not attempt to access the non-loaded test/unit library" do
14
- lambda { Spec::Runner.exit? }.should_not raise_error
15
- end
16
-
17
- after(:each) do
18
- Object.send(:remove_const, :Test)
19
- end
20
- end
21
- end
@@ -1,46 +0,0 @@
1
- module Spec
2
- module Story
3
- class StoryBuilder
4
- def initialize
5
- @title = 'a story'
6
- @narrative = 'narrative'
7
- end
8
-
9
- def title(value)
10
- @title = value
11
- self
12
- end
13
-
14
- def narrative(value)
15
- @narrative = value
16
- self
17
- end
18
-
19
- def to_story(&block)
20
- block = lambda {} unless block_given?
21
- Story.new @title, @narrative, &block
22
- end
23
- end
24
-
25
- class ScenarioBuilder
26
- def initialize
27
- @name = 'a scenario'
28
- @story = StoryBuilder.new.to_story
29
- end
30
-
31
- def name(value)
32
- @name = value
33
- self
34
- end
35
-
36
- def story(value)
37
- @story = value
38
- self
39
- end
40
-
41
- def to_scenario(&block)
42
- Scenario.new @story, @name, &block
43
- end
44
- end
45
- end
46
- end
@@ -1,161 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
-
3
- module Spec
4
- module Story
5
- module Extensions
6
- describe "the main object extended with Main", :shared => true do
7
- before(:each) do
8
- @main = Class.new do; include Main; end
9
- @original_rspec_story_steps, $rspec_story_steps = $rspec_story_steps, nil
10
- end
11
-
12
- after(:each) do
13
- $rspec_story_steps = @original_rspec_story_steps
14
- end
15
-
16
- def have_step(type, name)
17
- return simple_matcher(%[step group containing a #{type} named #{name.inspect}]) do |actual|
18
- Spec::Story::Step === actual.find(type, name)
19
- end
20
- end
21
- end
22
-
23
- describe Main, "#run_story" do
24
- it_should_behave_like "the main object extended with Main"
25
-
26
- it "should create a PlainTextStoryRunner with run_story" do
27
- Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).and_return(mock("runner", :null_object => true))
28
- @main.run_story
29
- end
30
-
31
- it "should yield the runner if arity == 1" do
32
- File.should_receive(:read).with("some/path").and_return("Story: foo")
33
- $main_spec_runner = nil
34
- @main.run_story("some/path") do |runner|
35
- $main_spec_runner = runner
36
- end
37
- $main_spec_runner.should be_an_instance_of(Spec::Story::Runner::PlainTextStoryRunner)
38
- end
39
-
40
- it "should run in the runner if arity == 0" do
41
- File.should_receive(:read).with("some/path").and_return("Story: foo")
42
- $main_spec_runner = nil
43
- @main.run_story("some/path") do
44
- $main_spec_runner = self
45
- end
46
- $main_spec_runner.should be_an_instance_of(Spec::Story::Runner::PlainTextStoryRunner)
47
- end
48
-
49
- it "should tell the PlainTextStoryRunner to run with run_story" do
50
- runner = mock("runner")
51
- Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).and_return(runner)
52
- runner.should_receive(:run)
53
- @main.run_story
54
- end
55
- end
56
-
57
- describe Main, "#steps_for" do
58
- it_should_behave_like "the main object extended with Main"
59
-
60
- it "should have no steps for a non existent key" do
61
- @main.steps_for(:key).find(:given, "foo").should be_nil
62
- end
63
-
64
- it "should create steps for a key" do
65
- $main_spec_invoked = false
66
- @main.steps_for(:key) do
67
- Given("foo") {
68
- $main_spec_invoked = true
69
- }
70
- end
71
- @main.steps_for(:key).find(:given, "foo").perform(Object.new, "foo")
72
- $main_spec_invoked.should be_true
73
- end
74
-
75
- it "should append steps to steps_for a given key" do
76
- @main.steps_for(:key) do
77
- Given("first") {}
78
- end
79
- @main.steps_for(:key) do
80
- Given("second") {}
81
- end
82
- @main.steps_for(:key).should have_step(:given, "first")
83
- @main.steps_for(:key).should have_step(:given, "second")
84
- end
85
- end
86
-
87
- describe Main, "#with_steps_for adding new steps" do
88
- it_should_behave_like "the main object extended with Main"
89
-
90
- it "should result in a group containing pre-existing steps and newly defined steps" do
91
- first_group = @main.steps_for(:key) do
92
- Given("first") {}
93
- end
94
- second_group = @main.with_steps_for(:key) do
95
- Given("second") {}
96
- end
97
-
98
- second_group.should have_step(:given, "first")
99
- second_group.should have_step(:given, "second")
100
- end
101
-
102
- it "should not add its steps to the existing group" do
103
- first_group = @main.steps_for(:key) do
104
- Given("first") {}
105
- end
106
- second_group = @main.with_steps_for(:key) do
107
- Given("second") {}
108
- end
109
-
110
- first_group.should have_step(:given, "first")
111
- first_group.should_not have_step(:given, "second")
112
- end
113
- end
114
-
115
- describe Main, "#with_steps_for running a story" do
116
- it_should_behave_like "the main object extended with Main"
117
-
118
- before(:each) do
119
- @runner = mock("runner")
120
- @runner_step_group = StepGroup.new
121
- @runner.stub!(:steps).and_return(@runner_step_group)
122
- @runner.stub!(:run)
123
- Spec::Story::Runner::PlainTextStoryRunner.stub!(:new).and_return(@runner)
124
- end
125
-
126
- it "should create a PlainTextStoryRunner with a path" do
127
- Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).with('path/to/file',{}).and_return(@runner)
128
- @main.with_steps_for(:foo) do
129
- run 'path/to/file'
130
- end
131
- end
132
-
133
- it "should create a PlainTextStoryRunner with a path and options" do
134
- Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).with(anything,{:bar => :baz}).and_return(@runner)
135
- @main.with_steps_for(:foo) do
136
- run 'path/to/file', :bar => :baz
137
- end
138
- end
139
-
140
- it "should pass the group it creates to the runner's steps" do
141
- steps = @main.steps_for(:ice_cream) do
142
- Given("vanilla") {}
143
- end
144
- @main.with_steps_for(:ice_cream) do
145
- run 'foo'
146
- end
147
- @runner_step_group.should have_step(:given, "vanilla")
148
- end
149
-
150
- it "should run a story" do
151
- @runner.should_receive(:run)
152
- Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).and_return(@runner)
153
- @main.with_steps_for(:foo) do
154
- run 'path/to/file'
155
- end
156
- end
157
-
158
- end
159
- end
160
- end
161
- end
@@ -1,14 +0,0 @@
1
- require File.dirname(__FILE__) + '/story_helper'
2
-
3
- require 'spec/story'
4
-
5
- describe Kernel, "#Story" do
6
- before(:each) do
7
- Kernel.stub!(:at_exit)
8
- end
9
-
10
- it "should delegate to ::Spec::Story::Runner.story_runner" do
11
- ::Spec::Story::Runner.story_runner.should_receive(:Story)
12
- story = Story("title","narrative"){}
13
- end
14
- end
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + '/story_helper'
2
-
3
- module Spec
4
- module Story
5
- describe GivenScenario do
6
- it 'should execute a scenario from the current story in its world' do
7
- # given
8
- class MyWorld
9
- attr :scenario_ran
10
- end
11
- instance = World.create(MyWorld)
12
- scenario = ScenarioBuilder.new.to_scenario do
13
- @scenario_ran = true
14
- end
15
- Runner::StoryRunner.should_receive(:scenario_from_current_story).with('scenario name').and_return(scenario)
16
-
17
- step = GivenScenario.new 'scenario name'
18
-
19
- # when
20
- step.perform(instance, nil)
21
-
22
- # then
23
- instance.scenario_ran.should be_true
24
- end
25
- end
26
- end
27
- end
@@ -1,90 +0,0 @@
1
- require File.dirname(__FILE__) + '/../story_helper'
2
-
3
- module Spec
4
- module Story
5
- module Runner
6
- describe PlainTextStoryRunner do
7
- before(:each) do
8
- StoryParser.stub!(:new).and_return(@parser = mock("parser"))
9
- @parser.stub!(:parse).and_return([])
10
- File.stub!(:read).with("path").and_return("this\nand that")
11
- end
12
-
13
- it "should provide access to steps" do
14
- runner = PlainTextStoryRunner.new("path")
15
-
16
- runner.steps do |add|
17
- add.given("baz") {}
18
- end
19
-
20
- runner.steps.find(:given, "baz").should_not be_nil
21
- end
22
-
23
- it "should parse a story file" do
24
- runner = PlainTextStoryRunner.new("path")
25
- @parser.should_receive(:parse).with(["this", "and that"])
26
- runner.run(mock('runner'))
27
- end
28
-
29
- it "should build up a mediator with its own steps and the singleton story_runner" do
30
- @story_runner = mock('story runner', :null_object => true)
31
-
32
- runner = PlainTextStoryRunner.new("path")
33
-
34
- Spec::Story::Runner::StoryMediator.should_receive(:new).with(
35
- runner.steps, @story_runner, {}
36
- ).and_return(mediator = stub("mediator", :run_stories => nil))
37
- runner.run(@story_runner)
38
- end
39
-
40
- it "should build up a parser with the mediator" do
41
- runner = PlainTextStoryRunner.new("path")
42
- Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator = stub("mediator", :run_stories => nil))
43
- Spec::Story::Runner::StoryParser.should_receive(:new).with(mediator).and_return(@parser)
44
- runner.run(stub("story_runner"))
45
- end
46
-
47
- it "should tell the mediator to run the stories" do
48
- runner = PlainTextStoryRunner.new("path")
49
- mediator = mock("mediator")
50
- Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator)
51
- mediator.should_receive(:run_stories)
52
- runner.run(mock('runner'))
53
- end
54
-
55
- it "should accept a block instead of a path" do
56
- runner = PlainTextStoryRunner.new do |runner|
57
- runner.load("path/to/story")
58
- end
59
- File.should_receive(:read).with("path/to/story").and_return("this\nand that")
60
- runner.run(mock('runner'))
61
- end
62
-
63
- it "should tell you if you try to run with no path set" do
64
- runner = PlainTextStoryRunner.new
65
- lambda {
66
- runner.run(mock('runner'))
67
- }.should raise_error(RuntimeError, "You must set a path to the file with the story. See the RDoc.")
68
- end
69
-
70
- it "should pass options to the mediator" do
71
- runner = PlainTextStoryRunner.new("path", :foo => :bar)
72
- Spec::Story::Runner::StoryMediator.should_receive(:new).
73
- with(anything, anything, :foo => :bar).
74
- and_return(mediator = stub("mediator", :run_stories => nil))
75
- runner.run(mock('runner'))
76
- end
77
-
78
- it "should provide access to its options" do
79
- runner = PlainTextStoryRunner.new("path")
80
- runner[:foo] = :bar
81
- Spec::Story::Runner::StoryMediator.should_receive(:new).
82
- with(anything, anything, :foo => :bar).
83
- and_return(mediator = stub("mediator", :run_stories => nil))
84
- runner.run mock('runner')
85
- end
86
-
87
- end
88
- end
89
- end
90
- end