rspec 1.2.9 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.rdoc +34 -1
- data/License.txt +1 -1
- data/Manifest.txt +11 -4
- data/README.rdoc +2 -3
- data/Rakefile +17 -13
- data/Upgrade.rdoc +63 -2
- data/features/formatters/nested_formatter.feature +32 -0
- data/features/interop/cucumber_stubs_dont_leak.feature +11 -0
- 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 +28 -0
- data/lib/autotest/rspec.rb +14 -7
- data/lib/spec/dsl/main.rb +1 -1
- data/lib/spec/example/example_methods.rb +4 -0
- data/lib/spec/{matchers/extensions → extensions}/instance_exec.rb +0 -0
- data/lib/spec/interop/test.rb +1 -1
- data/lib/spec/matchers.rb +21 -2
- 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/raise_exception.rb +131 -0
- data/lib/spec/matchers/throw_symbol.rb +16 -20
- data/lib/spec/mocks/message_expectation.rb +63 -48
- data/lib/spec/mocks/methods.rb +13 -8
- data/lib/spec/mocks/proxy.rb +43 -22
- 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 +6 -1
- 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/example/example_group_methods_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/matcher_spec.rb +70 -9
- data/spec/spec/matchers/raise_exception_spec.rb +345 -0
- data/spec/spec/matchers/throw_symbol_spec.rb +83 -58
- data/spec/spec/mocks/and_yield_spec.rb +117 -0
- 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
- metadata +17 -10
- 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/History.rdoc
CHANGED
@@ -1,3 +1,36 @@
|
|
1
|
+
=== Version 1.3.0 / 2010-01-11
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* capture ExpectationNotMet error by default in matcher DSL
|
5
|
+
* supports wrapping other expectations
|
6
|
+
* added match_unless_raises to matcher DSL
|
7
|
+
* supports easy wrapping of t/u assertions in matchers
|
8
|
+
* thanks to Chad Fowler and Glenn Vanderburg for the name
|
9
|
+
* add chain to matcher DSL (Joe Ferris - #935)
|
10
|
+
* see rdoc for Spec::Matchers
|
11
|
+
* and_yield provides configurable eval_context
|
12
|
+
* Eric Meyer & David Chelimsky
|
13
|
+
* CTRL-C actually stops execution! (Bryan Helmkamp - #911)
|
14
|
+
* make drb port configurable (Chris Flipse - #875)
|
15
|
+
* changed raise_error to raise_exception (#933)
|
16
|
+
* kept raise_error aliased, so this is completely
|
17
|
+
backwards compatible
|
18
|
+
|
19
|
+
* bug fixes
|
20
|
+
* don't define top-level context() method when running in IRB (#899)
|
21
|
+
* remove Ruby warning for uninitialized ivar (Bryan Helmkamp - #892)
|
22
|
+
* fully qualify reference to Default (Alex Sharp - #895)
|
23
|
+
* use runtime version of Test::Unit::VERSION in incompatibility message
|
24
|
+
(Ryan Bigg - #916)
|
25
|
+
* quote paths in RSpec's own specs so people running in paths with
|
26
|
+
spaces in them can achieve green too (Ryan Bigg - #917)
|
27
|
+
* ensure drb specs run when EADDRNOTAVAIL (Michael Klett - #881)
|
28
|
+
* throw_symbol matcher correctly bubbles errors up (#918)
|
29
|
+
* make Rakefile work without Cucumber installed (#919 - devrandom)
|
30
|
+
* escape . in regexp (#925)
|
31
|
+
* align be_true and be_false with Ruby's conditional semantics (#931)
|
32
|
+
* print duplicate nested descriptions (when appropriate) (#936)
|
33
|
+
|
1
34
|
=== Version 1.2.9 / 2009-10-05
|
2
35
|
|
3
36
|
* enhancements
|
@@ -25,7 +58,7 @@
|
|
25
58
|
* better handling of determining test names in test/unit/interop mode
|
26
59
|
* Joe Ferris
|
27
60
|
* closes #854
|
28
|
-
|
61
|
+
|
29
62
|
* bug fixes
|
30
63
|
|
31
64
|
* Fixed problem with colorized output when writing to a file
|
data/License.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -67,6 +67,8 @@ features/expectations/expect_change.feature
|
|
67
67
|
features/expectations/expect_error.feature
|
68
68
|
features/extensions/custom_example_group.feature
|
69
69
|
features/formatters/custom_formatter.feature
|
70
|
+
features/formatters/nested_formatter.feature
|
71
|
+
features/interop/cucumber_stubs_dont_leak.feature
|
70
72
|
features/interop/examples_and_tests_together.feature
|
71
73
|
features/interop/rspec_output.feature
|
72
74
|
features/interop/test_but_not_test_unit.feature
|
@@ -78,19 +80,24 @@ features/matchers/define_matcher.feature
|
|
78
80
|
features/matchers/define_matcher_outside_rspec.feature
|
79
81
|
features/matchers/define_matcher_with_fluent_interface.feature
|
80
82
|
features/matchers/define_wrapped_matcher.feature
|
83
|
+
features/matchers/match_unless_raises.feature
|
84
|
+
features/matchers/match_unless_raises_unexpected_error.feature
|
81
85
|
features/mock_framework_integration/use_flexmock.feature
|
82
86
|
features/mock_framework_integration/use_mocha.feature
|
83
87
|
features/mock_framework_integration/use_rr.feature
|
88
|
+
features/mocks/block_local_expectations.feature
|
84
89
|
features/mocks/mix_stubs_and_mocks.feature
|
85
90
|
features/mocks/stub_implementation.feature
|
86
91
|
features/pending/pending_examples.feature
|
87
92
|
features/runner/specify_line_number.feature
|
88
93
|
features/spec_helper/spec_helper.feature
|
89
94
|
features/step_definitions/running_rspec_steps.rb
|
95
|
+
features/step_definitions/stubbing_steps.rb
|
90
96
|
features/subject/explicit_subject.feature
|
91
97
|
features/subject/implicit_subject.feature
|
92
98
|
features/support/env.rb
|
93
99
|
features/support/matchers/smart_match.rb
|
100
|
+
geminstaller.yml
|
94
101
|
init.rb
|
95
102
|
lib/autotest/discover.rb
|
96
103
|
lib/autotest/rspec.rb
|
@@ -126,6 +133,7 @@ lib/spec/expectations/extensions.rb
|
|
126
133
|
lib/spec/expectations/extensions/kernel.rb
|
127
134
|
lib/spec/expectations/fail_with.rb
|
128
135
|
lib/spec/expectations/handler.rb
|
136
|
+
lib/spec/extensions/instance_exec.rb
|
129
137
|
lib/spec/interop/test.rb
|
130
138
|
lib/spec/interop/test/unit/autorunner.rb
|
131
139
|
lib/spec/interop/test/unit/testcase.rb
|
@@ -144,7 +152,6 @@ lib/spec/matchers/eql.rb
|
|
144
152
|
lib/spec/matchers/equal.rb
|
145
153
|
lib/spec/matchers/errors.rb
|
146
154
|
lib/spec/matchers/exist.rb
|
147
|
-
lib/spec/matchers/extensions/instance_exec.rb
|
148
155
|
lib/spec/matchers/generated_descriptions.rb
|
149
156
|
lib/spec/matchers/has.rb
|
150
157
|
lib/spec/matchers/have.rb
|
@@ -155,7 +162,7 @@ lib/spec/matchers/matcher.rb
|
|
155
162
|
lib/spec/matchers/method_missing.rb
|
156
163
|
lib/spec/matchers/operator_matcher.rb
|
157
164
|
lib/spec/matchers/pretty.rb
|
158
|
-
lib/spec/matchers/
|
165
|
+
lib/spec/matchers/raise_exception.rb
|
159
166
|
lib/spec/matchers/respond_to.rb
|
160
167
|
lib/spec/matchers/satisfy.rb
|
161
168
|
lib/spec/matchers/simple_matcher.rb
|
@@ -274,15 +281,15 @@ spec/spec/matchers/have_spec.rb
|
|
274
281
|
spec/spec/matchers/include_spec.rb
|
275
282
|
spec/spec/matchers/match_array_spec.rb
|
276
283
|
spec/spec/matchers/match_spec.rb
|
277
|
-
spec/spec/matchers/matcher_methods_spec.rb
|
278
284
|
spec/spec/matchers/matcher_spec.rb
|
279
285
|
spec/spec/matchers/matchers_spec.rb
|
280
286
|
spec/spec/matchers/operator_matcher_spec.rb
|
281
|
-
spec/spec/matchers/
|
287
|
+
spec/spec/matchers/raise_exception_spec.rb
|
282
288
|
spec/spec/matchers/respond_to_spec.rb
|
283
289
|
spec/spec/matchers/satisfy_spec.rb
|
284
290
|
spec/spec/matchers/simple_matcher_spec.rb
|
285
291
|
spec/spec/matchers/throw_symbol_spec.rb
|
292
|
+
spec/spec/mocks/and_yield_spec.rb
|
286
293
|
spec/spec/mocks/any_number_of_times_spec.rb
|
287
294
|
spec/spec/mocks/argument_expectation_spec.rb
|
288
295
|
spec/spec/mocks/argument_matchers_spec.rb
|
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -7,7 +7,6 @@ $:.unshift 'lib'
|
|
7
7
|
require 'spec/version'
|
8
8
|
require 'spec/rake/spectask'
|
9
9
|
require 'spec/ruby'
|
10
|
-
require 'cucumber/rake/task'
|
11
10
|
|
12
11
|
Hoe.spec 'rspec' do
|
13
12
|
self.version = Spec::VERSION::STRING
|
@@ -15,7 +14,7 @@ Hoe.spec 'rspec' do
|
|
15
14
|
self.description = "Behaviour Driven Development for Ruby."
|
16
15
|
self.rubyforge_name = 'rspec'
|
17
16
|
self.developer('RSpec Development Team', 'rspec-devel@rubyforge.org')
|
18
|
-
self.extra_dev_deps << ["cucumber",">=0.3"] << ["
|
17
|
+
self.extra_dev_deps << ["cucumber",">=0.3"] << ["fakefs",">=0.2.1"] << ["syntax",">=1.0"] << ["diff-lcs",">=1.1.2"]
|
19
18
|
self.extra_dev_deps << ["heckle",">=1.4.3"] unless Spec::Ruby.version >= "1.9"
|
20
19
|
self.remote_rdoc_dir = "rspec/#{Spec::VERSION::STRING}"
|
21
20
|
self.rspec_options = ['--options', 'spec/spec.opts']
|
@@ -78,18 +77,23 @@ namespace :spec do
|
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
81
|
-
|
82
|
-
|
83
|
-
Cucumber
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
80
|
+
begin
|
81
|
+
require 'cucumber/rake/task'
|
82
|
+
desc "Run Cucumber features"
|
83
|
+
if RUBY_VERSION =~ /^1.8/
|
84
|
+
Cucumber::Rake::Task.new :features do |t|
|
85
|
+
t.rcov = true
|
86
|
+
t.rcov_opts = ['--exclude', "features,kernel,load-diff-lcs\.rb,instance_exec\.rb,lib/spec.rb,lib/spec/runner.rb,^spec/*,bin/spec,examples,/gems,/Library/Ruby,\.autotest,#{ENV['GEM_HOME']}"]
|
87
|
+
t.rcov_opts << '--no-html --aggregate coverage.data'
|
88
|
+
t.cucumber_opts = %w{--format progress}
|
89
|
+
end
|
90
|
+
else
|
91
|
+
task :features do
|
92
|
+
sh 'cucumber --profile no_heckle'
|
93
|
+
end
|
92
94
|
end
|
95
|
+
rescue LoadError
|
96
|
+
puts "You need cucumber installed to run cucumber tasks"
|
93
97
|
end
|
94
98
|
|
95
99
|
desc "Run failing examples (see failure output)"
|
data/Upgrade.rdoc
CHANGED
@@ -1,3 +1,61 @@
|
|
1
|
+
= Upgrade to 1.3.0
|
2
|
+
|
3
|
+
== What's changed
|
4
|
+
|
5
|
+
=== +be_true+ and +be_false+
|
6
|
+
|
7
|
+
These methods now align with Ruby's conditional semantics:
|
8
|
+
|
9
|
+
* +be_false+ passes for +false+ and +nil+
|
10
|
+
* +be_true+ passes for everything else
|
11
|
+
|
12
|
+
This is a change from the previous behaviour (which wasn't working correctly
|
13
|
+
anyway), which was supposed to treat +be_true+ as <tt>equal(true)</tt>, and +be_false+ as
|
14
|
+
<tt>equal(false)</tt>.
|
15
|
+
|
16
|
+
If the actual values +true+ and +false+ are meaningful to your examples, you'll
|
17
|
+
want to change the to use <tt>equal(true)</tt> and <tt>equal(false)</tt> (or
|
18
|
+
<tt>==(true)</tt> and <tt>==(false)</tt>).
|
19
|
+
|
20
|
+
=== +raise_exception+
|
21
|
+
|
22
|
+
We changed the +raise_error+ matcher to +raise_exception+, and aliased it with
|
23
|
+
+raise_error+. This maintains backward compatibility, and also gives you the
|
24
|
+
option of being more precise in specs about what is expected.
|
25
|
+
|
26
|
+
=== Matcher DSL
|
27
|
+
|
28
|
+
==== +match+ rescues from +ExpectationNotMetErrror+ by default
|
29
|
+
|
30
|
+
This allows you to wrap other expectations in the +match+ method. Consider
|
31
|
+
this matcher:
|
32
|
+
|
33
|
+
Spec::Matchers.define :teach do |subject|
|
34
|
+
match do |teacher|
|
35
|
+
teacher.subjects.should include(subject)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
The block passed to +match+ is called internally by Rspec, and is expected to
|
40
|
+
return a boolean value. In this case, if <tt>should include(subject)</tt>
|
41
|
+
fails, it raises an +ExpectationNotMetError+.
|
42
|
+
|
43
|
+
Beginning with rspec-1.3.0, when the match block raises an
|
44
|
+
+ExpectationNotMetError+, it is captured and the block returns +false+.
|
45
|
+
Otherwise it returns +true+, so it works like any other matcher.
|
46
|
+
|
47
|
+
==== match_unless_raises
|
48
|
+
|
49
|
+
The new +match_unless_raises+ method allows you to wrap <tt>Test::Unit</tt>
|
50
|
+
assertions by capturing +AssertionFailedError+ and returning false, just as the
|
51
|
+
+match+ method now does with +ExpectationNotMetError+.
|
52
|
+
|
53
|
+
Spec::Matchers.define :teach do |subject|
|
54
|
+
match_unless_raises Test::Unit::AssertionFailedError do |teacher|
|
55
|
+
assert teacher.subjects.include?(subject)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
1
59
|
= Upgrade to rspec-1.2.9
|
2
60
|
|
3
61
|
== What's new
|
@@ -9,8 +67,11 @@ automatically as long as you don't include any options on the command line.
|
|
9
67
|
|
10
68
|
=== let()
|
11
69
|
|
12
|
-
Writing specs tends to follow a regular pattern of using local variables,
|
13
|
-
|
70
|
+
Writing specs tends to follow a regular pattern of using local variables,
|
71
|
+
discovering duplication, and then having to convert to local variables to
|
72
|
+
instance variables by adding an "@" symbol. The let() method assigns the result
|
73
|
+
of a lazy eval'd block as the return value of an instance method using the same
|
74
|
+
name. This way you can go from this:
|
14
75
|
|
15
76
|
describe Subscription do
|
16
77
|
it "does something" do
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Feature: nested formatter
|
2
|
+
|
3
|
+
The nested formatter follows the nesting in each spec.
|
4
|
+
|
5
|
+
Scenario: parallel contexts
|
6
|
+
Given a file named "simple_example_spec.rb" with:
|
7
|
+
"""
|
8
|
+
describe "first group" do
|
9
|
+
context "with context" do
|
10
|
+
specify "does something" do
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
describe "second group" do
|
15
|
+
context "with context" do
|
16
|
+
specify "does something" do
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
"""
|
21
|
+
|
22
|
+
When I run "spec simple_example_spec.rb --format nested"
|
23
|
+
Then the exit code should be 0
|
24
|
+
And the stdout should include
|
25
|
+
"""
|
26
|
+
first group
|
27
|
+
with context
|
28
|
+
does something
|
29
|
+
second group
|
30
|
+
with context
|
31
|
+
does something
|
32
|
+
"""
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: Cucumber Stubs Don't Leak
|
2
|
+
In order to not explode from frustration
|
3
|
+
a developer
|
4
|
+
does not want rspec stubs to leak between cucumber scenarios
|
5
|
+
|
6
|
+
Scenario: Create a stub
|
7
|
+
When I stub "nap" on "Time" to "When I Get Cranky"
|
8
|
+
Then calling "nap" on "Time" should return "When I Get Cranky"
|
9
|
+
|
10
|
+
Scenario: Check to see if the stub leaked
|
11
|
+
Then "nap" should not be defined on "Time"
|
@@ -25,3 +25,24 @@ Feature: define matcher
|
|
25
25
|
When I run "spec between_spec.rb --format specdoc"
|
26
26
|
Then the stdout should include "1 example, 0 failures"
|
27
27
|
And the stdout should include "should be bigger than 4"
|
28
|
+
|
29
|
+
Scenario: generate method using dsl
|
30
|
+
Given a file named "between_spec.rb" with:
|
31
|
+
"""
|
32
|
+
Spec::Matchers.define :be_bigger_than do |first|
|
33
|
+
chain :but_smaller_than do |limit|
|
34
|
+
@limit = limit
|
35
|
+
end
|
36
|
+
|
37
|
+
match do |actual|
|
38
|
+
(actual > first) && (actual < @limit)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 5 do
|
43
|
+
it { should be_bigger_than(4).but_smaller_than(6) }
|
44
|
+
end
|
45
|
+
"""
|
46
|
+
When I run "spec between_spec.rb --format specdoc"
|
47
|
+
Then the stdout should include "1 example, 0 failures"
|
48
|
+
And the stdout should include "should be bigger than 4"
|
@@ -3,8 +3,11 @@ Feature: define wrapped matcher
|
|
3
3
|
In order to reuse existing matchers
|
4
4
|
As an RSpec user
|
5
5
|
I want to define matchers that wrap other matchers
|
6
|
+
|
7
|
+
When the wrapped matcher passes, the wrapping matcher returns true.
|
8
|
+
When the wrapped matcher fails, the wrapping matcher returns false.
|
6
9
|
|
7
|
-
Scenario:
|
10
|
+
Scenario: wrap a matcher using should
|
8
11
|
Given a file named "new_model_spec.rb" with:
|
9
12
|
"""
|
10
13
|
Spec::Matchers.define :have_tag do |tag|
|
@@ -27,3 +30,27 @@ Feature: define wrapped matcher
|
|
27
30
|
"""
|
28
31
|
When I run "spec new_model_spec.rb --format specdoc"
|
29
32
|
Then the stdout should include "1 example, 0 failures"
|
33
|
+
|
34
|
+
Scenario: wrap a matcher using should_not
|
35
|
+
Given a file named "new_model_spec.rb" with:
|
36
|
+
"""
|
37
|
+
Spec::Matchers.define :have_tag do |tag|
|
38
|
+
match do |markup|
|
39
|
+
markup =~ /<#{tag}>.*<\/#{tag}>/
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Spec::Matchers.define :have_button do
|
44
|
+
match do |markup|
|
45
|
+
markup.should have_tag('button')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "some markup" do
|
50
|
+
it "has no buttons" do
|
51
|
+
"<p>Label</p>".should_not have_button
|
52
|
+
end
|
53
|
+
end
|
54
|
+
"""
|
55
|
+
When I run "spec new_model_spec.rb --format specdoc"
|
56
|
+
Then the stdout should include "1 example, 0 failures"
|
@@ -0,0 +1,60 @@
|
|
1
|
+
Feature: match unless raises
|
2
|
+
|
3
|
+
In order, primarily, to reuse existing test/unit assertions
|
4
|
+
As an RSpec user
|
5
|
+
I want to define matchers that wrap a statement that raises an error on failure
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a file named "example.rb" with:
|
9
|
+
"""
|
10
|
+
require 'test/unit/assertions'
|
11
|
+
|
12
|
+
Spec::Matchers.define :be_the_same_as do |expected|
|
13
|
+
extend Test::Unit::Assertions
|
14
|
+
match_unless_raises Test::Unit::AssertionFailedError do |actual|
|
15
|
+
assert_equal expected, actual
|
16
|
+
end
|
17
|
+
end
|
18
|
+
"""
|
19
|
+
|
20
|
+
Scenario: passing examples
|
21
|
+
Given a file named "match_unless_raises_spec.rb" with:
|
22
|
+
"""
|
23
|
+
require 'example.rb'
|
24
|
+
|
25
|
+
describe 4 do
|
26
|
+
it "is 4" do
|
27
|
+
4.should be_the_same_as(4)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 5 do
|
32
|
+
it "is not 4" do
|
33
|
+
5.should_not be_the_same_as(4)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
"""
|
37
|
+
When I run "spec match_unless_raises_spec.rb"
|
38
|
+
Then the stdout should include "2 examples, 0 failures"
|
39
|
+
|
40
|
+
Scenario: failing examples
|
41
|
+
Given a file named "match_unless_raises_spec.rb" with:
|
42
|
+
"""
|
43
|
+
require 'example.rb'
|
44
|
+
|
45
|
+
describe 4 do
|
46
|
+
it "is 4" do
|
47
|
+
# intentionally fail
|
48
|
+
4.should_not be_the_same_as(4)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 5 do
|
53
|
+
it "is not 4" do
|
54
|
+
# intentionally fail
|
55
|
+
5.should be_the_same_as(4)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
"""
|
59
|
+
When I run "spec match_unless_raises_spec.rb"
|
60
|
+
Then the stdout should include "2 examples, 2 failures"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Feature: match unless raises with an unexpected error
|
2
|
+
|
3
|
+
In order to know when a match_unless_raises block raises an unexpected error
|
4
|
+
As an RSpec user
|
5
|
+
I want the error to bubble up
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a file named "example.rb" with:
|
9
|
+
"""
|
10
|
+
Spec::Matchers.define :be_the_same_as do |expected|
|
11
|
+
match_unless_raises SyntaxError do |actual|
|
12
|
+
raise "unexpected error"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
|
17
|
+
Scenario: failing examples
|
18
|
+
Given a file named "match_unless_raises_spec.rb" with:
|
19
|
+
"""
|
20
|
+
require 'example.rb'
|
21
|
+
|
22
|
+
describe 4 do
|
23
|
+
it "is 4" do
|
24
|
+
# intentionally fail
|
25
|
+
4.should_not be_the_same_as(4)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 5 do
|
30
|
+
it "is not 4" do
|
31
|
+
# intentionally fail
|
32
|
+
5.should be_the_same_as(4)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
"""
|
36
|
+
When I run "spec match_unless_raises_spec.rb"
|
37
|
+
Then the stdout should include "2 examples, 2 failures"
|
38
|
+
Then the stdout should include "unexpected error"
|
39
|
+
|