rspec 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. data/CHANGES +125 -9
  2. data/EXAMPLES.rd +50 -27
  3. data/README +14 -1
  4. data/Rakefile +95 -42
  5. data/UPGRADE +31 -0
  6. data/bin/spec +0 -1
  7. data/bin/spec_translator +6 -0
  8. data/examples/auto_spec_description_example.rb +19 -0
  9. data/examples/{setup_teardown_example.rb → before_and_after_example.rb} +6 -6
  10. data/examples/behave_as_example.rb +45 -0
  11. data/examples/custom_expectation_matchers.rb +13 -12
  12. data/examples/dynamic_spec.rb +2 -2
  13. data/examples/file_accessor_spec.rb +2 -2
  14. data/examples/greeter_spec.rb +3 -3
  15. data/examples/helper_method_example.rb +2 -2
  16. data/examples/io_processor_spec.rb +4 -4
  17. data/examples/legacy_spec.rb +10 -0
  18. data/examples/mocking_example.rb +5 -5
  19. data/examples/multi_threaded_behaviour_runner.rb +25 -0
  20. data/examples/partial_mock_example.rb +4 -4
  21. data/examples/predicate_example.rb +4 -4
  22. data/examples/priority.txt +1 -0
  23. data/examples/shared_behaviours_example.rb +31 -0
  24. data/examples/stack_spec.rb +52 -69
  25. data/examples/stubbing_example.rb +10 -10
  26. data/examples/test_case_adapter_example.rb +26 -0
  27. data/examples/test_case_spec.rb +6 -6
  28. data/lib/spec.rb +9 -4
  29. data/lib/spec/dsl.rb +10 -0
  30. data/lib/spec/dsl/behaviour.rb +189 -0
  31. data/lib/spec/dsl/behaviour_callbacks.rb +43 -0
  32. data/lib/spec/dsl/behaviour_eval.rb +170 -0
  33. data/lib/spec/dsl/behaviour_factory.rb +32 -0
  34. data/lib/spec/dsl/composite_proc_builder.rb +28 -0
  35. data/lib/spec/dsl/configuration.rb +38 -0
  36. data/lib/spec/dsl/description.rb +34 -0
  37. data/lib/spec/dsl/example.rb +114 -0
  38. data/lib/spec/dsl/example_matcher.rb +28 -0
  39. data/lib/spec/{runner/spec_should_raise_handler.rb → dsl/example_should_raise_handler.rb} +4 -4
  40. data/lib/spec/expectations.rb +0 -3
  41. data/lib/spec/expectations/differs/default.rb +0 -1
  42. data/lib/spec/expectations/extensions.rb +0 -1
  43. data/lib/spec/expectations/extensions/object.rb +10 -53
  44. data/lib/spec/expectations/handler.rb +14 -18
  45. data/lib/spec/extensions.rb +1 -0
  46. data/lib/spec/extensions/object.rb +6 -0
  47. data/lib/spec/matchers.rb +19 -21
  48. data/lib/spec/matchers/be.rb +40 -11
  49. data/lib/spec/matchers/be_close.rb +2 -2
  50. data/lib/spec/matchers/operator_matcher.rb +52 -0
  51. data/lib/spec/matchers/respond_to.rb +21 -11
  52. data/lib/spec/mocks.rb +5 -28
  53. data/lib/spec/mocks/argument_constraint_matchers.rb +12 -0
  54. data/lib/spec/mocks/argument_expectation.rb +7 -4
  55. data/lib/spec/mocks/methods.rb +11 -16
  56. data/lib/spec/mocks/mock.rb +6 -3
  57. data/lib/spec/mocks/{mock_handler.rb → proxy.rb} +4 -7
  58. data/lib/spec/mocks/space.rb +28 -0
  59. data/lib/spec/mocks/spec_methods.rb +30 -0
  60. data/lib/spec/rake/spectask.rb +23 -21
  61. data/lib/spec/rake/verify_rcov.rb +1 -0
  62. data/lib/spec/runner.rb +88 -35
  63. data/lib/spec/runner/backtrace_tweaker.rb +2 -1
  64. data/lib/spec/runner/behaviour_runner.rb +102 -0
  65. data/lib/spec/runner/command_line.rb +5 -17
  66. data/lib/spec/runner/drb_command_line.rb +2 -2
  67. data/lib/spec/runner/extensions/kernel.rb +22 -9
  68. data/lib/spec/runner/formatter.rb +4 -0
  69. data/lib/spec/runner/formatter/base_formatter.rb +63 -0
  70. data/lib/spec/runner/formatter/base_text_formatter.rb +22 -52
  71. data/lib/spec/runner/formatter/failing_behaviours_formatter.rb +25 -0
  72. data/lib/spec/runner/formatter/failing_examples_formatter.rb +22 -0
  73. data/lib/spec/runner/formatter/html_formatter.rb +74 -29
  74. data/lib/spec/runner/formatter/progress_bar_formatter.rb +6 -8
  75. data/lib/spec/runner/formatter/rdoc_formatter.rb +6 -6
  76. data/lib/spec/runner/formatter/snippet_extractor.rb +52 -0
  77. data/lib/spec/runner/formatter/specdoc_formatter.rb +6 -6
  78. data/lib/spec/runner/heckle_runner.rb +8 -7
  79. data/lib/spec/runner/option_parser.rb +136 -55
  80. data/lib/spec/runner/options.rb +26 -0
  81. data/lib/spec/runner/reporter.rb +38 -31
  82. data/lib/spec/runner/spec_parser.rb +22 -13
  83. data/lib/spec/test_case_adapter.rb +10 -0
  84. data/lib/spec/translator.rb +103 -86
  85. data/lib/spec/version.rb +7 -15
  86. data/plugins/mock_frameworks/flexmock.rb +27 -0
  87. data/plugins/mock_frameworks/mocha.rb +21 -0
  88. data/plugins/mock_frameworks/rspec.rb +18 -0
  89. data/spec/spec/dsl/behaviour_eval_spec.rb +49 -0
  90. data/spec/spec/dsl/behaviour_factory_spec.rb +30 -0
  91. data/spec/spec/dsl/behaviour_spec.rb +508 -0
  92. data/spec/spec/dsl/composite_proc_builder_spec.rb +57 -0
  93. data/spec/spec/dsl/configuration_spec.rb +43 -0
  94. data/spec/spec/dsl/description_spec.rb +51 -0
  95. data/spec/spec/dsl/example_class_spec.rb +24 -0
  96. data/spec/spec/dsl/example_instance_spec.rb +140 -0
  97. data/spec/spec/dsl/example_should_raise_spec.rb +137 -0
  98. data/spec/spec/dsl/predicate_matcher_spec.rb +21 -0
  99. data/spec/spec/dsl/shared_behaviour_spec.rb +186 -0
  100. data/spec/spec/expectations/differs/default_spec.rb +12 -12
  101. data/spec/spec/expectations/extensions/object_spec.rb +10 -10
  102. data/spec/spec/expectations/fail_with_spec.rb +20 -20
  103. data/spec/spec/matchers/be_close_spec.rb +37 -31
  104. data/spec/spec/matchers/be_spec.rb +50 -41
  105. data/spec/spec/matchers/change_spec.rb +54 -54
  106. data/spec/spec/matchers/description_generation_spec.rb +43 -31
  107. data/spec/spec/matchers/eql_spec.rb +24 -37
  108. data/spec/spec/matchers/equal_spec.rb +24 -37
  109. data/spec/spec/matchers/exist_spec.rb +48 -0
  110. data/spec/spec/matchers/handler_spec.rb +36 -23
  111. data/spec/spec/matchers/has_spec.rb +8 -8
  112. data/spec/spec/matchers/have_spec.rb +38 -38
  113. data/spec/spec/matchers/include_spec.rb +6 -6
  114. data/spec/spec/matchers/match_spec.rb +8 -8
  115. data/spec/spec/matchers/matcher_methods_spec.rb +24 -31
  116. data/spec/spec/matchers/raise_error_spec.rb +34 -34
  117. data/spec/spec/matchers/respond_to_spec.rb +32 -8
  118. data/spec/spec/matchers/satisfy_spec.rb +6 -6
  119. data/spec/spec/matchers/should_===_spec.rb +38 -0
  120. data/spec/spec/matchers/should_==_spec.rb +37 -0
  121. data/spec/spec/matchers/should_=~_spec.rb +36 -0
  122. data/spec/spec/matchers/throw_symbol_spec.rb +47 -55
  123. data/spec/spec/mocks/any_number_of_times_spec.rb +16 -21
  124. data/spec/spec/mocks/argument_expectation_spec.rb +3 -3
  125. data/spec/spec/mocks/at_least_spec.rb +30 -30
  126. data/spec/spec/mocks/at_most_spec.rb +53 -57
  127. data/spec/spec/mocks/bug_report_10260_spec.rb +8 -0
  128. data/spec/spec/mocks/bug_report_7611_spec.rb +3 -3
  129. data/spec/spec/mocks/bug_report_7805_spec.rb +3 -3
  130. data/spec/spec/mocks/bug_report_8165_spec.rb +5 -5
  131. data/spec/spec/mocks/bug_report_8302_spec.rb +5 -5
  132. data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +26 -27
  133. data/spec/spec/mocks/mock_ordering_spec.rb +19 -15
  134. data/spec/spec/mocks/mock_space_spec.rb +54 -0
  135. data/spec/spec/mocks/mock_spec.rb +111 -141
  136. data/spec/spec/mocks/multiple_return_value_spec.rb +48 -48
  137. data/spec/spec/mocks/null_object_mock_spec.rb +10 -10
  138. data/spec/spec/mocks/once_counts_spec.rb +32 -35
  139. data/spec/spec/mocks/options_hash_spec.rb +12 -10
  140. data/spec/spec/mocks/partial_mock_spec.rb +15 -15
  141. data/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +24 -22
  142. data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +19 -19
  143. data/spec/spec/mocks/precise_counts_spec.rb +28 -32
  144. data/spec/spec/mocks/record_messages_spec.rb +10 -10
  145. data/spec/spec/mocks/stub_spec.rb +45 -45
  146. data/spec/spec/mocks/twice_counts_spec.rb +21 -21
  147. data/spec/spec/package/bin_spec_spec.rb +12 -0
  148. data/spec/spec/runner/behaviour_runner_spec.rb +114 -0
  149. data/spec/spec/runner/command_line_spec.rb +8 -8
  150. data/spec/spec/runner/context_matching_spec.rb +14 -15
  151. data/spec/spec/runner/drb_command_line_spec.rb +12 -12
  152. data/spec/spec/runner/execution_context_spec.rb +8 -29
  153. data/spec/spec/runner/extensions/kernel_spec.rb +36 -0
  154. data/spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb +27 -0
  155. data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +28 -0
  156. data/spec/spec/runner/formatter/html_formatter_spec.rb +9 -8
  157. data/spec/spec/runner/formatter/progress_bar_formatter_dry_run_spec.rb +6 -6
  158. data/spec/spec/runner/formatter/progress_bar_formatter_failure_dump_spec.rb +10 -10
  159. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +22 -27
  160. data/spec/spec/runner/formatter/rdoc_formatter_dry_run_spec.rb +6 -5
  161. data/spec/spec/runner/formatter/rdoc_formatter_spec.rb +17 -17
  162. data/spec/spec/runner/formatter/snippet_extractor_spec.rb +11 -0
  163. data/spec/spec/runner/formatter/specdoc_formatter_dry_run_spec.rb +6 -6
  164. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +17 -17
  165. data/spec/spec/runner/heckle_runner_spec.rb +21 -21
  166. data/spec/spec/runner/heckler_spec.rb +5 -5
  167. data/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +12 -12
  168. data/spec/spec/runner/object_ext_spec.rb +3 -3
  169. data/spec/spec/runner/option_parser_spec.rb +171 -102
  170. data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +21 -12
  171. data/spec/spec/runner/reporter_spec.rb +106 -97
  172. data/spec/spec/runner/spec_matcher_spec.rb +46 -51
  173. data/spec/spec/runner/spec_parser_spec.rb +72 -16
  174. data/spec/spec/spec_classes.rb +12 -3
  175. data/spec/spec/translator_spec.rb +165 -36
  176. metadata +66 -76
  177. data/RELEASE-PLAN +0 -117
  178. data/examples/auto_spec_name_generation_example.rb +0 -18
  179. data/lib/spec/callback.rb +0 -11
  180. data/lib/spec/callback/callback_container.rb +0 -60
  181. data/lib/spec/callback/extensions/module.rb +0 -24
  182. data/lib/spec/callback/extensions/object.rb +0 -37
  183. data/lib/spec/deprecated.rb +0 -3
  184. data/lib/spec/expectations/extensions/proc.rb +0 -57
  185. data/lib/spec/expectations/should.rb +0 -5
  186. data/lib/spec/expectations/should/base.rb +0 -64
  187. data/lib/spec/expectations/should/change.rb +0 -69
  188. data/lib/spec/expectations/should/have.rb +0 -128
  189. data/lib/spec/expectations/should/not.rb +0 -74
  190. data/lib/spec/expectations/should/should.rb +0 -81
  191. data/lib/spec/expectations/sugar.rb +0 -47
  192. data/lib/spec/runner/context.rb +0 -154
  193. data/lib/spec/runner/context_eval.rb +0 -142
  194. data/lib/spec/runner/context_runner.rb +0 -55
  195. data/lib/spec/runner/execution_context.rb +0 -17
  196. data/lib/spec/runner/spec_matcher.rb +0 -25
  197. data/lib/spec/runner/specification.rb +0 -114
  198. data/spec/spec/callback/callback_container_spec.rb +0 -27
  199. data/spec/spec/callback/module_spec.rb +0 -37
  200. data/spec/spec/callback/object_spec.rb +0 -90
  201. data/spec/spec/callback/object_with_class_callback_spec.rb +0 -19
  202. data/spec/spec/expectations/should/should_==_spec.rb +0 -19
  203. data/spec/spec/expectations/should/should_=~_spec.rb +0 -13
  204. data/spec/spec/expectations/should/should_be_a_kind_of_spec.rb +0 -21
  205. data/spec/spec/expectations/should/should_be_an_instance_of_spec.rb +0 -30
  206. data/spec/spec/expectations/should/should_be_arbitrary_predicate_spec.rb +0 -81
  207. data/spec/spec/expectations/should/should_be_close_spec.rb +0 -18
  208. data/spec/spec/expectations/should/should_be_comparison_operator_spec.rb +0 -44
  209. data/spec/spec/expectations/should/should_be_false_spec.rb +0 -39
  210. data/spec/spec/expectations/should/should_be_spec.rb +0 -11
  211. data/spec/spec/expectations/should/should_be_true_spec.rb +0 -27
  212. data/spec/spec/expectations/should/should_change_spec.rb +0 -184
  213. data/spec/spec/expectations/should/should_eql_spec.rb +0 -11
  214. data/spec/spec/expectations/should/should_equal_spec.rb +0 -11
  215. data/spec/spec/expectations/should/should_have_at_least_spec.rb +0 -53
  216. data/spec/spec/expectations/should/should_have_at_most_spec.rb +0 -45
  217. data/spec/spec/expectations/should/should_have_key_spec.rb +0 -21
  218. data/spec/spec/expectations/should/should_have_spec.rb +0 -64
  219. data/spec/spec/expectations/should/should_include_spec.rb +0 -59
  220. data/spec/spec/expectations/should/should_match_spec.rb +0 -25
  221. data/spec/spec/expectations/should/should_not_==_spec.rb +0 -15
  222. data/spec/spec/expectations/should/should_not_be_a_kind_of_spec.rb +0 -21
  223. data/spec/spec/expectations/should/should_not_be_an_instance_of_spec.rb +0 -11
  224. data/spec/spec/expectations/should/should_not_be_arbitrary_predicate_spec.rb +0 -68
  225. data/spec/spec/expectations/should/should_not_be_spec.rb +0 -11
  226. data/spec/spec/expectations/should/should_not_change_spec.rb +0 -24
  227. data/spec/spec/expectations/should/should_not_eql_spec.rb +0 -11
  228. data/spec/spec/expectations/should/should_not_equal_spec.rb +0 -11
  229. data/spec/spec/expectations/should/should_not_have_key_spec.rb +0 -15
  230. data/spec/spec/expectations/should/should_not_include_spec.rb +0 -58
  231. data/spec/spec/expectations/should/should_not_match_spec.rb +0 -11
  232. data/spec/spec/expectations/should/should_not_raise_spec.rb +0 -75
  233. data/spec/spec/expectations/should/should_not_respond_to_spec.rb +0 -15
  234. data/spec/spec/expectations/should/should_not_throw_spec.rb +0 -35
  235. data/spec/spec/expectations/should/should_raise_spec.rb +0 -66
  236. data/spec/spec/expectations/should/should_respond_to_spec.rb +0 -15
  237. data/spec/spec/expectations/should/should_satisfy_spec.rb +0 -35
  238. data/spec/spec/expectations/should/should_throw_spec.rb +0 -27
  239. data/spec/spec/runner/context_runner_spec.rb +0 -100
  240. data/spec/spec/runner/context_spec.rb +0 -405
  241. data/spec/spec/runner/kernel_ext_spec.rb +0 -16
  242. data/spec/spec/runner/spec_name_generation_spec.rb +0 -102
  243. data/spec/spec/runner/specification_class_spec.rb +0 -72
  244. data/spec/spec/runner/specification_instance_spec.rb +0 -160
  245. data/spec/spec/runner/specification_should_raise_spec.rb +0 -136
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_not_eql" do
4
- specify "should pass when objects are not equal (by value)" do
5
- "apples".should_not_eql("cadillacs")
6
- end
7
-
8
- specify "should fail when objects are equal (by value)" do
9
- lambda { "apple".should_not_eql("apple") }.should_fail_with "expected \"apple\" not to equal \"apple\" (using .eql?)"
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_not_equal" do
4
- specify "should pass when objects are not the same instance" do
5
- "apple".should_not_equal("apple")
6
- end
7
-
8
- specify "should fail when objects are the same instance" do
9
- lambda { :apple.should_not_equal(:apple) }.should_fail_with "expected :apple not to equal :apple (using .equal?)"
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_not_have_key" do
4
- specify "should pass when key is not present" do
5
- lambda do
6
- {"a" => 1}.should_not_have_key("b")
7
- end.should_not_raise
8
- end
9
-
10
- specify "should fail when key is present" do
11
- lambda do
12
- {"a" => 1}.should_not_have_key("a")
13
- end.should_fail_with('expected #has_key?("a") to return false, got true')
14
- end
15
- end
@@ -1,58 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_not_include" do
4
- setup do
5
- @dummy = "dummy"
6
- @equal_dummy = "dummy"
7
- @another_dummy = "another_dummy"
8
- @nil_var = nil
9
- end
10
-
11
- specify "should fail when array inclusion is present" do
12
- lambda do
13
- [1, 2, 3].should_not_include(2)
14
- end.should_fail
15
- end
16
-
17
- specify "should fail when enumerable inclusion is missing" do
18
- lambda do
19
- IO.constants.should_not_include("SEEK_SET")
20
- end.should_fail
21
- end
22
-
23
- specify "should fail when hash inclusion is present" do
24
- lambda do
25
- {"a" => 1}.should_not_include("a")
26
- end.should_fail
27
- end
28
-
29
- specify "should fail when string inclusion is present" do
30
- lambda do
31
- @dummy.should_not_include("mm")
32
- end.should_fail
33
- end
34
-
35
- specify "should pass when array inclusion is missing" do
36
- lambda do
37
- [1, 2, 3].should_not_include(5)
38
- end.should_pass
39
- end
40
-
41
- specify "should pass when enumerable inclusion is present" do
42
- lambda do
43
- IO.constants.should_not_include("BLAH")
44
- end.should_pass
45
- end
46
-
47
- specify "should pass when hash inclusion is missing" do
48
- lambda do
49
- {"a" => 1}.should_not_include("b")
50
- end.should_pass
51
- end
52
-
53
- specify "should pass when string inclusion is missing" do
54
- lambda do
55
- @dummy.should_not_include("abc")
56
- end.should_pass
57
- end
58
- end
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_not_match" do
4
- specify "should not raise when objects do not match" do
5
- "hi aslak".should_not_match(/steve/)
6
- end
7
-
8
- specify "should raise when objects match" do
9
- lambda { "hi aslak".should_not_match(/aslak/) }.should_fail
10
- end
11
- end
@@ -1,75 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_not_raise" do
4
- specify "should fail when specific exception is raised" do
5
- lambda {
6
- lambda do
7
- "".nonexistent_method
8
- end.should_not_raise(NoMethodError)
9
- }.should_fail_with /expected no NoMethodError, got #<NoMethodError: undefined method/
10
- end
11
-
12
- specify "should fail when exact exception is raised with message" do
13
- lambda do
14
- lambda do
15
- raise(StandardError.new("abc"))
16
- end.should_not_raise(StandardError, "abc")
17
- end.should_fail_with "expected no StandardError with \"abc\", got #<StandardError: abc>"
18
- end
19
-
20
- specify "should fail when exact exception is raised with message matching regexp" do
21
- lambda do
22
- lambda do
23
- raise(StandardError.new("abc"))
24
- end.should_not_raise(StandardError, /^a.c$/)
25
- end.should_fail_with "expected no StandardError with message matching /^a.c$/, got #<StandardError: abc>"
26
- end
27
-
28
- specify "should include actual error in failure message" do
29
- lambda {
30
- lambda {
31
- "".nonexistent_method
32
- }.should_not_raise(Exception)
33
- }.should_fail_with /expected no Exception, got #<NoMethodError: undefined method/
34
- end
35
-
36
- specify "should pass when exact exception is raised with wrong message" do
37
- lambda do
38
- lambda do
39
- raise(StandardError.new("abc"))
40
- end.should_not_raise(StandardError, "xyz")
41
- end.should_pass
42
- end
43
-
44
- specify "should pass when exact exception is raised with message not matching regexp" do
45
- lambda do
46
- lambda do
47
- raise(StandardError.new("abc"))
48
- end.should_not_raise(StandardError, /xyz/)
49
- end.should_pass
50
- end
51
-
52
- specify "should pass when no exception is raised" do
53
- lambda do
54
- lambda do
55
- "".to_s
56
- end.should_not_raise(NoMethodError)
57
- end.should_pass
58
- end
59
-
60
- specify "should pass when other exception is raised" do
61
- lambda do
62
- lambda do
63
- "".nonexistent_method
64
- end.should_not_raise(SyntaxError)
65
- end.should_pass
66
- end
67
-
68
- specify "without exception should pass when no exception is raised" do
69
- lambda do
70
- lambda do
71
- "".to_s
72
- end.should_not_raise
73
- end.should_pass
74
- end
75
- end
@@ -1,15 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_not_respond_to" do
4
- specify "should fail when target responds to" do
5
- lambda do
6
- "".should_not_respond_to(:length)
7
- end.should_fail
8
- end
9
-
10
- specify "should pass when target doesnt respond to" do
11
- lambda do
12
- "".should_not_respond_to(:connect)
13
- end.should_not_raise
14
- end
15
- end
@@ -1,35 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_not_throw" do
4
- specify "should fail when expected symbol is actually thrown" do
5
- lambda do
6
- lambda do
7
- throw(:foo)
8
- end.should_not_throw(:foo)
9
- end.should_fail
10
- end
11
-
12
- specify "should pass when expected symbol is thrown" do
13
- lambda do
14
- lambda do
15
- throw(:bar)
16
- end.should_not_throw(:foo)
17
- end.should_not_raise
18
- end
19
-
20
- specify "should pass when no symbol is thrown" do
21
- lambda do
22
- lambda do
23
- "".to_s
24
- end.should_not_throw(:foo)
25
- end.should_not_raise
26
- end
27
-
28
- specify "should pass when no symbol is thrown and none is specified" do
29
- lambda do
30
- lambda do
31
- "".to_s
32
- end.should_not_throw
33
- end.should_not_raise
34
- end
35
- end
@@ -1,66 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_raise" do
4
- specify "should fail when exact exception is raised with wrong message" do
5
- lambda do
6
- lambda do
7
- raise(StandardError.new("chunky bacon"))
8
- end.should_raise(StandardError, "rotten tomatoes")
9
- end.should_raise(Spec::Expectations::ExpectationNotMetError)
10
- end
11
-
12
- specify "should fail when exact exception is raised with message not matching regexp" do
13
- lambda do
14
- lambda do
15
- raise(StandardError.new("chunky bacon"))
16
- end.should_raise(StandardError, /lean/)
17
- end.should_raise(Spec::Expectations::ExpectationNotMetError)
18
- end
19
-
20
- specify "should fail when no exception is raised" do
21
- lambda do
22
- lambda {}.should_raise(SyntaxError)
23
- end.should_raise(Spec::Expectations::ExpectationNotMetError, "expected SyntaxError but nothing was raised")
24
- end
25
-
26
- specify "should fail when wrong exception is raised" do
27
- lambda do
28
- lambda do
29
- "".nonexistent_method
30
- end.should_raise(SyntaxError)
31
- end.should_raise(Spec::Expectations::ExpectationNotMetError, /expected SyntaxError, got #<NoMethodError: undefined method/)
32
- end
33
-
34
- specify "should pass when exact exception is raised" do
35
- lambda do
36
- lambda do
37
- "".nonexistent_method
38
- end.should_raise(NoMethodError)
39
- end.should_not_raise
40
- end
41
-
42
- specify "should pass when exact exception is raised with message" do
43
- lambda do
44
- lambda do
45
- raise(StandardError.new("this is standard"))
46
- end.should_raise(StandardError, "this is standard")
47
- end.should_not_raise
48
- end
49
-
50
- specify "should pass when exact exception is raised with message matching regexp" do
51
- lambda do
52
- lambda do
53
- raise(StandardError.new("this is standard"))
54
- end.should_raise(StandardError, /standard$/)
55
- end.should_not_raise
56
- end
57
-
58
- specify "should pass when subclass exception is raised" do
59
- lambda do
60
- lambda do
61
- "".nonexistent_method
62
- end.should_raise
63
- end.should_not_raise
64
- end
65
-
66
- end
@@ -1,15 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_respond_to" do
4
- specify "should fail when target doesnt respond to" do
5
- lambda do
6
- "".should_respond_to(:connect)
7
- end.should_fail
8
- end
9
-
10
- specify "should pass when target responds to" do
11
- lambda do
12
- "".should_respond_to(:length)
13
- end.should_not_raise
14
- end
15
- end
@@ -1,35 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_satisfy" do
4
- specify "should not raise exception when block yields true" do
5
- lambda do
6
- 5.should_satisfy do |target|
7
- true
8
- end
9
- end.should_not_raise
10
- end
11
-
12
- specify "should not raise exception when block yields true again" do
13
- lambda do
14
- 5.should_not_satisfy do |target|
15
- false
16
- end
17
- end.should_not_raise
18
- end
19
-
20
- specify "should raise exception when block yields false" do
21
- lambda do
22
- 5.should_satisfy do |target|
23
- false
24
- end
25
- end.should_fail
26
- end
27
-
28
- specify "should raise exception when block yields false again" do
29
- lambda do
30
- 5.should_not_satisfy do |target|
31
- true
32
- end
33
- end.should_fail
34
- end
35
- end
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper.rb'
2
-
3
- context "should_throw" do
4
-
5
- specify "should fail when no symbol is thrown" do
6
- lambda do
7
- lambda {}.should_throw(:foo)
8
- end.should_fail
9
- end
10
-
11
- specify "should fail when wrong symbol is thrown" do
12
- lambda do
13
- lambda do
14
- throw(:bar)
15
- end.should_throw(:foo)
16
- end.should_fail
17
- end
18
-
19
- specify "should pass when proper symbol is thrown" do
20
- lambda do
21
- lambda do
22
- throw(:foo)
23
- end.should_throw(:foo)
24
- end.should_not_raise
25
- end
26
-
27
- end
@@ -1,100 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
-
3
- context "ContextRunner" do
4
- specify "should call run on context" do
5
- context1 = mock("context1", {
6
- :null_object => true
7
- })
8
- context2 = mock("context2", {
9
- :null_object => true
10
- })
11
- context1.should_receive(:run)
12
- context1.should_receive(:number_of_specs).and_return(0)
13
- context2.should_receive(:run)
14
- context2.should_receive(:number_of_specs).and_return(0)
15
- reporter = mock("reporter")
16
- reporter.should_receive(:start).with(0)
17
- reporter.should_receive(:end)
18
- reporter.should_receive(:dump)
19
-
20
- options = OpenStruct.new
21
- options.reporter = reporter
22
- runner = Spec::Runner::ContextRunner.new(options)
23
- runner.add_context(context1)
24
- runner.add_context(context2)
25
- runner.run(false)
26
- end
27
-
28
- specify "should support single spec" do
29
- desired_context = mock("desired context")
30
- desired_context.should_receive(:matches?).at_least(:once).and_return(true)
31
- desired_context.should_receive(:run)
32
- desired_context.should_receive(:run_single_spec)
33
- desired_context.should_receive(:number_of_specs).and_return(1)
34
- other_context = mock("other context")
35
- other_context.should_receive(:matches?).and_return(false)
36
- other_context.should_receive(:run).never
37
- other_context.should_receive(:number_of_specs).never
38
- reporter = mock("reporter")
39
- options = OpenStruct.new
40
- options.reporter = reporter
41
- options.spec_name = "desired context legal spec"
42
-
43
- runner = Spec::Runner::ContextRunner.new(options)
44
- runner.add_context(desired_context)
45
- runner.add_context(other_context)
46
- reporter.should_receive(:start)
47
- reporter.should_receive(:end)
48
- reporter.should_receive(:dump)
49
- runner.run(false)
50
- end
51
-
52
- specify "should dump even if Interrupt exception is occurred" do
53
- context = Spec::Runner::Context.new("context") do
54
- specify "no error" do
55
- end
56
-
57
- specify "should interrupt" do
58
- raise Interrupt
59
- end
60
- end
61
-
62
- reporter = mock("reporter")
63
- reporter.should_receive(:start)
64
- reporter.should_receive(:add_context).with("context")
65
- reporter.should_receive(:spec_started).with("no error")
66
- reporter.should_receive(:spec_started).with("should interrupt")
67
- reporter.should_receive(:spec_finished).twice
68
- reporter.should_receive(:end)
69
- reporter.should_receive(:dump)
70
-
71
- options = OpenStruct.new
72
- options.reporter = reporter
73
- runner = Spec::Runner::ContextRunner.new(options)
74
- runner.add_context(context)
75
- runner.run(false)
76
- end
77
-
78
- specify "should heckle when options have heckle_runner" do
79
- context = mock("context", :null_object => true)
80
- context.should_receive(:number_of_specs).and_return(0)
81
- context.should_receive(:run).and_return(0)
82
-
83
- reporter = mock("reporter")
84
- reporter.should_receive(:start).with(0)
85
- reporter.should_receive(:end)
86
- reporter.should_receive(:dump).and_return(0)
87
-
88
- heckle_runner = mock("heckle_runner")
89
- heckle_runner.should_receive(:heckle_with)
90
-
91
- options = OpenStruct.new
92
- options.reporter = reporter
93
- options.heckle_runner = heckle_runner
94
-
95
- runner = Spec::Runner::ContextRunner.new(options)
96
- runner.add_context(context)
97
- runner.run(false)
98
-
99
- end
100
- end