rspec 1.2.6 → 1.2.7
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 +22 -0
- data/Manifest.txt +9 -4
- data/Rakefile +13 -12
- data/Upgrade.rdoc +1 -1
- data/features/command_line/line_number_option.feature +56 -0
- data/features/command_line/line_number_option_with_example_with_no_name.feature +22 -0
- data/features/mocks/stub_implementation.feature +26 -0
- data/lib/autotest/rspec.rb +7 -7
- data/lib/spec/autorun.rb +1 -1
- data/lib/spec/deprecation.rb +3 -3
- data/lib/spec/dsl.rb +0 -1
- data/lib/spec/dsl/main.rb +6 -6
- data/lib/spec/example.rb +28 -29
- data/lib/spec/example/args_and_options.rb +1 -1
- data/lib/spec/example/before_and_after_hooks.rb +10 -10
- data/lib/spec/example/errors.rb +8 -3
- data/lib/spec/example/example_group.rb +0 -1
- data/lib/spec/example/example_group_factory.rb +3 -3
- data/lib/spec/example/example_group_hierarchy.rb +10 -10
- data/lib/spec/example/example_group_methods.rb +37 -29
- data/lib/spec/example/example_group_proxy.rb +9 -10
- data/lib/spec/example/example_matcher.rb +3 -3
- data/lib/spec/example/example_methods.rb +11 -11
- data/lib/spec/example/example_proxy.rb +5 -5
- data/lib/spec/example/module_reopening_fix.rb +7 -7
- data/lib/spec/example/pending.rb +1 -1
- data/lib/spec/example/predicate_matchers.rb +0 -1
- data/lib/spec/example/shared_example_group.rb +5 -5
- data/lib/spec/example/subject.rb +12 -16
- data/lib/spec/expectations/extensions/kernel.rb +1 -1
- data/lib/spec/expectations/fail_with.rb +4 -0
- data/lib/spec/matchers/generated_descriptions.rb +4 -16
- data/lib/spec/matchers/match.rb +5 -4
- data/lib/spec/matchers/matcher.rb +21 -3
- data/lib/spec/matchers/operator_matcher.rb +1 -1
- data/lib/spec/mocks/errors.rb +1 -1
- data/lib/spec/mocks/message_expectation.rb +3 -2
- data/lib/spec/mocks/methods.rb +8 -5
- data/lib/spec/mocks/proxy.rb +2 -2
- data/lib/spec/rake/spectask.rb +9 -3
- data/lib/spec/runner.rb +1 -1
- data/lib/spec/runner/{spec_parser.rb → line_number_query.rb} +20 -9
- data/lib/spec/runner/options.rb +10 -2
- data/lib/spec/version.rb +3 -2
- data/spec/autotest/failed_results_re_spec.rb +7 -0
- data/spec/spec/example/example_group_methods_spec.rb +61 -0
- data/spec/spec/example/example_matcher_spec.rb +7 -0
- data/spec/spec/example/example_methods_spec.rb +35 -7
- data/spec/spec/expectations/fail_with_spec.rb +18 -1
- data/spec/spec/matchers/match_spec.rb +20 -0
- data/spec/spec/matchers/matcher_spec.rb +27 -28
- data/spec/spec/matchers/operator_matcher_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_10263_spec.rb +4 -1
- data/spec/spec/mocks/bug_report_830_spec.rb +21 -0
- data/spec/spec/mocks/options_hash_spec.rb +1 -1
- data/spec/spec/mocks/stub_chain_spec.rb +7 -0
- data/spec/spec/mocks/stub_implementation_spec.rb +31 -0
- data/spec/spec/rake/spectask_spec.rb +150 -0
- data/spec/spec/runner/{spec_parser/spec_parser_fixture.rb → line_number_query/line_number_query_fixture.rb} +4 -4
- data/spec/spec/runner/{spec_parser_spec.rb → line_number_query_spec.rb} +31 -10
- data/spec/spec/runner/option_parser_spec.rb +1 -1
- data/spec/spec/runner/options_spec.rb +33 -25
- metadata +15 -10
- data/.autotest +0 -5
data/History.rdoc
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
=== Version 1.2.7 / 2009-06-22
|
2
|
+
|
3
|
+
* enhancments
|
4
|
+
* added support for fakes using obj.stub(:method) { # implementation }
|
5
|
+
* allow subject { self } (Jarmo Pertman). Closes #816.
|
6
|
+
* friendly error message when a matcher returns nil on a failure message
|
7
|
+
* add ruby_cmd option to SpecTask (Rick DeNatale). Closes #823.
|
8
|
+
* also added missing specs for SpecTask - thanks Rick!
|
9
|
+
* add support for generating matchers with fluent interfaces with the
|
10
|
+
Matcher DSL
|
11
|
+
|
12
|
+
* bug fixes
|
13
|
+
* NegativeOperatorMatcher now returns false (Wesley Beary). Closes #812.
|
14
|
+
* derive MockExpectationError from Exception rather than StandardError
|
15
|
+
(Kerry Buckley). Closes #830.
|
16
|
+
* fix bug where multi-line failure messages weren't getting picked up by
|
17
|
+
autotest (Jarmo Pertman). Closes #832.
|
18
|
+
* --line_number now works for it { should xxx } format (assist from Fred
|
19
|
+
Lee)
|
20
|
+
* warn instead of raise when there is no description supplied for an
|
21
|
+
example. Closes #840.
|
22
|
+
|
1
23
|
=== Version 1.2.6 / 2009-04-30
|
2
24
|
|
3
25
|
* bug fixes
|
data/Manifest.txt
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
.autotest
|
2
1
|
.document
|
3
2
|
History.rdoc
|
4
3
|
License.txt
|
@@ -59,6 +58,8 @@ examples/passing/stubbing_example.rb
|
|
59
58
|
examples/passing/yielding_example.rb
|
60
59
|
examples/ruby1.9.compatibility/access_to_constants_spec.rb
|
61
60
|
features/before_and_after_blocks/before_and_after_blocks.feature
|
61
|
+
features/command_line/line_number_option.feature
|
62
|
+
features/command_line/line_number_option_with_example_with_no_name.feature
|
62
63
|
features/example_groups/example_group_with_should_methods.feature
|
63
64
|
features/example_groups/implicit_docstrings.feature
|
64
65
|
features/example_groups/nested_groups.feature
|
@@ -78,6 +79,7 @@ features/mock_framework_integration/use_flexmock.feature
|
|
78
79
|
features/mock_framework_integration/use_mocha.feature
|
79
80
|
features/mock_framework_integration/use_rr.feature
|
80
81
|
features/mocks/mix_stubs_and_mocks.feature
|
82
|
+
features/mocks/stub_implementation.feature
|
81
83
|
features/pending/pending_examples.feature
|
82
84
|
features/runner/specify_line_number.feature
|
83
85
|
features/step_definitions/running_rspec_steps.rb
|
@@ -198,10 +200,10 @@ lib/spec/runner/formatter/specdoc_formatter.rb
|
|
198
200
|
lib/spec/runner/formatter/text_mate_formatter.rb
|
199
201
|
lib/spec/runner/heckle_runner.rb
|
200
202
|
lib/spec/runner/heckle_runner_unsupported.rb
|
203
|
+
lib/spec/runner/line_number_query.rb
|
201
204
|
lib/spec/runner/option_parser.rb
|
202
205
|
lib/spec/runner/options.rb
|
203
206
|
lib/spec/runner/reporter.rb
|
204
|
-
lib/spec/runner/spec_parser.rb
|
205
207
|
lib/spec/test/unit.rb
|
206
208
|
lib/spec/version.rb
|
207
209
|
resources/helpers/cmdline.rb
|
@@ -290,6 +292,7 @@ spec/spec/mocks/bug_report_7611_spec.rb
|
|
290
292
|
spec/spec/mocks/bug_report_7805_spec.rb
|
291
293
|
spec/spec/mocks/bug_report_8165_spec.rb
|
292
294
|
spec/spec/mocks/bug_report_8302_spec.rb
|
295
|
+
spec/spec/mocks/bug_report_830_spec.rb
|
293
296
|
spec/spec/mocks/failing_argument_matchers_spec.rb
|
294
297
|
spec/spec/mocks/hash_including_matcher_spec.rb
|
295
298
|
spec/spec/mocks/hash_not_including_matcher_spec.rb
|
@@ -307,10 +310,12 @@ spec/spec/mocks/passing_argument_matchers_spec.rb
|
|
307
310
|
spec/spec/mocks/precise_counts_spec.rb
|
308
311
|
spec/spec/mocks/record_messages_spec.rb
|
309
312
|
spec/spec/mocks/stub_chain_spec.rb
|
313
|
+
spec/spec/mocks/stub_implementation_spec.rb
|
310
314
|
spec/spec/mocks/stub_spec.rb
|
311
315
|
spec/spec/mocks/stubbed_message_expectations_spec.rb
|
312
316
|
spec/spec/mocks/twice_counts_spec.rb
|
313
317
|
spec/spec/package/bin_spec_spec.rb
|
318
|
+
spec/spec/rake/spectask_spec.rb
|
314
319
|
spec/spec/runner/class_and_argument_parser_spec.rb
|
315
320
|
spec/spec/runner/command_line_spec.rb
|
316
321
|
spec/spec/runner/configuration_spec.rb
|
@@ -343,6 +348,8 @@ spec/spec/runner/formatter/text_mate_formatted-1.9.1.html
|
|
343
348
|
spec/spec/runner/formatter/text_mate_formatter_spec.rb
|
344
349
|
spec/spec/runner/heckle_runner_spec.rb
|
345
350
|
spec/spec/runner/heckler_spec.rb
|
351
|
+
spec/spec/runner/line_number_query/line_number_query_fixture.rb
|
352
|
+
spec/spec/runner/line_number_query_spec.rb
|
346
353
|
spec/spec/runner/noisy_backtrace_tweaker_spec.rb
|
347
354
|
spec/spec/runner/option_parser_spec.rb
|
348
355
|
spec/spec/runner/options_spec.rb
|
@@ -358,8 +365,6 @@ spec/spec/runner/resources/custom_example_group_runner.rb
|
|
358
365
|
spec/spec/runner/resources/utf8_encoded.rb
|
359
366
|
spec/spec/runner/spec.opts
|
360
367
|
spec/spec/runner/spec_drb.opts
|
361
|
-
spec/spec/runner/spec_parser/spec_parser_fixture.rb
|
362
|
-
spec/spec/runner/spec_parser_spec.rb
|
363
368
|
spec/spec/runner/spec_spaced.opts
|
364
369
|
spec/spec/runner_spec.rb
|
365
370
|
spec/spec/spec_classes.rb
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
gem 'hoe', '>=
|
2
|
+
gem 'hoe', '>=2.0.0'
|
3
3
|
require 'hoe'
|
4
4
|
|
5
5
|
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
@@ -8,17 +8,18 @@ require 'spec/version'
|
|
8
8
|
require 'spec/rake/spectask'
|
9
9
|
require 'cucumber/rake/task'
|
10
10
|
|
11
|
-
Hoe.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
Hoe.spec('rspec') do |hoe|
|
12
|
+
hoe.version = Spec::VERSION::STRING
|
13
|
+
hoe.summary = Spec::VERSION::SUMMARY
|
14
|
+
hoe.description = "Behaviour Driven Development for Ruby."
|
15
|
+
hoe.rubyforge_name = 'rspec'
|
16
|
+
hoe.developer('RSpec Development Team', 'rspec-devel@rubyforge.org')
|
17
|
+
hoe.extra_dev_deps = [["cucumber",">= 0.2.2"]]
|
18
|
+
hoe.remote_rdoc_dir = "rspec/#{Spec::VERSION::STRING}"
|
19
|
+
hoe.rspec_options = ['--options', 'spec/spec.opts']
|
20
|
+
hoe.history_file = 'History.rdoc'
|
21
|
+
hoe.readme_file = 'README.rdoc'
|
22
|
+
hoe.post_install_message = <<-POST_INSTALL_MESSAGE
|
22
23
|
#{'*'*50}
|
23
24
|
|
24
25
|
Thank you for installing rspec-#{Spec::VERSION::STRING}
|
data/Upgrade.rdoc
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
Feature: Spec and test together
|
2
|
+
|
3
|
+
As an RSpec user
|
4
|
+
I want to run one example identified by the line number
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a file named "example.rb" with:
|
8
|
+
"""
|
9
|
+
describe "a group" do
|
10
|
+
|
11
|
+
it "has a first example" do
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
it "has a second example" do
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
"""
|
21
|
+
|
22
|
+
Scenario: two examples - first example on declaration line
|
23
|
+
When I run "spec example.rb:3 --format nested"
|
24
|
+
Then the stdout should match "1 example, 0 failures"
|
25
|
+
And the stdout should match "has a first example"
|
26
|
+
But the stdout should not match "has a second example"
|
27
|
+
|
28
|
+
Scenario: two examples - first example from line inside declaration
|
29
|
+
When I run "spec example.rb:4 --format nested"
|
30
|
+
Then the stdout should match "1 example, 0 failures"
|
31
|
+
And the stdout should match "has a first example"
|
32
|
+
But the stdout should not match "has a second example"
|
33
|
+
|
34
|
+
Scenario: two examples - first example from line below declaration
|
35
|
+
When I run "spec example.rb:6 --format nested"
|
36
|
+
Then the stdout should match "1 example, 0 failures"
|
37
|
+
And the stdout should match "has a first example"
|
38
|
+
But the stdout should not match "has a second example"
|
39
|
+
|
40
|
+
Scenario: two examples - second example from line below declaration
|
41
|
+
When I run "spec example.rb:7 --format nested"
|
42
|
+
Then the stdout should match "1 example, 0 failures"
|
43
|
+
And the stdout should match "has a second example"
|
44
|
+
But the stdout should not match "has a first example"
|
45
|
+
|
46
|
+
Scenario: two examples - both examples from the group declaration
|
47
|
+
When I run "spec example.rb:1 --format nested"
|
48
|
+
Then the stdout should match "2 examples, 0 failures"
|
49
|
+
And the stdout should match "has a second example"
|
50
|
+
And the stdout should match "has a first example"
|
51
|
+
|
52
|
+
Scenario: two examples - both examples from above the first example declaration
|
53
|
+
When I run "spec example.rb:2 --format nested"
|
54
|
+
Then the stdout should match "2 examples, 0 failures"
|
55
|
+
And the stdout should match "has a second example"
|
56
|
+
And the stdout should match "has a first example"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Feature: Spec and test together
|
2
|
+
|
3
|
+
As an RSpec user
|
4
|
+
I want to run one example identified by the line number
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a file named "example.rb" with:
|
8
|
+
"""
|
9
|
+
describe 9 do
|
10
|
+
|
11
|
+
it { should be > 8 }
|
12
|
+
|
13
|
+
it { should be < 10 }
|
14
|
+
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
|
18
|
+
Scenario: two examples - first example on declaration line
|
19
|
+
When I run "spec example.rb:3 --format nested"
|
20
|
+
Then the stdout should match "1 example, 0 failures"
|
21
|
+
Then the stdout should match "should be > 8"
|
22
|
+
But the stdout should not match "should be < 10"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Feature: stub implementation
|
2
|
+
|
3
|
+
As an rspec user, I want to stub a complete implementation, not just a
|
4
|
+
return value.
|
5
|
+
|
6
|
+
Scenario: stub implementation
|
7
|
+
Given a file named "stub_implementation.rb" with:
|
8
|
+
"""
|
9
|
+
describe "a stubbed implementation" do
|
10
|
+
it "works" do
|
11
|
+
object = Object.new
|
12
|
+
object.stub(:foo) do |arg|
|
13
|
+
if arg == :this
|
14
|
+
"got this"
|
15
|
+
elsif arg == :that
|
16
|
+
"got that"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
object.foo(:this).should == "got this"
|
21
|
+
object.foo(:that).should == "got that"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
When I run "spec stub_implementation.rb"
|
26
|
+
Then the stdout should match "1 example, 0 failures"
|
data/lib/autotest/rspec.rb
CHANGED
@@ -4,13 +4,13 @@ Autotest.add_hook :initialize do |at|
|
|
4
4
|
at.clear_mappings
|
5
5
|
# watch out: Ruby bug (1.8.6):
|
6
6
|
# %r(/) != /\//
|
7
|
-
at.add_mapping(%r%^spec/.*_spec.rb$%) { |filename, _|
|
8
|
-
filename
|
7
|
+
at.add_mapping(%r%^spec/.*_spec.rb$%) { |filename, _|
|
8
|
+
filename
|
9
9
|
}
|
10
|
-
at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
|
10
|
+
at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
|
11
11
|
["spec/#{m[1]}_spec.rb"]
|
12
12
|
}
|
13
|
-
at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
|
13
|
+
at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
|
14
14
|
at.files_matching %r%^spec/.*_spec\.rb$%
|
15
15
|
}
|
16
16
|
end
|
@@ -21,10 +21,10 @@ class Autotest::Rspec < Autotest
|
|
21
21
|
|
22
22
|
def initialize
|
23
23
|
super
|
24
|
-
self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m
|
24
|
+
self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n\n?(.*?(\n\n\(.*?)?)\n\n/m
|
25
25
|
self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def consolidate_failures(failed)
|
29
29
|
filters = new_hash_of_arrays
|
30
30
|
failed.each do |spec, trace|
|
@@ -40,7 +40,7 @@ class Autotest::Rspec < Autotest
|
|
40
40
|
spec_program = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec'))
|
41
41
|
return "#{ruby} #{spec_program} --autospec #{files_to_test.keys.flatten.join(' ')} #{add_options_if_present}"
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def add_options_if_present # :nodoc:
|
45
45
|
File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
|
46
46
|
end
|
data/lib/spec/autorun.rb
CHANGED
data/lib/spec/deprecation.rb
CHANGED
@@ -16,15 +16,15 @@ NOTICE
|
|
16
16
|
* please use #{alternate_method} instead.
|
17
17
|
ADDITIONAL
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
message << "*****************************************************************"
|
21
21
|
warn(message)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def warn(message)
|
25
25
|
Kernel.warn(message)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
end
|
29
29
|
|
30
30
|
class HashWithDeprecationNotice < Hash
|
data/lib/spec/dsl.rb
CHANGED
data/lib/spec/dsl/main.rb
CHANGED
@@ -2,7 +2,7 @@ module Spec
|
|
2
2
|
module DSL
|
3
3
|
module Main
|
4
4
|
include Spec::Example::ArgsAndOptions
|
5
|
-
|
5
|
+
|
6
6
|
# Creates and returns a class that includes the ExampleGroupMethods
|
7
7
|
# module. Which ExampleGroup type is created depends on the directory of the file
|
8
8
|
# calling this method. For example, Spec::Rails will use different
|
@@ -28,7 +28,7 @@ module Spec
|
|
28
28
|
Spec::Example::ExampleGroupFactory.create_example_group(*args, &block)
|
29
29
|
end
|
30
30
|
alias :context :describe
|
31
|
-
|
31
|
+
|
32
32
|
# Creates an example group that can be shared by other example groups
|
33
33
|
#
|
34
34
|
# == Examples
|
@@ -39,7 +39,7 @@ module Spec
|
|
39
39
|
#
|
40
40
|
# describe SmallEdition do
|
41
41
|
# it_should_behave_like "All Editions"
|
42
|
-
#
|
42
|
+
#
|
43
43
|
# it "should do small edition stuff" do
|
44
44
|
# ...
|
45
45
|
# end
|
@@ -50,7 +50,7 @@ module Spec
|
|
50
50
|
Spec::Example::ExampleGroupFactory.create_shared_example_group(*args, &block)
|
51
51
|
end
|
52
52
|
alias :shared_examples_for :share_examples_for
|
53
|
-
|
53
|
+
|
54
54
|
# Creates a Shared Example Group and assigns it to a constant
|
55
55
|
#
|
56
56
|
# share_as :AllEditions do
|
@@ -59,7 +59,7 @@ module Spec
|
|
59
59
|
#
|
60
60
|
# describe SmallEdition do
|
61
61
|
# it_should_behave_like AllEditions
|
62
|
-
#
|
62
|
+
#
|
63
63
|
# it "should do small edition stuff" do
|
64
64
|
# ...
|
65
65
|
# end
|
@@ -70,7 +70,7 @@ module Spec
|
|
70
70
|
#
|
71
71
|
# describe SmallEdition do
|
72
72
|
# include AllEditions
|
73
|
-
#
|
73
|
+
#
|
74
74
|
# it "should do small edition stuff" do
|
75
75
|
# ...
|
76
76
|
# end
|
data/lib/spec/example.rb
CHANGED
@@ -7,102 +7,102 @@ module Spec
|
|
7
7
|
# An Example Group is a group of code examples.
|
8
8
|
#
|
9
9
|
# RSpec exposes a DSL to describe groups of examples.
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# describe Account do
|
12
12
|
# it "should have a balance of $0" do
|
13
13
|
# account = Account.new
|
14
14
|
# account.balance.should == Money.new(0, :dollars)
|
15
15
|
# end
|
16
16
|
# end
|
17
|
-
#
|
17
|
+
#
|
18
18
|
# == Before and After
|
19
|
-
#
|
19
|
+
#
|
20
20
|
# You can use the <tt>before()</tt> and <tt>after()</tt> methods to extract
|
21
21
|
# common code within an Example Group. Both methods take an optional scope
|
22
22
|
# argument so you can run the block before :each example or before :all
|
23
23
|
# examples
|
24
|
-
#
|
24
|
+
#
|
25
25
|
# describe "..." do
|
26
26
|
# before :all do
|
27
27
|
# ...
|
28
28
|
# end
|
29
|
-
#
|
29
|
+
#
|
30
30
|
# before :each do
|
31
31
|
# ...
|
32
32
|
# end
|
33
|
-
#
|
33
|
+
#
|
34
34
|
# it "should do something" do
|
35
35
|
# ...
|
36
36
|
# end
|
37
|
-
#
|
37
|
+
#
|
38
38
|
# it "should do something else" do
|
39
39
|
# ...
|
40
40
|
# end
|
41
|
-
#
|
41
|
+
#
|
42
42
|
# after :each do
|
43
43
|
# ...
|
44
44
|
# end
|
45
|
-
#
|
45
|
+
#
|
46
46
|
# after :all do
|
47
47
|
# ...
|
48
48
|
# end
|
49
|
-
#
|
49
|
+
#
|
50
50
|
# end
|
51
|
-
#
|
51
|
+
#
|
52
52
|
# The <tt>before :each</tt> block will run before each of the examples, once
|
53
53
|
# for each example. Likewise, the <tt>after :each</tt> block will run after
|
54
54
|
# each of the examples.
|
55
|
-
#
|
55
|
+
#
|
56
56
|
# It is also possible to specify a <tt>before :all</tt> and <tt>after
|
57
57
|
# :all</tt> block that will run only once for each example group, before the
|
58
58
|
# first <code>before :each</code> and after the last <code>after
|
59
59
|
# :each</code> respectively. The use of these is generally discouraged,
|
60
60
|
# because it introduces dependencies between the examples. Still, it might
|
61
61
|
# prove useful for very expensive operations if you know what you are doing.
|
62
|
-
#
|
62
|
+
#
|
63
63
|
# == Local helper methods
|
64
|
-
#
|
64
|
+
#
|
65
65
|
# You can include local helper methods by simply expressing them within an
|
66
66
|
# example group:
|
67
|
-
#
|
67
|
+
#
|
68
68
|
# describe "..." do
|
69
|
-
#
|
69
|
+
#
|
70
70
|
# it "..." do
|
71
71
|
# helper_method
|
72
72
|
# end
|
73
|
-
#
|
73
|
+
#
|
74
74
|
# def helper_method
|
75
75
|
# ...
|
76
76
|
# end
|
77
|
-
#
|
77
|
+
#
|
78
78
|
# end
|
79
|
-
#
|
79
|
+
#
|
80
80
|
# == Included helper methods
|
81
|
-
#
|
81
|
+
#
|
82
82
|
# You can include helper methods in multiple example groups by expressing
|
83
83
|
# them within a module, and then including that module in your example
|
84
84
|
# groups:
|
85
|
-
#
|
85
|
+
#
|
86
86
|
# module AccountExampleHelperMethods
|
87
87
|
# def helper_method
|
88
88
|
# ...
|
89
89
|
# end
|
90
90
|
# end
|
91
|
-
#
|
91
|
+
#
|
92
92
|
# describe "A new account" do
|
93
93
|
# include AccountExampleHelperMethods
|
94
94
|
# before do
|
95
95
|
# @account = Account.new
|
96
96
|
# end
|
97
|
-
#
|
97
|
+
#
|
98
98
|
# it "should have a balance of $0" do
|
99
99
|
# helper_method
|
100
100
|
# @account.balance.should eql(Money.new(0, :dollars))
|
101
101
|
# end
|
102
102
|
# end
|
103
|
-
#
|
103
|
+
#
|
104
104
|
# == Shared Example Groups
|
105
|
-
#
|
105
|
+
#
|
106
106
|
# You can define a shared example group, that may be used on other groups
|
107
107
|
#
|
108
108
|
# share_examples_for "All Editions" do
|
@@ -111,7 +111,7 @@ module Spec
|
|
111
111
|
#
|
112
112
|
# describe SmallEdition do
|
113
113
|
# it_should_behave_like "All Editions"
|
114
|
-
#
|
114
|
+
#
|
115
115
|
# it "should do small edition stuff" do
|
116
116
|
# ...
|
117
117
|
# end
|
@@ -125,7 +125,7 @@ module Spec
|
|
125
125
|
#
|
126
126
|
# describe SmallEdition do
|
127
127
|
# it_should_behave_like AllEditions
|
128
|
-
#
|
128
|
+
#
|
129
129
|
# it "should do small edition stuff" do
|
130
130
|
# ...
|
131
131
|
# end
|
@@ -136,7 +136,7 @@ module Spec
|
|
136
136
|
#
|
137
137
|
# describe SmallEdition do
|
138
138
|
# include AllEditions
|
139
|
-
#
|
139
|
+
#
|
140
140
|
# it "should do small edition stuff" do
|
141
141
|
# ...
|
142
142
|
# end
|
@@ -162,4 +162,3 @@ require 'spec/example/shared_example_group'
|
|
162
162
|
require 'spec/example/example_group_factory'
|
163
163
|
require 'spec/example/errors'
|
164
164
|
require 'spec/example/example_matcher'
|
165
|
-
|