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
@@ -128,19 +128,34 @@ module Spec
128
128
 
129
129
  it 'should keep public methods public' do
130
130
  @object.should_receive(:public_method)
131
- @object.public_methods.should include('public_method')
131
+ with_ruby('1.9') do
132
+ @object.public_methods.should include(:public_method)
133
+ end
134
+ with_ruby('1.8') do
135
+ @object.public_methods.should include('public_method')
136
+ end
132
137
  @object.public_method
133
138
  end
134
139
 
135
140
  it 'should keep private methods private' do
136
141
  @object.should_receive(:private_method)
137
- @object.private_methods.should include('private_method')
142
+ with_ruby('1.9') do
143
+ @object.private_methods.should include(:private_method)
144
+ end
145
+ with_ruby('1.8') do
146
+ @object.private_methods.should include('private_method')
147
+ end
138
148
  @object.public_method
139
149
  end
140
150
 
141
151
  it 'should keep protected methods protected' do
142
152
  @object.should_receive(:protected_method)
143
- @object.protected_methods.should include('protected_method')
153
+ with_ruby('1.9') do
154
+ @object.protected_methods.should include(:protected_method)
155
+ end
156
+ with_ruby('1.8') do
157
+ @object.protected_methods.should include('protected_method')
158
+ end
144
159
  @object.public_method
145
160
  end
146
161
 
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  module Spec
4
4
  module Mocks
5
- describe "mock argument constraints", :shared => true do
5
+ describe "mock argument matchers", :shared => true do
6
6
  before(:each) do
7
7
  @mock = Mock.new("test mock")
8
8
  Kernel.stub!(:warn)
@@ -13,8 +13,8 @@ module Spec
13
13
  end
14
14
  end
15
15
 
16
- describe Methods, "handling argument constraints" do
17
- it_should_behave_like "mock argument constraints"
16
+ describe Methods, "handling argument matchers" do
17
+ it_should_behave_like "mock argument matchers"
18
18
 
19
19
  it "should accept true as boolean()" do
20
20
  @mock.should_receive(:random_call).with(boolean())
@@ -88,8 +88,8 @@ module Spec
88
88
 
89
89
  end
90
90
 
91
- describe Methods, "handling block constraints" do
92
- it_should_behave_like "mock argument constraints"
91
+ describe Methods, "handling block matchers" do
92
+ it_should_behave_like "mock argument matchers"
93
93
 
94
94
  it "should match arguments against RSpec expectations" do
95
95
  @mock.should_receive(:random_call).with {|arg1, arg2, arr, *rest|
@@ -103,7 +103,7 @@ module Spec
103
103
  end
104
104
  end
105
105
 
106
- describe Methods, "handling non-constraint arguments" do
106
+ describe Methods, "handling non-matcher arguments" do
107
107
 
108
108
  before(:each) do
109
109
  @mock = Mock.new("test mock")
@@ -3,12 +3,24 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
3
3
  module Spec
4
4
  module Mocks
5
5
  describe "Example with stubbed and then called message" do
6
- it "should fail if the message is expected and then subsequently not called again" do
6
+ it "fails if the message is expected and then subsequently not called again" do
7
7
  mock_obj = mock("mock", :msg => nil)
8
8
  mock_obj.msg
9
9
  mock_obj.should_receive(:msg)
10
10
  lambda { mock_obj.rspec_verify }.should raise_error(Spec::Mocks::MockExpectationError)
11
11
  end
12
+
13
+ it "outputs arguments of all similar calls" do
14
+ m = mock('mock', :foo => true)
15
+ m.should_receive(:foo).with('first')
16
+ m.foo('second')
17
+ m.foo('third')
18
+ lambda do
19
+ m.rspec_verify
20
+ end.should raise_error(%q|Mock 'mock' expected :foo with ("first") but received it with (["second"], ["third"])|)
21
+ m.rspec_reset
22
+ end
12
23
  end
24
+
13
25
  end
14
26
  end
@@ -5,7 +5,7 @@ describe "The bin/spec script" do
5
5
  include RubyForker
6
6
 
7
7
  it "should have no warnings" do
8
- pending "Hangs on JRuby" if PLATFORM =~ /java/
8
+ pending "Hangs on JRuby" if RUBY_PLATFORM =~ /java/
9
9
  spec_path = "#{File.dirname(__FILE__)}/../../../bin/spec"
10
10
 
11
11
  output = ruby "-w #{spec_path} --help 2>&1"
@@ -13,7 +13,7 @@ describe "The bin/spec script" do
13
13
  end
14
14
 
15
15
  it "should show the help w/ no args" do
16
- pending "Hangs on JRuby" if PLATFORM =~ /java/
16
+ pending "Hangs on JRuby" if RUBY_PLATFORM =~ /java/
17
17
  spec_path = "#{File.dirname(__FILE__)}/../../../bin/spec"
18
18
 
19
19
  output = ruby "-w #{spec_path} 2>&1"
@@ -7,27 +7,27 @@ module Spec
7
7
  with_sandboxed_config do
8
8
  describe "#mock_with" do
9
9
  it "should default mock framework to rspec" do
10
- config.mock_framework.should =~ /\/adapters\/mock_frameworks\/rspec$/
10
+ config.mock_framework.should =~ /\/spec\/adapters\/mock_frameworks\/rspec$/
11
11
  end
12
12
 
13
13
  it "should set rspec mocking explicitly" do
14
14
  config.mock_with(:rspec)
15
- config.mock_framework.should =~ /\/adapters\/mock_frameworks\/rspec$/
15
+ config.mock_framework.should =~ /\/spec\/adapters\/mock_frameworks\/rspec$/
16
16
  end
17
17
 
18
18
  it "should set mocha" do
19
19
  config.mock_with(:mocha)
20
- config.mock_framework.should =~ /\/adapters\/mock_frameworks\/mocha$/
20
+ config.mock_framework.should =~ /\/spec\/adapters\/mock_frameworks\/mocha$/
21
21
  end
22
22
 
23
23
  it "should set flexmock" do
24
24
  config.mock_with(:flexmock)
25
- config.mock_framework.should =~ /\/adapters\/mock_frameworks\/flexmock$/
25
+ config.mock_framework.should =~ /\/spec\/adapters\/mock_frameworks\/flexmock$/
26
26
  end
27
27
 
28
28
  it "should set rr" do
29
29
  config.mock_with(:rr)
30
- config.mock_framework.should =~ /\/adapters\/mock_frameworks\/rr$/
30
+ config.mock_framework.should =~ /\/spec\/adapters\/mock_frameworks\/rr$/
31
31
  end
32
32
 
33
33
  it "should set an arbitrary adapter module" do
@@ -40,7 +40,7 @@ module Spec
40
40
  describe "#include" do
41
41
 
42
42
  before(:each) do
43
- @example_group_class = Class.new(ExampleGroup) {}
43
+ @example_group_class = Class.new(::Spec::Example::ExampleGroupDouble) {}
44
44
  Spec::Example::ExampleGroupFactory.register(:foobar, @example_group_class)
45
45
  end
46
46
 
@@ -58,7 +58,7 @@ module Spec
58
58
 
59
59
  it "should not include modules in a type they are not intended for" do
60
60
  mod = Module.new
61
- @other_example_group_class = Class.new(ExampleGroup)
61
+ @other_example_group_class = Class.new(::Spec::Example::ExampleGroupDouble)
62
62
  Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class)
63
63
 
64
64
  config.include mod, :type => :foobar
@@ -68,7 +68,7 @@ module Spec
68
68
 
69
69
  it "accepts an Array of types" do
70
70
  mod = Module.new
71
- @other_example_group_class = Class.new(ExampleGroup)
71
+ @other_example_group_class = Class.new(::Spec::Example::ExampleGroupDouble)
72
72
  Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class)
73
73
 
74
74
  config.include mod, :type => [:foobar, :baz]
@@ -82,7 +82,7 @@ module Spec
82
82
  describe "#extend" do
83
83
 
84
84
  before(:each) do
85
- @example_group_class = Class.new(ExampleGroup) {}
85
+ @example_group_class = Class.new(::Spec::Example::ExampleGroupDouble) {}
86
86
  Spec::Example::ExampleGroupFactory.register(:foobar, @example_group_class)
87
87
  end
88
88
 
@@ -99,7 +99,7 @@ module Spec
99
99
  end
100
100
 
101
101
  it "should not extend non-specified groups" do
102
- @other_example_group_class = Class.new(ExampleGroup)
102
+ @other_example_group_class = Class.new(::Spec::Example::ExampleGroupDouble)
103
103
  Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class)
104
104
 
105
105
  mod = Module.new
@@ -114,9 +114,9 @@ module Spec
114
114
  describe "ordering methods: " do
115
115
 
116
116
  before(:each) do
117
- @special_example_group = Class.new(ExampleGroup).describe("special_example_group")
117
+ @special_example_group = Class.new(::Spec::Example::ExampleGroupDouble).describe("special_example_group")
118
118
  @special_child_example_group = Class.new(@special_example_group).describe("special_child_example_group")
119
- @nonspecial_example_group = Class.new(ExampleGroup).describe("nonspecial_example_group")
119
+ @nonspecial_example_group = Class.new(::Spec::Example::ExampleGroupDouble).describe("nonspecial_example_group")
120
120
  Spec::Example::ExampleGroupFactory.register(:special, @special_example_group)
121
121
  Spec::Example::ExampleGroupFactory.register(:special_child, @special_child_example_group)
122
122
  Spec::Example::ExampleGroupFactory.register(:non_special, @nonspecial_example_group)
@@ -2,96 +2,94 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  module Spec
4
4
  module Runner
5
- describe DrbCommandLine, "without running local server" do
6
- unless jruby?
7
- it "should print error when there is no running local server" do
8
- err = StringIO.new
9
- out = StringIO.new
10
- DrbCommandLine.run(OptionParser.parse(['--version'], err, out))
5
+ unless jruby?
6
+ describe DrbCommandLine do
11
7
 
12
- err.rewind
13
- err.read.should =~ /No server is running/
14
- end
15
- end
16
- end
8
+ context "without server running" do
9
+ it "should print error when there is no running local server" do
10
+ err = out = StringIO.new
11
+ DrbCommandLine.run(OptionParser.parse(['--version'], err, out))
17
12
 
18
- describe "with local server" do
13
+ err.rewind
14
+ err.read.should =~ /No server is running/
15
+ end
16
+ end
19
17
 
20
- class ::CommandLineForSpec
21
- def self.run(argv, stderr, stdout)
22
- orig_options = Spec::Runner.options
23
- tmp_options = OptionParser.parse(argv, stderr, stdout)
24
- Spec::Runner.use tmp_options
25
- Spec::Runner::CommandLine.run(tmp_options)
26
- ensure
27
- Spec::Runner.use orig_options
28
- end
29
- end
30
-
31
- unless jruby?
32
- before(:all) do
33
- DRb.start_service("druby://127.0.0.1:8989", ::CommandLineForSpec)
34
- @@drb_example_file_counter = 0
35
- end
18
+ context "with server running" do
19
+ class ::CommandLineForDrbSpec
20
+ def self.run(argv, stderr, stdout)
21
+ orig_options = Spec::Runner.options
22
+ tmp_options = Spec::Runner::OptionParser.parse(argv, stderr, stdout)
23
+ Spec::Runner.use tmp_options
24
+ Spec::Runner::CommandLine.run(tmp_options)
25
+ ensure
26
+ Spec::Runner.use orig_options
27
+ end
28
+ end
36
29
 
37
- before(:each) do
38
- create_dummy_spec_file
39
- @@drb_example_file_counter = @@drb_example_file_counter + 1
40
- end
30
+ before(:all) do
31
+ DRb.start_service("druby://127.0.0.1:8989", ::CommandLineForDrbSpec)
32
+ @@drb_example_file_counter = 0
33
+ end
41
34
 
42
- after(:each) do
43
- File.delete(@dummy_spec_filename)
44
- end
35
+ before(:each) do
36
+ create_dummy_spec_file
37
+ @@drb_example_file_counter = @@drb_example_file_counter + 1
38
+ end
45
39
 
46
- after(:all) do
47
- DRb.stop_service
48
- end
40
+ after(:each) do
41
+ File.delete(@dummy_spec_filename)
42
+ end
49
43
 
50
- it "should run against local server" do
51
- out = run_spec_via_druby(['--version'])
52
- out.should =~ /rspec \d+\.\d+\.\d+.*/n
53
- end
44
+ after(:all) do
45
+ DRb.stop_service
46
+ end
54
47
 
55
- it "should output green colorized text when running with --colour option" do
56
- out = run_spec_via_druby(["--colour", @dummy_spec_filename])
57
- out.should =~ /\e\[32m/n
58
- end
48
+ it "should run against local server" do
49
+ out = run_spec_via_druby(['--version'])
50
+ out.should =~ /rspec \d+\.\d+\.\d+.*/n
51
+ end
59
52
 
60
- it "should output red colorized text when running with -c option" do
61
- out = run_spec_via_druby(["-c", @dummy_spec_filename])
62
- out.should =~ /\e\[31m/n
63
- end
53
+ it "should output green colorized text when running with --colour option" do
54
+ out = run_spec_via_druby(["--colour", @dummy_spec_filename])
55
+ out.should =~ /\e\[32m/n
56
+ end
64
57
 
65
- def create_dummy_spec_file
66
- @dummy_spec_filename = File.expand_path(File.dirname(__FILE__)) + "/_dummy_spec#{@@drb_example_file_counter}.rb"
67
- File.open(@dummy_spec_filename, 'w') do |f|
68
- f.write %{
69
- describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do
70
- it "should be output with green bar" do
71
- true.should be_true
72
- end
58
+ it "should output red colorized text when running with -c option" do
59
+ out = run_spec_via_druby(["-c", @dummy_spec_filename])
60
+ out.should =~ /\e\[31m/n
61
+ end
62
+
63
+ def create_dummy_spec_file
64
+ @dummy_spec_filename = File.expand_path(File.dirname(__FILE__)) + "/_dummy_spec#{@@drb_example_file_counter}.rb"
65
+ File.open(@dummy_spec_filename, 'w') do |f|
66
+ f.write %{
67
+ describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do
68
+ it "should be output with green bar" do
69
+ true.should be_true
70
+ end
73
71
 
74
- it "should be output with red bar" do
75
- violated("I want to see a red bar!")
72
+ it "should be output with red bar" do
73
+ violated("I want to see a red bar!")
74
+ end
76
75
  end
77
- end
78
- }
76
+ }
77
+ end
79
78
  end
80
- end
81
79
 
82
- def run_spec_via_druby(argv)
83
- err, out = StringIO.new, StringIO.new
84
- out.instance_eval do
85
- def tty?; true end
80
+ def run_spec_via_druby(argv)
81
+ err, out = StringIO.new, StringIO.new
82
+ out.instance_eval do
83
+ def tty?; true end
84
+ end
85
+ options = ::Spec::Runner::Options.new(err, out)
86
+ options.argv = argv
87
+ Spec::Runner::DrbCommandLine.run(options)
88
+ out.rewind; out.read
86
89
  end
87
- options = ::Spec::Runner::Options.new(err, out)
88
- options.argv = argv
89
- Spec::Runner::DrbCommandLine.run(options)
90
- out.rewind; out.read
91
90
  end
91
+
92
92
  end
93
-
94
93
  end
95
-
96
94
  end
97
95
  end
@@ -1,6 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
  require 'spec/runner/formatter/base_text_formatter'
3
- require 'fileutils'
4
3
 
5
4
  module Spec
6
5
  module Runner
@@ -16,7 +15,89 @@ module Spec
16
15
  File.stub!(:open)
17
16
  BaseTextFormatter.new({},"#{@sandbox}/temp.rb")
18
17
  end
18
+
19
+ context "(deprecations)" do
20
+ before(:each) do
21
+ Kernel.stub!(:warn)
22
+ @io = StringIO.new
23
+ @options = mock('options')
24
+ @options.stub!(:dry_run).and_return(false)
25
+ @options.stub!(:colour).and_return(false)
26
+ @options.stub!(:autospec).and_return(false)
27
+ @formatter = Class.new(BaseTextFormatter) do
28
+ def method_that_class_magenta(message)
29
+ magenta(message)
30
+ end
31
+ def method_that_class_colourise(message, failure)
32
+ colourise(message, failure)
33
+ end
34
+ end.new(@options, @io)
35
+ @failure = stub('failure', :pending_fixed? => false)
36
+ end
37
+
38
+ context "#colourise" do
39
+ it "warns when subclasses call colourise" do
40
+ Kernel.should_receive(:warn).with(/DEPRECATED/)
41
+ @formatter.method_that_class_colourise('this message', @failure)
42
+ end
43
+
44
+ it "delegates to colorize_failure" do
45
+ @formatter.should_receive(:colorize_failure).with('this message', @failure)
46
+ @formatter.colourise('this message', @failure)
47
+ end
48
+ end
49
+
50
+ context "#magenta" do
51
+ it "warns when subclasses call magenta" do
52
+ Kernel.should_receive(:warn).with(/DEPRECATED/)
53
+ @formatter.method_that_class_magenta('this message')
54
+ end
19
55
 
56
+ it "delegates to red" do
57
+ @formatter.should_receive(:red).with('this message')
58
+ @formatter.method_that_class_magenta('this message')
59
+ end
60
+ end
61
+
62
+ end
63
+
64
+ describe "#colour (protected)" do
65
+ before(:each) do
66
+ @original_RSPEC_COLOR = ENV['RSPEC_COLOR']
67
+ end
68
+
69
+ it "colorizes when colour? and output_to_tty? return true" do
70
+ out = StringIO.new
71
+ options = stub('options', :colour => true, :autospec => false)
72
+ formatter = BaseTextFormatter.new(options,out)
73
+ formatter.stub!(:output_to_tty?).and_return(true)
74
+ formatter.__send__(:colour, 'foo', "\e[32m").should == "\e[32mfoo\e[0m"
75
+ end
76
+
77
+ it "colorizes when ENV['RSPEC_COLOR'] is set even if colour? and output_to_tty? return false" do
78
+ out = StringIO.new
79
+ options = stub('options', :colour => false)
80
+ formatter = BaseTextFormatter.new(options,out)
81
+ formatter.stub!(:output_to_tty?).and_return(false)
82
+
83
+ ENV['RSPEC_COLOR'] = 'true'
84
+
85
+ formatter.__send__(:colour, 'foo', "\e[32m").should == "\e[32mfoo\e[0m"
86
+ end
87
+
88
+ it "colorizes when autospec? is true even if colour? and output_to_tty? return false" do
89
+ out = StringIO.new
90
+ options = stub('options', :colour => true, :autospec => true)
91
+ formatter = BaseTextFormatter.new(options,out)
92
+ formatter.stub!(:output_to_tty?).and_return(false)
93
+
94
+ formatter.__send__(:colour, 'foo', "\e[32m").should == "\e[32mfoo\e[0m"
95
+ end
96
+
97
+ after(:each) do
98
+ ENV['RSPEC_COLOR'] = @original_RSPEC_COLOR
99
+ end
100
+ end
20
101
  end
21
102
  end
22
103
  end