rspec-core 2.5.1 → 2.6.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/.travis.yml +7 -0
- data/Gemfile +12 -14
- data/README.md +4 -1
- data/Rakefile +29 -12
- data/cucumber.yml +1 -1
- data/features/.nav +15 -9
- data/features/Autotest.md +31 -7
- data/features/Changelog.md +46 -3
- data/features/Upgrade.md +35 -2
- data/features/command_line/README.md +22 -0
- data/features/command_line/configure.feature +2 -2
- data/features/command_line/example_name_option.feature +10 -10
- data/features/command_line/exit_status.feature +4 -4
- data/features/command_line/format_option.feature +4 -4
- data/features/command_line/line_number_appended_to_path.feature +11 -11
- data/features/command_line/line_number_option.feature +2 -2
- data/features/command_line/rake_task.feature +3 -3
- data/features/command_line/tag.feature +30 -14
- data/features/configuration/alias_example_to.feature +48 -0
- data/features/configuration/custom_settings.feature +3 -3
- data/features/configuration/fail_fast.feature +3 -3
- data/features/configuration/read_options_from_file.feature +4 -4
- data/features/example_groups/basic_structure.feature +11 -15
- data/features/example_groups/shared_context.feature +74 -0
- data/features/example_groups/shared_example_group.feature +21 -17
- data/features/expectation_framework_integration/configure_expectation_framework.feature +15 -4
- data/features/filtering/exclusion_filters.feature +28 -4
- data/features/filtering/{implicit_filters.feature → if_and_unless.feature} +9 -7
- data/features/filtering/inclusion_filters.feature +26 -3
- data/features/filtering/run_all_when_everything_filtered.feature +2 -2
- data/features/formatters/custom_formatter.feature +1 -1
- data/features/formatters/text_formatter.feature +43 -0
- data/features/helper_methods/arbitrary_methods.feature +2 -2
- data/features/helper_methods/let.feature +2 -2
- data/features/helper_methods/modules.feature +149 -0
- data/features/hooks/around_hooks.feature +18 -11
- data/features/hooks/before_and_after_hooks.feature +15 -19
- data/features/hooks/filtering.feature +160 -124
- data/features/metadata/current_example.feature +17 -0
- data/features/metadata/described_class.feature +2 -2
- data/features/metadata/user_defined.feature +111 -0
- data/features/mock_framework_integration/use_any_framework.feature +1 -1
- data/features/mock_framework_integration/use_flexmock.feature +83 -10
- data/features/mock_framework_integration/use_mocha.feature +84 -10
- data/features/mock_framework_integration/use_rr.feature +85 -10
- data/features/mock_framework_integration/use_rspec.feature +84 -10
- data/features/pending/pending_examples.feature +8 -8
- data/features/spec_files/arbitrary_file_suffix.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +11 -1
- data/features/subject/attribute_of_subject.feature +24 -4
- data/features/subject/explicit_subject.feature +5 -5
- data/features/subject/implicit_receiver.feature +2 -2
- data/features/subject/implicit_subject.feature +2 -2
- data/features/support/env.rb +6 -1
- data/lib/rspec/core/backward_compatibility.rb +12 -2
- data/lib/rspec/core/command_line.rb +2 -5
- data/lib/rspec/core/configuration.rb +70 -38
- data/lib/rspec/core/configuration_options.rb +6 -23
- data/lib/rspec/core/drb_command_line.rb +5 -11
- data/lib/rspec/core/example.rb +29 -21
- data/lib/rspec/core/example_group.rb +40 -8
- data/lib/rspec/core/extensions/object.rb +0 -1
- data/lib/rspec/core/formatters/base_formatter.rb +6 -0
- data/lib/rspec/core/formatters/base_text_formatter.rb +1 -1
- data/lib/rspec/core/formatters/helpers.rb +0 -4
- data/lib/rspec/core/hooks.rb +14 -4
- data/lib/rspec/core/metadata.rb +1 -1
- data/lib/rspec/core/metadata_hash_builder.rb +93 -0
- data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
- data/lib/rspec/core/mocking/with_mocha.rb +2 -0
- data/lib/rspec/core/mocking/with_rr.rb +2 -0
- data/lib/rspec/core/mocking/with_rspec.rb +3 -1
- data/lib/rspec/core/option_parser.rb +9 -2
- data/lib/rspec/core/pending.rb +10 -3
- data/lib/rspec/core/reporter.rb +2 -2
- data/lib/rspec/core/runner.rb +38 -13
- data/lib/rspec/core/shared_example_group.rb +18 -4
- data/lib/rspec/core/subject.rb +4 -6
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +70 -18
- data/lib/rspec/core.rb +29 -0
- data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
- data/rspec-core.gemspec +3 -5
- data/spec/autotest/failed_results_re_spec.rb +2 -2
- data/spec/rspec/core/command_line_spec.rb +36 -2
- data/spec/rspec/core/configuration_spec.rb +150 -70
- data/spec/rspec/core/deprecations_spec.rb +21 -0
- data/spec/rspec/core/drb_command_line_spec.rb +21 -56
- data/spec/rspec/core/example_group_spec.rb +213 -56
- data/spec/rspec/core/example_spec.rb +110 -0
- data/spec/rspec/core/formatters/base_formatter_spec.rb +23 -2
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +9 -0
- data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +8 -10
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.1.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +5 -5
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -1
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +8 -10
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +5 -5
- data/spec/rspec/core/hooks_spec.rb +86 -0
- data/spec/rspec/core/metadata_spec.rb +7 -7
- data/spec/rspec/core/option_parser_spec.rb +26 -15
- data/spec/rspec/core/pending_example_spec.rb +12 -51
- data/spec/rspec/core/reporter_spec.rb +19 -3
- data/spec/rspec/core/resources/formatter_specs.rb +7 -1
- data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
- data/spec/rspec/core/runner_spec.rb +42 -10
- data/spec/rspec/core/shared_example_group_spec.rb +57 -21
- data/spec/rspec/core/subject_spec.rb +32 -11
- data/spec/rspec/core/world_spec.rb +147 -15
- data/spec/rspec/core_spec.rb +28 -0
- data/spec/spec_helper.rb +22 -2
- data/spec/support/matchers.rb +44 -13
- data/spec/support/shared_example_groups.rb +41 -0
- data/spec/support/spec_files.rb +44 -0
- data/spec.txt +1126 -0
- metadata +35 -16
- data/spec/ruby_forker.rb +0 -13
|
@@ -4,6 +4,9 @@ Feature: inclusion filters
|
|
|
4
4
|
most common use case is to focus on a subset of examples as you're focused on
|
|
5
5
|
a particular problem.
|
|
6
6
|
|
|
7
|
+
If you set the `treat_symbols_as_metadata_keys_with_true_values` config option
|
|
8
|
+
to `true`, you can specify metadata using only symbols.
|
|
9
|
+
|
|
7
10
|
Background:
|
|
8
11
|
Given a file named "spec/spec_helper.rb" with:
|
|
9
12
|
"""
|
|
@@ -26,7 +29,7 @@ Feature: inclusion filters
|
|
|
26
29
|
end
|
|
27
30
|
end
|
|
28
31
|
"""
|
|
29
|
-
When I run
|
|
32
|
+
When I run `rspec spec/sample_spec.rb --format doc`
|
|
30
33
|
Then the output should contain "does another thing"
|
|
31
34
|
And the output should not contain "does one thing"
|
|
32
35
|
|
|
@@ -48,7 +51,7 @@ Feature: inclusion filters
|
|
|
48
51
|
end
|
|
49
52
|
end
|
|
50
53
|
"""
|
|
51
|
-
When I run
|
|
54
|
+
When I run `rspec spec/sample_spec.rb --format doc`
|
|
52
55
|
Then the output should contain "group 1 example 1"
|
|
53
56
|
And the output should contain "group 1 example 2"
|
|
54
57
|
And the output should not contain "group 2 example 1"
|
|
@@ -76,8 +79,28 @@ Feature: inclusion filters
|
|
|
76
79
|
end
|
|
77
80
|
end
|
|
78
81
|
"""
|
|
79
|
-
When I run
|
|
82
|
+
When I run `rspec ./spec/before_after_all_inclusion_filter_spec.rb`
|
|
80
83
|
Then the output should contain "before all in focused group"
|
|
81
84
|
And the output should contain "after all in focused group"
|
|
82
85
|
And the output should not contain "before all in unfocused group"
|
|
83
86
|
And the output should not contain "after all in unfocused group"
|
|
87
|
+
|
|
88
|
+
Scenario: Use symbols as metadata
|
|
89
|
+
Given a file named "symbols_as_metadata_spec.rb" with:
|
|
90
|
+
"""
|
|
91
|
+
RSpec.configure do |c|
|
|
92
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
|
93
|
+
c.filter_run :current_example
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe "something" do
|
|
97
|
+
it "does one thing" do
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "does another thing", :current_example do
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
"""
|
|
104
|
+
When I run `rspec symbols_as_metadata_spec.rb --format doc`
|
|
105
|
+
Then the output should contain "does another thing"
|
|
106
|
+
And the output should not contain "does one thing"
|
|
@@ -31,8 +31,8 @@ Feature: run all when everything filtered
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
"""
|
|
34
|
-
When I run
|
|
35
|
-
Then the output should contain "No examples
|
|
34
|
+
When I run `rspec spec/sample_spec.rb --format doc`
|
|
35
|
+
Then the output should contain "No examples matched {:focus=>true}"
|
|
36
36
|
And the examples should all pass
|
|
37
37
|
And the output should contain:
|
|
38
38
|
"""
|
|
@@ -31,6 +31,6 @@ Feature: custom formatters
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
"""
|
|
34
|
-
When I run
|
|
34
|
+
When I run `rspec example_spec.rb --require ./custom_formatter.rb --format CustomFormatter`
|
|
35
35
|
Then the output should contain "example: my example"
|
|
36
36
|
And the exit status should be 0
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Feature: text formatter
|
|
2
|
+
|
|
3
|
+
In order to easily see the result of running my specs
|
|
4
|
+
As an RSpec user
|
|
5
|
+
I want clear, concise, well-formatted output
|
|
6
|
+
|
|
7
|
+
Scenario: Backtrace formatting for failing specs in multiple files
|
|
8
|
+
Given a file named "string_spec.rb" with:
|
|
9
|
+
"""
|
|
10
|
+
describe String do
|
|
11
|
+
it "has a failing example" do
|
|
12
|
+
"foo".reverse.should == "ofo"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
"""
|
|
16
|
+
And a file named "integer_spec.rb" with:
|
|
17
|
+
"""
|
|
18
|
+
require 'rspec/autorun'
|
|
19
|
+
|
|
20
|
+
describe Integer do
|
|
21
|
+
it "has a failing example" do
|
|
22
|
+
(7 + 5).should == 11
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
"""
|
|
26
|
+
When I run `ruby ./integer_spec.rb ./string_spec.rb`
|
|
27
|
+
Then the backtrace-normalized output should contain:
|
|
28
|
+
"""
|
|
29
|
+
Failures:
|
|
30
|
+
|
|
31
|
+
1) Integer has a failing example
|
|
32
|
+
Failure/Error: (7 + 5).should == 11
|
|
33
|
+
expected: 11
|
|
34
|
+
got: 12 (using ==)
|
|
35
|
+
# ./integer_spec.rb:5
|
|
36
|
+
|
|
37
|
+
2) String has a failing example
|
|
38
|
+
Failure/Error: "foo".reverse.should == "ofo"
|
|
39
|
+
expected: "ofo"
|
|
40
|
+
got: "oof" (using ==)
|
|
41
|
+
# ./string_spec.rb:3
|
|
42
|
+
"""
|
|
43
|
+
|
|
@@ -18,7 +18,7 @@ Feature: arbitrary helper methods
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
"""
|
|
21
|
-
When I run
|
|
21
|
+
When I run `rspec example_spec.rb`
|
|
22
22
|
Then the examples should all pass
|
|
23
23
|
|
|
24
24
|
Scenario: use a method defined in a parent group
|
|
@@ -36,5 +36,5 @@ Feature: arbitrary helper methods
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
"""
|
|
39
|
-
When I run
|
|
39
|
+
When I run `rspec example_spec.rb`
|
|
40
40
|
Then the examples should all pass
|
|
@@ -24,7 +24,7 @@ Feature: let and let!
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
"""
|
|
27
|
-
When I run
|
|
27
|
+
When I run `rspec let_spec.rb`
|
|
28
28
|
Then the examples should all pass
|
|
29
29
|
|
|
30
30
|
Scenario: use let! to define a memoized helper method that is called in a before hook
|
|
@@ -46,5 +46,5 @@ Feature: let and let!
|
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
"""
|
|
49
|
-
When I run
|
|
49
|
+
When I run `rspec let_bang_spec.rb`
|
|
50
50
|
Then the examples should all pass
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
Feature: Define helper methods in a module
|
|
2
|
+
|
|
3
|
+
You can define helper methods in a module and include it in
|
|
4
|
+
your example groups using the `config.include` configuration
|
|
5
|
+
option. `config.extend` can be used to extend the module onto
|
|
6
|
+
your example groups so that the methods in the module are available
|
|
7
|
+
in the example groups themselves (but not in the actual examples).
|
|
8
|
+
|
|
9
|
+
You can also include or extend the module onto only certain example
|
|
10
|
+
groups by passing a metadata hash as the last argument. Only groups
|
|
11
|
+
that match the given metadata will include or extend the module.
|
|
12
|
+
|
|
13
|
+
If you set the `treat_symbols_as_metadata_keys_with_true_values` config option
|
|
14
|
+
to `true`, you can specify metadata using only symbols.
|
|
15
|
+
|
|
16
|
+
Background:
|
|
17
|
+
Given a file named "helpers.rb" with:
|
|
18
|
+
"""
|
|
19
|
+
module Helpers
|
|
20
|
+
def help
|
|
21
|
+
:available
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
Scenario: include a module in all example groups
|
|
27
|
+
Given a file named "include_module_spec.rb" with:
|
|
28
|
+
"""
|
|
29
|
+
require './helpers'
|
|
30
|
+
|
|
31
|
+
RSpec.configure do |c|
|
|
32
|
+
c.include Helpers
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "an example group" do
|
|
36
|
+
it "has access the helper methods defined in the module" do
|
|
37
|
+
help.should be(:available)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
"""
|
|
41
|
+
When I run `rspec include_module_spec.rb`
|
|
42
|
+
Then the examples should all pass
|
|
43
|
+
|
|
44
|
+
Scenario: extend a module in all example groups
|
|
45
|
+
Given a file named "extend_module_spec.rb" with:
|
|
46
|
+
"""
|
|
47
|
+
require './helpers'
|
|
48
|
+
|
|
49
|
+
RSpec.configure do |c|
|
|
50
|
+
c.extend Helpers
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe "an example group" do
|
|
54
|
+
puts "Help is #{help}"
|
|
55
|
+
|
|
56
|
+
it "does not have access to the helper methods defined in the module" do
|
|
57
|
+
expect { help }.to raise_error(NameError)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
"""
|
|
61
|
+
When I run `rspec extend_module_spec.rb`
|
|
62
|
+
Then the examples should all pass
|
|
63
|
+
And the output should contain "Help is available"
|
|
64
|
+
|
|
65
|
+
Scenario: include a module in only some example groups
|
|
66
|
+
Given a file named "include_module_in_some_groups_spec.rb" with:
|
|
67
|
+
"""
|
|
68
|
+
require './helpers'
|
|
69
|
+
|
|
70
|
+
RSpec.configure do |c|
|
|
71
|
+
c.include Helpers, :foo => :bar
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe "an example group with matching metadata", :foo => :bar do
|
|
75
|
+
it "has access the helper methods defined in the module" do
|
|
76
|
+
help.should be(:available)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe "an example group without matching metadata" do
|
|
81
|
+
it "does not have access to the helper methods defined in the module" do
|
|
82
|
+
expect { help }.to raise_error(NameError)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
"""
|
|
86
|
+
When I run `rspec include_module_in_some_groups_spec.rb`
|
|
87
|
+
Then the examples should all pass
|
|
88
|
+
|
|
89
|
+
Scenario: extend a module in only some example groups
|
|
90
|
+
Given a file named "extend_module_in_only_some_groups_spec.rb" with:
|
|
91
|
+
"""
|
|
92
|
+
require './helpers'
|
|
93
|
+
|
|
94
|
+
RSpec.configure do |c|
|
|
95
|
+
c.extend Helpers, :foo => :bar
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe "an example group with matching metadata", :foo => :bar do
|
|
99
|
+
puts "In a matching group, help is #{help}"
|
|
100
|
+
|
|
101
|
+
it "does not have access to the helper methods defined in the module" do
|
|
102
|
+
expect { help }.to raise_error(NameError)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe "an example group without matching metadata" do
|
|
107
|
+
puts "In a non-matching group, help is #{help rescue 'not available'}"
|
|
108
|
+
|
|
109
|
+
it "does not have access to the helper methods defined in the module" do
|
|
110
|
+
expect { help }.to raise_error(NameError)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
"""
|
|
114
|
+
When I run `rspec extend_module_in_only_some_groups_spec.rb`
|
|
115
|
+
Then the examples should all pass
|
|
116
|
+
And the output should contain "In a matching group, help is available"
|
|
117
|
+
And the output should contain "In a non-matching group, help is not available"
|
|
118
|
+
|
|
119
|
+
Scenario: use symbols as metadata
|
|
120
|
+
Given a file named "symbols_as_metadata_spec.rb" with:
|
|
121
|
+
"""
|
|
122
|
+
require './helpers'
|
|
123
|
+
|
|
124
|
+
RSpec.configure do |c|
|
|
125
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
|
126
|
+
c.include Helpers, :include_helpers
|
|
127
|
+
c.extend Helpers, :extend_helpers
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
describe "an example group with matching include metadata", :include_helpers do
|
|
131
|
+
puts "In a group not matching the extend filter, help is #{help rescue 'not available'}"
|
|
132
|
+
|
|
133
|
+
it "has access the helper methods defined in the module" do
|
|
134
|
+
help.should be(:available)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
describe "an example group with matching extend metadata", :extend_helpers do
|
|
139
|
+
puts "In a group matching the extend filter, help is #{help}"
|
|
140
|
+
|
|
141
|
+
it "does not have access to the helper methods defined in the module" do
|
|
142
|
+
expect { help }.to raise_error(NameError)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
"""
|
|
146
|
+
When I run `rspec symbols_as_metadata_spec.rb`
|
|
147
|
+
Then the examples should all pass
|
|
148
|
+
And the output should contain "In a group not matching the extend filter, help is not available"
|
|
149
|
+
And the output should contain "In a group matching the extend filter, help is available"
|
|
@@ -9,6 +9,13 @@ Feature: around hooks
|
|
|
9
9
|
example, if your database library offers a transaction method that receives
|
|
10
10
|
a block, you can use an around hook as described in the first scenario:
|
|
11
11
|
|
|
12
|
+
WARNING: around hooks do not share state with the example the way before and
|
|
13
|
+
after hooks do. This means that you can not share instance variables between
|
|
14
|
+
around hooks and examples.
|
|
15
|
+
|
|
16
|
+
Also, mock frameworks are set up and torn down within the context of running
|
|
17
|
+
the example, so you can not interact with them directly in around hooks.
|
|
18
|
+
|
|
12
19
|
Scenario: use the example as a proc within the block passed to around()
|
|
13
20
|
Given a file named "example_spec.rb" with:
|
|
14
21
|
"""
|
|
@@ -30,7 +37,7 @@ Feature: around hooks
|
|
|
30
37
|
end
|
|
31
38
|
end
|
|
32
39
|
"""
|
|
33
|
-
When I run
|
|
40
|
+
When I run `rspec example_spec.rb`
|
|
34
41
|
Then the output should contain:
|
|
35
42
|
"""
|
|
36
43
|
open transaction
|
|
@@ -53,7 +60,7 @@ Feature: around hooks
|
|
|
53
60
|
end
|
|
54
61
|
end
|
|
55
62
|
"""
|
|
56
|
-
When I run
|
|
63
|
+
When I run `rspec example_spec.rb`
|
|
57
64
|
Then the output should contain:
|
|
58
65
|
"""
|
|
59
66
|
around each before
|
|
@@ -74,7 +81,7 @@ Feature: around hooks
|
|
|
74
81
|
end
|
|
75
82
|
end
|
|
76
83
|
"""
|
|
77
|
-
When I run
|
|
84
|
+
When I run `rspec example_spec.rb`
|
|
78
85
|
Then the output should contain "this should show up in the output"
|
|
79
86
|
|
|
80
87
|
Scenario: define a global around hook
|
|
@@ -94,7 +101,7 @@ Feature: around hooks
|
|
|
94
101
|
end
|
|
95
102
|
end
|
|
96
103
|
"""
|
|
97
|
-
When I run
|
|
104
|
+
When I run `rspec example_spec.rb`
|
|
98
105
|
Then the output should contain:
|
|
99
106
|
"""
|
|
100
107
|
around each before
|
|
@@ -125,7 +132,7 @@ Feature: around hooks
|
|
|
125
132
|
end
|
|
126
133
|
end
|
|
127
134
|
"""
|
|
128
|
-
When I run
|
|
135
|
+
When I run `rspec example_spec.rb`
|
|
129
136
|
Then the output should contain:
|
|
130
137
|
"""
|
|
131
138
|
around each before
|
|
@@ -158,7 +165,7 @@ Feature: around hooks
|
|
|
158
165
|
end
|
|
159
166
|
end
|
|
160
167
|
"""
|
|
161
|
-
When I run
|
|
168
|
+
When I run `rspec example_spec.rb`
|
|
162
169
|
Then the output should contain:
|
|
163
170
|
"""
|
|
164
171
|
before all
|
|
@@ -189,7 +196,7 @@ Feature: around hooks
|
|
|
189
196
|
end
|
|
190
197
|
end
|
|
191
198
|
"""
|
|
192
|
-
When I run
|
|
199
|
+
When I run `rspec example_spec.rb`
|
|
193
200
|
Then the output should contain "1 example, 0 failure"
|
|
194
201
|
|
|
195
202
|
Scenario: implicitly pending examples are detected as Not Yet Implemented
|
|
@@ -203,7 +210,7 @@ Feature: around hooks
|
|
|
203
210
|
it "should be detected as Not Yet Implemented"
|
|
204
211
|
end
|
|
205
212
|
"""
|
|
206
|
-
When I run
|
|
213
|
+
When I run `rspec example_spec.rb`
|
|
207
214
|
Then the output should contain "1 example, 0 failures, 1 pending"
|
|
208
215
|
And the output should contain:
|
|
209
216
|
"""
|
|
@@ -226,7 +233,7 @@ Feature: around hooks
|
|
|
226
233
|
end
|
|
227
234
|
end
|
|
228
235
|
"""
|
|
229
|
-
When I run
|
|
236
|
+
When I run `rspec example_spec.rb`
|
|
230
237
|
Then the output should contain "1 example, 0 failures, 1 pending"
|
|
231
238
|
And the output should contain:
|
|
232
239
|
"""
|
|
@@ -256,7 +263,7 @@ Feature: around hooks
|
|
|
256
263
|
end
|
|
257
264
|
end
|
|
258
265
|
"""
|
|
259
|
-
When I run
|
|
266
|
+
When I run `rspec example_spec.rb`
|
|
260
267
|
Then the output should contain "1 example, 0 failure"
|
|
261
268
|
And the output should contain:
|
|
262
269
|
"""
|
|
@@ -316,7 +323,7 @@ Feature: around hooks
|
|
|
316
323
|
end
|
|
317
324
|
end
|
|
318
325
|
"""
|
|
319
|
-
When I run
|
|
326
|
+
When I run `rspec example_spec.rb`
|
|
320
327
|
Then the output should contain "1 example, 0 failure"
|
|
321
328
|
And the output should contain:
|
|
322
329
|
"""
|
|
@@ -52,7 +52,7 @@ Feature: before and after hooks
|
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
"""
|
|
55
|
-
When I run
|
|
55
|
+
When I run `rspec before_each_spec.rb`
|
|
56
56
|
Then the examples should all pass
|
|
57
57
|
|
|
58
58
|
Scenario: define before(:all) block in example group
|
|
@@ -86,10 +86,10 @@ Feature: before and after hooks
|
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
"""
|
|
89
|
-
When I run
|
|
89
|
+
When I run `rspec before_all_spec.rb`
|
|
90
90
|
Then the examples should all pass
|
|
91
91
|
|
|
92
|
-
When I run
|
|
92
|
+
When I run `rspec before_all_spec.rb:15`
|
|
93
93
|
Then the examples should all pass
|
|
94
94
|
|
|
95
95
|
Scenario: failure in before(:all) block
|
|
@@ -124,7 +124,7 @@ Feature: before and after hooks
|
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
"""
|
|
127
|
-
When I run
|
|
127
|
+
When I run `rspec before_all_spec.rb --format documentation`
|
|
128
128
|
Then the output should contain "5 examples, 5 failures"
|
|
129
129
|
And the output should contain:
|
|
130
130
|
"""
|
|
@@ -139,15 +139,12 @@ Feature: before and after hooks
|
|
|
139
139
|
after all ran
|
|
140
140
|
"""
|
|
141
141
|
|
|
142
|
-
When I run
|
|
142
|
+
When I run `rspec before_all_spec.rb:9 --format documentation`
|
|
143
143
|
Then the output should contain "1 example, 1 failure"
|
|
144
144
|
And the output should contain:
|
|
145
145
|
"""
|
|
146
146
|
an error in before(:all)
|
|
147
147
|
fails this example, too (FAILED - 1)
|
|
148
|
-
nested group
|
|
149
|
-
yet another level deep
|
|
150
|
-
after all ran
|
|
151
148
|
"""
|
|
152
149
|
|
|
153
150
|
Scenario: failure in after(:all) block
|
|
@@ -165,7 +162,7 @@ Feature: before and after hooks
|
|
|
165
162
|
end
|
|
166
163
|
end
|
|
167
164
|
"""
|
|
168
|
-
When I run
|
|
165
|
+
When I run `rspec after_all_spec.rb`
|
|
169
166
|
Then the examples should all pass
|
|
170
167
|
And the output should contain:
|
|
171
168
|
"""
|
|
@@ -200,7 +197,7 @@ Feature: before and after hooks
|
|
|
200
197
|
end
|
|
201
198
|
end
|
|
202
199
|
"""
|
|
203
|
-
When I run
|
|
200
|
+
When I run `rspec befores_in_configuration_spec.rb`
|
|
204
201
|
Then the examples should all pass
|
|
205
202
|
|
|
206
203
|
Scenario: before/after blocks are run in order
|
|
@@ -230,7 +227,7 @@ Feature: before and after hooks
|
|
|
230
227
|
end
|
|
231
228
|
end
|
|
232
229
|
"""
|
|
233
|
-
When I run
|
|
230
|
+
When I run `rspec ensure_block_order_spec.rb`
|
|
234
231
|
Then the output should contain:
|
|
235
232
|
"""
|
|
236
233
|
before all
|
|
@@ -275,7 +272,7 @@ Feature: before and after hooks
|
|
|
275
272
|
end
|
|
276
273
|
end
|
|
277
274
|
"""
|
|
278
|
-
When I run
|
|
275
|
+
When I run `rspec configuration_spec.rb`
|
|
279
276
|
Then the output should contain:
|
|
280
277
|
"""
|
|
281
278
|
before suite
|
|
@@ -316,7 +313,7 @@ Feature: before and after hooks
|
|
|
316
313
|
|
|
317
314
|
end
|
|
318
315
|
"""
|
|
319
|
-
When I run
|
|
316
|
+
When I run `rspec before_and_after_all_spec.rb`
|
|
320
317
|
Then the examples should all pass
|
|
321
318
|
And the output should contain:
|
|
322
319
|
"""
|
|
@@ -326,7 +323,7 @@ Feature: before and after hooks
|
|
|
326
323
|
outer after all
|
|
327
324
|
"""
|
|
328
325
|
|
|
329
|
-
When I run
|
|
326
|
+
When I run `rspec before_and_after_all_spec.rb:14`
|
|
330
327
|
Then the examples should all pass
|
|
331
328
|
And the output should contain:
|
|
332
329
|
"""
|
|
@@ -336,7 +333,7 @@ Feature: before and after hooks
|
|
|
336
333
|
outer after all
|
|
337
334
|
"""
|
|
338
335
|
|
|
339
|
-
When I run
|
|
336
|
+
When I run `rspec before_and_after_all_spec.rb:6`
|
|
340
337
|
Then the examples should all pass
|
|
341
338
|
And the output should contain:
|
|
342
339
|
"""
|
|
@@ -371,7 +368,7 @@ Feature: before and after hooks
|
|
|
371
368
|
end
|
|
372
369
|
end
|
|
373
370
|
"""
|
|
374
|
-
When I run
|
|
371
|
+
When I run `rspec before_all_spec.rb`
|
|
375
372
|
Then the examples should all pass
|
|
376
373
|
|
|
377
374
|
Scenario: before/after all blocks have access to state
|
|
@@ -402,12 +399,11 @@ Feature: before and after hooks
|
|
|
402
399
|
end
|
|
403
400
|
|
|
404
401
|
after(:all) do
|
|
405
|
-
# p @outer_state.nil?
|
|
406
402
|
@outer_state.should eq("set in outer before all")
|
|
407
403
|
end
|
|
408
404
|
end
|
|
409
405
|
"""
|
|
410
|
-
When I run
|
|
406
|
+
When I run `rspec before_and_after_all_spec.rb`
|
|
411
407
|
Then the examples should all pass
|
|
412
408
|
|
|
413
409
|
Scenario: exception in before(:each) is captured and reported as failure
|
|
@@ -422,6 +418,6 @@ Feature: before and after hooks
|
|
|
422
418
|
end
|
|
423
419
|
end
|
|
424
420
|
"""
|
|
425
|
-
When I run
|
|
421
|
+
When I run `rspec error_in_before_each_spec.rb`
|
|
426
422
|
Then the output should contain "1 example, 1 failure"
|
|
427
423
|
And the output should contain "this error"
|