rspec 1.2.9 → 1.3.1
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.
- data/History.rdoc +51 -1
- data/License.txt +1 -1
- data/Manifest.txt +11 -4
- data/README.rdoc +10 -24
- data/Rakefile +17 -13
- data/Upgrade.rdoc +63 -2
- data/examples/passing/shared_example_group_example.rb +0 -36
- data/examples/passing/simple_matcher_example.rb +3 -3
- data/features/formatters/nested_formatter.feature +32 -0
- data/features/interop/cucumber_stubs_dont_leak.feature +11 -0
- data/features/interop/test_but_not_test_unit.feature +1 -1
- data/features/interop/test_case_with_should_methods.feature +1 -1
- data/features/matchers/define_matcher_with_fluent_interface.feature +21 -0
- data/features/matchers/define_wrapped_matcher.feature +28 -1
- data/features/matchers/match_unless_raises.feature +60 -0
- data/features/matchers/match_unless_raises_unexpected_error.feature +39 -0
- data/features/mocks/block_local_expectations.feature +62 -0
- data/features/step_definitions/running_rspec_steps.rb +9 -0
- data/features/step_definitions/stubbing_steps.rb +16 -0
- data/features/support/env.rb +1 -0
- data/features/support/matchers/smart_match.rb +23 -4
- data/geminstaller.yml +29 -0
- data/lib/autotest/rspec.rb +14 -7
- data/lib/spec/deprecation.rb +2 -1
- data/lib/spec/dsl/main.rb +2 -1
- data/lib/spec/example/example_group_methods.rb +6 -1
- data/lib/spec/example/example_methods.rb +4 -0
- data/lib/spec/example/subject.rb +9 -3
- data/lib/spec/interop/test/unit/testsuite_adapter.rb +2 -0
- data/lib/spec/interop/test.rb +1 -1
- data/lib/spec/matchers/be.rb +167 -128
- data/lib/spec/matchers/has.rb +3 -3
- data/lib/spec/matchers/have.rb +1 -0
- data/lib/spec/matchers/matcher.rb +55 -10
- data/lib/spec/matchers/method_missing.rb +2 -2
- data/lib/spec/matchers/operator_matcher.rb +6 -1
- data/lib/spec/matchers/pretty.rb +2 -2
- data/lib/spec/matchers/raise_exception.rb +131 -0
- data/lib/spec/matchers/simple_matcher.rb +2 -1
- data/lib/spec/matchers/throw_symbol.rb +18 -22
- data/lib/spec/matchers.rb +21 -2
- data/lib/spec/mocks/message_expectation.rb +63 -48
- data/lib/spec/mocks/methods.rb +13 -8
- data/lib/spec/mocks/proxy.rb +45 -22
- data/lib/spec/runner/backtrace_tweaker.rb +3 -2
- data/lib/spec/runner/configuration.rb +8 -0
- data/lib/spec/runner/differs/default.rb +1 -1
- data/lib/spec/runner/drb_command_line.rb +8 -2
- data/lib/spec/runner/example_group_runner.rb +1 -2
- data/lib/spec/runner/formatter/nested_text_formatter.rb +6 -3
- data/lib/spec/runner/option_parser.rb +2 -0
- data/lib/spec/runner/options.rb +8 -2
- data/lib/spec/stubs/cucumber.rb +2 -2
- data/lib/spec/version.rb +2 -2
- data/spec/autotest/autotest_helper.rb +1 -1
- data/spec/autotest/discover_spec.rb +2 -2
- data/spec/autotest/failed_results_re_spec.rb +2 -2
- data/spec/autotest/rspec_spec.rb +21 -6
- data/spec/spec/dsl/main_spec.rb +10 -2
- data/spec/spec/example/example_group_methods_spec.rb +21 -1
- data/spec/spec/example/example_group_proxy_spec.rb +1 -1
- data/spec/spec/example/example_group_spec.rb +1 -12
- data/spec/spec/example/example_matcher_spec.rb +3 -4
- data/spec/spec/example/subject_spec.rb +7 -0
- data/spec/spec/expectations/wrap_expectation_spec.rb +2 -1
- data/spec/spec/interop/test/unit/spec_spec.rb +7 -7
- data/spec/spec/interop/test/unit/testcase_spec.rb +7 -7
- data/spec/spec/interop/test/unit/testsuite_adapter_spec.rb +1 -1
- data/spec/spec/matchers/be_spec.rb +159 -10
- data/spec/spec/matchers/has_spec.rb +109 -0
- data/spec/spec/matchers/have_spec.rb +278 -293
- data/spec/spec/matchers/match_array_spec.rb +8 -1
- data/spec/spec/matchers/matcher_spec.rb +70 -9
- data/spec/spec/matchers/raise_exception_spec.rb +345 -0
- data/spec/spec/matchers/simple_matcher_spec.rb +51 -44
- data/spec/spec/matchers/throw_symbol_spec.rb +83 -58
- data/spec/spec/mocks/and_yield_spec.rb +117 -0
- data/spec/spec/mocks/bug_report_496_spec.rb +2 -4
- data/spec/spec/mocks/mock_spec.rb +2 -2
- data/spec/spec/runner/command_line_spec.rb +26 -5
- data/spec/spec/runner/drb_command_line_spec.rb +39 -0
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +35 -11
- data/spec/spec/runner/option_parser_spec.rb +12 -6
- data/spec/spec/runner/options_spec.rb +7 -0
- data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +23 -5
- data/spec/spec_helper.rb +2 -1
- metadata +107 -38
- data/lib/spec/matchers/raise_error.rb +0 -129
- data/spec/spec/matchers/matcher_methods_spec.rb +0 -63
- data/spec/spec/matchers/raise_error_spec.rb +0 -333
- /data/lib/spec/{matchers/extensions → extensions}/instance_exec.rb +0 -0
metadata
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
4
|
+
hash: 25
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 1
|
|
8
|
+
- 3
|
|
9
|
+
- 1
|
|
10
|
+
version: 1.3.1
|
|
5
11
|
platform: ruby
|
|
6
12
|
authors:
|
|
7
13
|
- RSpec Development Team
|
|
@@ -9,69 +15,119 @@ autorequire:
|
|
|
9
15
|
bindir: bin
|
|
10
16
|
cert_chain: []
|
|
11
17
|
|
|
12
|
-
date:
|
|
18
|
+
date: 2010-10-09 00:00:00 -05:00
|
|
13
19
|
default_executable:
|
|
14
20
|
dependencies:
|
|
15
21
|
- !ruby/object:Gem::Dependency
|
|
16
|
-
name:
|
|
22
|
+
name: rubyforge
|
|
23
|
+
prerelease: false
|
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 7
|
|
30
|
+
segments:
|
|
31
|
+
- 2
|
|
32
|
+
- 0
|
|
33
|
+
- 4
|
|
34
|
+
version: 2.0.4
|
|
17
35
|
type: :development
|
|
18
|
-
|
|
19
|
-
|
|
36
|
+
version_requirements: *id001
|
|
37
|
+
- !ruby/object:Gem::Dependency
|
|
38
|
+
name: cucumber
|
|
39
|
+
prerelease: false
|
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
20
42
|
requirements:
|
|
21
43
|
- - ">="
|
|
22
44
|
- !ruby/object:Gem::Version
|
|
45
|
+
hash: 13
|
|
46
|
+
segments:
|
|
47
|
+
- 0
|
|
48
|
+
- 3
|
|
23
49
|
version: "0.3"
|
|
24
|
-
version:
|
|
25
|
-
- !ruby/object:Gem::Dependency
|
|
26
|
-
name: bmabey-fakefs
|
|
27
50
|
type: :development
|
|
28
|
-
|
|
29
|
-
|
|
51
|
+
version_requirements: *id002
|
|
52
|
+
- !ruby/object:Gem::Dependency
|
|
53
|
+
name: fakefs
|
|
54
|
+
prerelease: false
|
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
56
|
+
none: false
|
|
30
57
|
requirements:
|
|
31
58
|
- - ">="
|
|
32
59
|
- !ruby/object:Gem::Version
|
|
33
|
-
|
|
34
|
-
|
|
60
|
+
hash: 21
|
|
61
|
+
segments:
|
|
62
|
+
- 0
|
|
63
|
+
- 2
|
|
64
|
+
- 1
|
|
65
|
+
version: 0.2.1
|
|
66
|
+
type: :development
|
|
67
|
+
version_requirements: *id003
|
|
35
68
|
- !ruby/object:Gem::Dependency
|
|
36
69
|
name: syntax
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
70
|
+
prerelease: false
|
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
72
|
+
none: false
|
|
40
73
|
requirements:
|
|
41
74
|
- - ">="
|
|
42
75
|
- !ruby/object:Gem::Version
|
|
76
|
+
hash: 15
|
|
77
|
+
segments:
|
|
78
|
+
- 1
|
|
79
|
+
- 0
|
|
43
80
|
version: "1.0"
|
|
44
|
-
|
|
81
|
+
type: :development
|
|
82
|
+
version_requirements: *id004
|
|
45
83
|
- !ruby/object:Gem::Dependency
|
|
46
84
|
name: diff-lcs
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
85
|
+
prerelease: false
|
|
86
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
87
|
+
none: false
|
|
50
88
|
requirements:
|
|
51
89
|
- - ">="
|
|
52
90
|
- !ruby/object:Gem::Version
|
|
91
|
+
hash: 23
|
|
92
|
+
segments:
|
|
93
|
+
- 1
|
|
94
|
+
- 1
|
|
95
|
+
- 2
|
|
53
96
|
version: 1.1.2
|
|
54
|
-
|
|
97
|
+
type: :development
|
|
98
|
+
version_requirements: *id005
|
|
55
99
|
- !ruby/object:Gem::Dependency
|
|
56
100
|
name: heckle
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
101
|
+
prerelease: false
|
|
102
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
|
103
|
+
none: false
|
|
60
104
|
requirements:
|
|
61
105
|
- - ">="
|
|
62
106
|
- !ruby/object:Gem::Version
|
|
107
|
+
hash: 1
|
|
108
|
+
segments:
|
|
109
|
+
- 1
|
|
110
|
+
- 4
|
|
111
|
+
- 3
|
|
63
112
|
version: 1.4.3
|
|
64
|
-
|
|
113
|
+
type: :development
|
|
114
|
+
version_requirements: *id006
|
|
65
115
|
- !ruby/object:Gem::Dependency
|
|
66
116
|
name: hoe
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
117
|
+
prerelease: false
|
|
118
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
|
119
|
+
none: false
|
|
70
120
|
requirements:
|
|
71
121
|
- - ">="
|
|
72
122
|
- !ruby/object:Gem::Version
|
|
73
|
-
|
|
74
|
-
|
|
123
|
+
hash: 19
|
|
124
|
+
segments:
|
|
125
|
+
- 2
|
|
126
|
+
- 6
|
|
127
|
+
- 2
|
|
128
|
+
version: 2.6.2
|
|
129
|
+
type: :development
|
|
130
|
+
version_requirements: *id007
|
|
75
131
|
description: Behaviour Driven Development for Ruby.
|
|
76
132
|
email:
|
|
77
133
|
- rspec-devel@rubyforge.org
|
|
@@ -155,6 +211,8 @@ files:
|
|
|
155
211
|
- features/expectations/expect_error.feature
|
|
156
212
|
- features/extensions/custom_example_group.feature
|
|
157
213
|
- features/formatters/custom_formatter.feature
|
|
214
|
+
- features/formatters/nested_formatter.feature
|
|
215
|
+
- features/interop/cucumber_stubs_dont_leak.feature
|
|
158
216
|
- features/interop/examples_and_tests_together.feature
|
|
159
217
|
- features/interop/rspec_output.feature
|
|
160
218
|
- features/interop/test_but_not_test_unit.feature
|
|
@@ -166,19 +224,24 @@ files:
|
|
|
166
224
|
- features/matchers/define_matcher_outside_rspec.feature
|
|
167
225
|
- features/matchers/define_matcher_with_fluent_interface.feature
|
|
168
226
|
- features/matchers/define_wrapped_matcher.feature
|
|
227
|
+
- features/matchers/match_unless_raises.feature
|
|
228
|
+
- features/matchers/match_unless_raises_unexpected_error.feature
|
|
169
229
|
- features/mock_framework_integration/use_flexmock.feature
|
|
170
230
|
- features/mock_framework_integration/use_mocha.feature
|
|
171
231
|
- features/mock_framework_integration/use_rr.feature
|
|
232
|
+
- features/mocks/block_local_expectations.feature
|
|
172
233
|
- features/mocks/mix_stubs_and_mocks.feature
|
|
173
234
|
- features/mocks/stub_implementation.feature
|
|
174
235
|
- features/pending/pending_examples.feature
|
|
175
236
|
- features/runner/specify_line_number.feature
|
|
176
237
|
- features/spec_helper/spec_helper.feature
|
|
177
238
|
- features/step_definitions/running_rspec_steps.rb
|
|
239
|
+
- features/step_definitions/stubbing_steps.rb
|
|
178
240
|
- features/subject/explicit_subject.feature
|
|
179
241
|
- features/subject/implicit_subject.feature
|
|
180
242
|
- features/support/env.rb
|
|
181
243
|
- features/support/matchers/smart_match.rb
|
|
244
|
+
- geminstaller.yml
|
|
182
245
|
- init.rb
|
|
183
246
|
- lib/autotest/discover.rb
|
|
184
247
|
- lib/autotest/rspec.rb
|
|
@@ -214,6 +277,7 @@ files:
|
|
|
214
277
|
- lib/spec/expectations/extensions/kernel.rb
|
|
215
278
|
- lib/spec/expectations/fail_with.rb
|
|
216
279
|
- lib/spec/expectations/handler.rb
|
|
280
|
+
- lib/spec/extensions/instance_exec.rb
|
|
217
281
|
- lib/spec/interop/test.rb
|
|
218
282
|
- lib/spec/interop/test/unit/autorunner.rb
|
|
219
283
|
- lib/spec/interop/test/unit/testcase.rb
|
|
@@ -232,7 +296,6 @@ files:
|
|
|
232
296
|
- lib/spec/matchers/equal.rb
|
|
233
297
|
- lib/spec/matchers/errors.rb
|
|
234
298
|
- lib/spec/matchers/exist.rb
|
|
235
|
-
- lib/spec/matchers/extensions/instance_exec.rb
|
|
236
299
|
- lib/spec/matchers/generated_descriptions.rb
|
|
237
300
|
- lib/spec/matchers/has.rb
|
|
238
301
|
- lib/spec/matchers/have.rb
|
|
@@ -243,7 +306,7 @@ files:
|
|
|
243
306
|
- lib/spec/matchers/method_missing.rb
|
|
244
307
|
- lib/spec/matchers/operator_matcher.rb
|
|
245
308
|
- lib/spec/matchers/pretty.rb
|
|
246
|
-
- lib/spec/matchers/
|
|
309
|
+
- lib/spec/matchers/raise_exception.rb
|
|
247
310
|
- lib/spec/matchers/respond_to.rb
|
|
248
311
|
- lib/spec/matchers/satisfy.rb
|
|
249
312
|
- lib/spec/matchers/simple_matcher.rb
|
|
@@ -362,15 +425,15 @@ files:
|
|
|
362
425
|
- spec/spec/matchers/include_spec.rb
|
|
363
426
|
- spec/spec/matchers/match_array_spec.rb
|
|
364
427
|
- spec/spec/matchers/match_spec.rb
|
|
365
|
-
- spec/spec/matchers/matcher_methods_spec.rb
|
|
366
428
|
- spec/spec/matchers/matcher_spec.rb
|
|
367
429
|
- spec/spec/matchers/matchers_spec.rb
|
|
368
430
|
- spec/spec/matchers/operator_matcher_spec.rb
|
|
369
|
-
- spec/spec/matchers/
|
|
431
|
+
- spec/spec/matchers/raise_exception_spec.rb
|
|
370
432
|
- spec/spec/matchers/respond_to_spec.rb
|
|
371
433
|
- spec/spec/matchers/satisfy_spec.rb
|
|
372
434
|
- spec/spec/matchers/simple_matcher_spec.rb
|
|
373
435
|
- spec/spec/matchers/throw_symbol_spec.rb
|
|
436
|
+
- spec/spec/mocks/and_yield_spec.rb
|
|
374
437
|
- spec/spec/mocks/any_number_of_times_spec.rb
|
|
375
438
|
- spec/spec/mocks/argument_expectation_spec.rb
|
|
376
439
|
- spec/spec/mocks/argument_matchers_spec.rb
|
|
@@ -470,7 +533,7 @@ licenses: []
|
|
|
470
533
|
post_install_message: |
|
|
471
534
|
**************************************************
|
|
472
535
|
|
|
473
|
-
Thank you for installing rspec-1.
|
|
536
|
+
Thank you for installing rspec-1.3.1
|
|
474
537
|
|
|
475
538
|
Please be sure to read History.rdoc and Upgrade.rdoc
|
|
476
539
|
for useful information about this release.
|
|
@@ -483,23 +546,29 @@ rdoc_options:
|
|
|
483
546
|
require_paths:
|
|
484
547
|
- lib
|
|
485
548
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
549
|
+
none: false
|
|
486
550
|
requirements:
|
|
487
551
|
- - ">="
|
|
488
552
|
- !ruby/object:Gem::Version
|
|
553
|
+
hash: 3
|
|
554
|
+
segments:
|
|
555
|
+
- 0
|
|
489
556
|
version: "0"
|
|
490
|
-
version:
|
|
491
557
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
558
|
+
none: false
|
|
492
559
|
requirements:
|
|
493
560
|
- - ">="
|
|
494
561
|
- !ruby/object:Gem::Version
|
|
562
|
+
hash: 3
|
|
563
|
+
segments:
|
|
564
|
+
- 0
|
|
495
565
|
version: "0"
|
|
496
|
-
version:
|
|
497
566
|
requirements: []
|
|
498
567
|
|
|
499
568
|
rubyforge_project: rspec
|
|
500
|
-
rubygems_version: 1.3.
|
|
569
|
+
rubygems_version: 1.3.7
|
|
501
570
|
signing_key:
|
|
502
571
|
specification_version: 3
|
|
503
|
-
summary: rspec 1.
|
|
572
|
+
summary: rspec 1.3.1
|
|
504
573
|
test_files: []
|
|
505
574
|
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
module Spec
|
|
2
|
-
module Matchers
|
|
3
|
-
class RaiseError #:nodoc:
|
|
4
|
-
def initialize(expected_error_or_message=Exception, expected_message=nil, &block)
|
|
5
|
-
@block = block
|
|
6
|
-
@actual_error = nil
|
|
7
|
-
case expected_error_or_message
|
|
8
|
-
when String, Regexp
|
|
9
|
-
@expected_error, @expected_message = Exception, expected_error_or_message
|
|
10
|
-
else
|
|
11
|
-
@expected_error, @expected_message = expected_error_or_message, expected_message
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def matches?(given_proc)
|
|
16
|
-
@raised_expected_error = false
|
|
17
|
-
@with_expected_message = false
|
|
18
|
-
@eval_block = false
|
|
19
|
-
@eval_block_passed = false
|
|
20
|
-
begin
|
|
21
|
-
given_proc.call
|
|
22
|
-
rescue @expected_error => @actual_error
|
|
23
|
-
@raised_expected_error = true
|
|
24
|
-
@with_expected_message = verify_message
|
|
25
|
-
rescue Exception => @actual_error
|
|
26
|
-
# This clause should be empty, but rcov will not report it as covered
|
|
27
|
-
# unless something (anything) is executed within the clause
|
|
28
|
-
rcov_error_report = "http://eigenclass.org/hiki.rb?rcov-0.8.0"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
unless negative_expectation?
|
|
32
|
-
eval_block if @raised_expected_error && @with_expected_message && @block
|
|
33
|
-
end
|
|
34
|
-
ensure
|
|
35
|
-
return (@raised_expected_error & @with_expected_message) ? (@eval_block ? @eval_block_passed : true) : false
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def eval_block
|
|
39
|
-
@eval_block = true
|
|
40
|
-
begin
|
|
41
|
-
@block[@actual_error]
|
|
42
|
-
@eval_block_passed = true
|
|
43
|
-
rescue Exception => err
|
|
44
|
-
@actual_error = err
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def verify_message
|
|
49
|
-
case @expected_message
|
|
50
|
-
when nil
|
|
51
|
-
true
|
|
52
|
-
when Regexp
|
|
53
|
-
@expected_message =~ @actual_error.message
|
|
54
|
-
else
|
|
55
|
-
@expected_message == @actual_error.message
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def failure_message_for_should
|
|
60
|
-
@eval_block ? @actual_error.message : "expected #{expected_error}#{given_error}"
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def failure_message_for_should_not
|
|
64
|
-
"expected no #{expected_error}#{given_error}"
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def description
|
|
68
|
-
"raise #{expected_error}"
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
private
|
|
72
|
-
def expected_error
|
|
73
|
-
case @expected_message
|
|
74
|
-
when nil
|
|
75
|
-
@expected_error
|
|
76
|
-
when Regexp
|
|
77
|
-
"#{@expected_error} with message matching #{@expected_message.inspect}"
|
|
78
|
-
else
|
|
79
|
-
"#{@expected_error} with #{@expected_message.inspect}"
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def given_error
|
|
84
|
-
@actual_error.nil? ? " but nothing was raised" : ", got #{@actual_error.inspect}"
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def negative_expectation?
|
|
88
|
-
# YES - I'm a bad person... help me find a better way - ryand
|
|
89
|
-
caller.first(3).find { |s| s =~ /should_not/ }
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# :call-seq:
|
|
94
|
-
# should raise_error()
|
|
95
|
-
# should raise_error(NamedError)
|
|
96
|
-
# should raise_error(NamedError, String)
|
|
97
|
-
# should raise_error(NamedError, Regexp)
|
|
98
|
-
# should raise_error() { |error| ... }
|
|
99
|
-
# should raise_error(NamedError) { |error| ... }
|
|
100
|
-
# should raise_error(NamedError, String) { |error| ... }
|
|
101
|
-
# should raise_error(NamedError, Regexp) { |error| ... }
|
|
102
|
-
# should_not raise_error()
|
|
103
|
-
# should_not raise_error(NamedError)
|
|
104
|
-
# should_not raise_error(NamedError, String)
|
|
105
|
-
# should_not raise_error(NamedError, Regexp)
|
|
106
|
-
#
|
|
107
|
-
# With no args, matches if any error is raised.
|
|
108
|
-
# With a named error, matches only if that specific error is raised.
|
|
109
|
-
# With a named error and messsage specified as a String, matches only if both match.
|
|
110
|
-
# With a named error and messsage specified as a Regexp, matches only if both match.
|
|
111
|
-
# Pass an optional block to perform extra verifications on the exception matched
|
|
112
|
-
#
|
|
113
|
-
# == Examples
|
|
114
|
-
#
|
|
115
|
-
# lambda { do_something_risky }.should raise_error
|
|
116
|
-
# lambda { do_something_risky }.should raise_error(PoorRiskDecisionError)
|
|
117
|
-
# lambda { do_something_risky }.should raise_error(PoorRiskDecisionError) { |error| error.data.should == 42 }
|
|
118
|
-
# lambda { do_something_risky }.should raise_error(PoorRiskDecisionError, "that was too risky")
|
|
119
|
-
# lambda { do_something_risky }.should raise_error(PoorRiskDecisionError, /oo ri/)
|
|
120
|
-
#
|
|
121
|
-
# lambda { do_something_risky }.should_not raise_error
|
|
122
|
-
# lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError)
|
|
123
|
-
# lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError, "that was too risky")
|
|
124
|
-
# lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError, /oo ri/)
|
|
125
|
-
def raise_error(error=Exception, message=nil, &block)
|
|
126
|
-
Matchers::RaiseError.new(error, message, &block)
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
end
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module Spec
|
|
4
|
-
module Matchers
|
|
5
|
-
context %Q{The Spec::Matchers module gets included in the execution context of every spec.
|
|
6
|
-
This module should provide the following methods, each of which returns a Matcher object.} do
|
|
7
|
-
it "be_true" do
|
|
8
|
-
be_true.should be_an_instance_of(Be)
|
|
9
|
-
end
|
|
10
|
-
it "be_false" do
|
|
11
|
-
be_false.should be_an_instance_of(Be)
|
|
12
|
-
end
|
|
13
|
-
it "be_nil" do
|
|
14
|
-
be_nil.should be_an_instance_of(Be)
|
|
15
|
-
end
|
|
16
|
-
it "be_arbitrary_predicate" do
|
|
17
|
-
be_arbitrary_predicate.should be_an_instance_of(Be)
|
|
18
|
-
end
|
|
19
|
-
it "change" do
|
|
20
|
-
change("target", :message).should be_an_instance_of(Change)
|
|
21
|
-
end
|
|
22
|
-
it "have" do
|
|
23
|
-
have(0).should be_an_instance_of(Have)
|
|
24
|
-
end
|
|
25
|
-
it "have_exactly" do
|
|
26
|
-
have_exactly(0).should be_an_instance_of(Have)
|
|
27
|
-
end
|
|
28
|
-
it "have_at_least" do
|
|
29
|
-
have_at_least(0).should be_an_instance_of(Have)
|
|
30
|
-
end
|
|
31
|
-
it "have_at_most" do
|
|
32
|
-
have_at_most(0).should be_an_instance_of(Have)
|
|
33
|
-
end
|
|
34
|
-
it "raise_error" do
|
|
35
|
-
raise_error.should be_an_instance_of(RaiseError)
|
|
36
|
-
raise_error(NoMethodError).should be_an_instance_of(RaiseError)
|
|
37
|
-
raise_error(NoMethodError, "message").should be_an_instance_of(RaiseError)
|
|
38
|
-
end
|
|
39
|
-
it "satisfy" do
|
|
40
|
-
satisfy{}.should be_an_instance_of(Satisfy)
|
|
41
|
-
end
|
|
42
|
-
it "throw_symbol" do
|
|
43
|
-
throw_symbol.should be_an_instance_of(ThrowSymbol)
|
|
44
|
-
throw_symbol(:sym).should be_an_instance_of(ThrowSymbol)
|
|
45
|
-
end
|
|
46
|
-
it "respond_to" do
|
|
47
|
-
respond_to(:sym).should be_an_instance_of(RespondTo)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
describe "Spec::Matchers#method_missing" do
|
|
52
|
-
it "should convert be_xyz to Be(:be_xyz)" do
|
|
53
|
-
Be.should_receive(:new).with(:be_whatever)
|
|
54
|
-
be_whatever
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it "should convert have_xyz to Has(:have_xyz)" do
|
|
58
|
-
Has.should_receive(:new).with(:have_whatever)
|
|
59
|
-
have_whatever
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|