rspec-core 2.12.2 → 2.13.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/Changelog.md +31 -0
- data/README.md +11 -10
- data/features/command_line/example_name_option.feature +6 -10
- data/features/command_line/tag.feature +15 -8
- data/features/configuration/backtrace_clean_patterns.feature +102 -0
- data/features/configuration/failure_exit_code.feature +36 -0
- data/features/configuration/order_and_seed.feature +3 -0
- data/features/configuration/output_stream.feature +24 -0
- data/features/configuration/pattern.feature +30 -0
- data/features/configuration/profile.feature +163 -0
- data/features/configuration/run_all_when_everything_filtered.feature +60 -0
- data/features/configuration/show_failures_in_pending_blocks.feature +61 -0
- data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +52 -0
- data/features/filtering/exclusion_filters.feature +1 -2
- data/features/formatters/configurable_colors.feature +31 -0
- data/features/step_definitions/additional_cli_steps.rb +21 -0
- data/features/subject/explicit_subject.feature +19 -0
- data/lib/autotest/rspec2.rb +1 -1
- data/lib/rspec/core.rb +1 -2
- data/lib/rspec/core/configuration.rb +33 -3
- data/lib/rspec/core/configuration_options.rb +5 -5
- data/lib/rspec/core/deprecation.rb +1 -1
- data/lib/rspec/core/example.rb +2 -2
- data/lib/rspec/core/example_group.rb +1 -3
- data/lib/rspec/core/formatters/base_text_formatter.rb +93 -27
- data/lib/rspec/core/formatters/documentation_formatter.rb +3 -3
- data/lib/rspec/core/formatters/progress_formatter.rb +3 -3
- data/lib/rspec/core/memoized_helpers.rb +425 -0
- data/lib/rspec/core/metadata.rb +6 -2
- data/lib/rspec/core/option_parser.rb +8 -2
- data/lib/rspec/core/pending.rb +7 -0
- data/lib/rspec/core/shared_context.rb +1 -1
- data/lib/rspec/core/version.rb +1 -1
- data/spec/autotest/failed_results_re_spec.rb +4 -4
- data/spec/autotest/rspec_spec.rb +25 -20
- data/spec/command_line/order_spec.rb +21 -21
- data/spec/rspec/core/command_line_spec.rb +6 -6
- data/spec/rspec/core/configuration_options_spec.rb +86 -72
- data/spec/rspec/core/configuration_spec.rb +161 -156
- data/spec/rspec/core/deprecations_spec.rb +4 -4
- data/spec/rspec/core/drb_command_line_spec.rb +9 -9
- data/spec/rspec/core/drb_options_spec.rb +46 -33
- data/spec/rspec/core/dsl_spec.rb +3 -3
- data/spec/rspec/core/example_group_spec.rb +156 -124
- data/spec/rspec/core/example_spec.rb +68 -52
- data/spec/rspec/core/filter_manager_spec.rb +36 -36
- data/spec/rspec/core/formatters/base_formatter_spec.rb +9 -9
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +104 -42
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +4 -4
- data/spec/rspec/core/formatters/helpers_spec.rb +13 -13
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +5 -17
- data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +159 -44
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +14 -14
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +20 -20
- data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +159 -44
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +20 -20
- data/spec/rspec/core/formatters/{html_formatted-1.9.2-jruby.html → html_formatted-2.0.0.html} +24 -18
- data/spec/rspec/core/formatters/html_formatter_spec.rb +9 -5
- data/spec/rspec/core/formatters/json_formatter_spec.rb +9 -9
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +4 -4
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +3 -3
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +5 -17
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-rbx.html +159 -44
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +16 -16
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +23 -23
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-jruby.html +5 -17
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-rbx.html +159 -44
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +23 -23
- data/spec/rspec/core/formatters/{text_mate_formatted-1.9.2-jruby.html → text_mate_formatted-2.0.0.html} +25 -19
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +8 -4
- data/spec/rspec/core/hooks_filtering_spec.rb +16 -16
- data/spec/rspec/core/hooks_spec.rb +11 -11
- data/spec/rspec/core/kernel_extensions_spec.rb +1 -1
- data/spec/rspec/core/memoized_helpers_spec.rb +458 -0
- data/spec/rspec/core/metadata_spec.rb +74 -74
- data/spec/rspec/core/option_parser_spec.rb +27 -27
- data/spec/rspec/core/pending_example_spec.rb +32 -32
- data/spec/rspec/core/project_initializer_spec.rb +8 -8
- data/spec/rspec/core/rake_task_spec.rb +16 -16
- data/spec/rspec/core/reporter_spec.rb +3 -3
- data/spec/rspec/core/resources/formatter_specs.rb +4 -4
- data/spec/rspec/core/ruby_project_spec.rb +4 -2
- data/spec/rspec/core/shared_context_spec.rb +34 -7
- data/spec/rspec/core/shared_example_group_spec.rb +14 -14
- data/spec/rspec/core/world_spec.rb +9 -9
- data/spec/rspec/core_spec.rb +5 -5
- data/spec/spec_helper.rb +4 -0
- data/spec/support/shared_example_groups.rb +4 -4
- data/spec/support/spec_files.rb +2 -2
- metadata +158 -150
- data/lib/rspec/core/let.rb +0 -110
- data/lib/rspec/core/subject.rb +0 -223
- data/spec/rspec/core/let_spec.rb +0 -55
- data/spec/rspec/core/subject_spec.rb +0 -255
data/Changelog.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
### 2.13.0 / 2013-02-23
|
|
2
|
+
[full changelog](http://github.com/rspec/rspec-core/compare/v2.12.2...v2.13.0)
|
|
3
|
+
|
|
4
|
+
Enhancements
|
|
5
|
+
|
|
6
|
+
* Allow `--profile` option to take a count argument that
|
|
7
|
+
determines the number of slow examples to dump
|
|
8
|
+
(Greggory Rothmeier).
|
|
9
|
+
* Add `subject!` that is the analog to `let!`. It defines an
|
|
10
|
+
explicit subject and sets a `before` hook that will invoke
|
|
11
|
+
the subject (Zubin Henner).
|
|
12
|
+
* Fix `let` and `subject` declaration so that `super`
|
|
13
|
+
and `return` can be used in them, just like in a normal
|
|
14
|
+
method. (Myron Marston)
|
|
15
|
+
* Allow output colors to be configured individually.
|
|
16
|
+
(Charlie Maffitt)
|
|
17
|
+
|
|
18
|
+
Bug fixes
|
|
19
|
+
|
|
20
|
+
* Don't blow up when dumping error output for instances
|
|
21
|
+
of anonymous error classes (Myron Marston).
|
|
22
|
+
* Fix default backtrace filters so lines from projects
|
|
23
|
+
containing "gems" in the name are not filtered, but
|
|
24
|
+
lines from installed gems still are (Myron Marston).
|
|
25
|
+
* Fix autotest command so that is uses double quotes
|
|
26
|
+
rather than single quotes for windows compatibility
|
|
27
|
+
(Jonas Tingeborn).
|
|
28
|
+
* Fix `its` so that uses of `subject` in a `before` or `let`
|
|
29
|
+
declaration in the parent group continue to reference the
|
|
30
|
+
parent group's subject. (Olek Janiszewski)
|
|
31
|
+
|
|
1
32
|
### 2.12.2 / 2012-12-13
|
|
2
33
|
[full changelog](http://github.com/rspec/rspec-core/compare/v2.12.1...v2.12.2)
|
|
3
34
|
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# rspec-core [](http://travis-ci.org/rspec/rspec-core) [](http://travis-ci.org/rspec/rspec-core) [](https://codeclimate.com/github/rspec/rspec-core)
|
|
2
2
|
|
|
3
3
|
rspec-core provides the structure for writing executable examples of how your
|
|
4
4
|
code should behave, and an `rspec` command with tools to constrain which
|
|
@@ -28,7 +28,7 @@ describe Order do
|
|
|
28
28
|
:price => Money.new(2.22, :USD),
|
|
29
29
|
:quantity => 2
|
|
30
30
|
)))
|
|
31
|
-
order.total.
|
|
31
|
+
expect(order.total).to eq(Money.new(5.55, :USD))
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
```
|
|
@@ -77,7 +77,7 @@ in any group using `include_examples`.
|
|
|
77
77
|
```ruby
|
|
78
78
|
shared_examples "collections" do |collection_class|
|
|
79
79
|
it "is empty when first created" do
|
|
80
|
-
collection_class.new.
|
|
80
|
+
expect(collection_class.new).to be_empty
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
@@ -102,7 +102,7 @@ etc, but no examples.
|
|
|
102
102
|
## metadata
|
|
103
103
|
|
|
104
104
|
rspec-core stores a metadata hash with every example and group, which
|
|
105
|
-
contains
|
|
105
|
+
contains their descriptions, the locations at which they were
|
|
106
106
|
declared, etc, etc. This hash powers many of rspec-core's features,
|
|
107
107
|
including output formatters (which access descriptions and locations),
|
|
108
108
|
and filtering before and after hooks.
|
|
@@ -112,7 +112,7 @@ extension, you can access it from an example like this:
|
|
|
112
112
|
|
|
113
113
|
```ruby
|
|
114
114
|
it "does something" do
|
|
115
|
-
example.metadata[:description].
|
|
115
|
+
expect(example.metadata[:description]).to eq("does something")
|
|
116
116
|
end
|
|
117
117
|
```
|
|
118
118
|
|
|
@@ -125,19 +125,19 @@ using the `described_class` method, which is a wrapper for
|
|
|
125
125
|
```ruby
|
|
126
126
|
describe Widget do
|
|
127
127
|
example do
|
|
128
|
-
described_class.
|
|
128
|
+
expect(described_class).to equal(Widget)
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
```
|
|
132
132
|
|
|
133
133
|
This is useful in extensions or shared example groups in which the specific
|
|
134
|
-
class is unknown. Taking the shared
|
|
134
|
+
class is unknown. Taking the collections shared example group from above, we can
|
|
135
135
|
clean it up a bit using `described_class`:
|
|
136
136
|
|
|
137
137
|
```ruby
|
|
138
138
|
shared_examples "collections" do
|
|
139
139
|
it "is empty when first created" do
|
|
140
|
-
|
|
140
|
+
expect(described_class.new).to be_empty
|
|
141
141
|
end
|
|
142
142
|
end
|
|
143
143
|
|
|
@@ -153,7 +153,8 @@ end
|
|
|
153
153
|
## the `rspec` command
|
|
154
154
|
|
|
155
155
|
When you install the rspec-core gem, it installs the `rspec` executable,
|
|
156
|
-
which you'll use to run rspec. The `rspec` comes with many useful
|
|
156
|
+
which you'll use to run rspec. The `rspec` command comes with many useful
|
|
157
|
+
options.
|
|
157
158
|
Run `rspec --help` to see the complete list.
|
|
158
159
|
|
|
159
160
|
## store command line options `.rspec`
|
|
@@ -198,7 +199,7 @@ this before you write any implementation code:
|
|
|
198
199
|
# in spec/calculator_spec.rb
|
|
199
200
|
describe Calculator do
|
|
200
201
|
it "add(x,y) returns the sum of its arguments" do
|
|
201
|
-
Calculator.new.add(1, 2).
|
|
202
|
+
expect(Calculator.new.add(1, 2)).to eq(3)
|
|
202
203
|
end
|
|
203
204
|
end
|
|
204
205
|
```
|
|
@@ -2,13 +2,13 @@ Feature: --example option
|
|
|
2
2
|
|
|
3
3
|
Use the --example (or -e) option to filter examples by name.
|
|
4
4
|
|
|
5
|
-
The argument is
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
The argument is matched against the full description of the example,
|
|
6
|
+
which is the concatenation of descriptions of the group (including
|
|
7
|
+
any nested groups) and the example.
|
|
8
8
|
|
|
9
9
|
This allows you to run a single uniquely named example, all examples with
|
|
10
10
|
similar names, all the examples in a uniquely named group, etc, etc.
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
You can also use the option more than once to specify multiple example matches.
|
|
13
13
|
|
|
14
14
|
Background:
|
|
@@ -49,7 +49,7 @@ Feature: --example option
|
|
|
49
49
|
|
|
50
50
|
Scenario: no matches
|
|
51
51
|
When I run `rspec . --example nothing_like_this`
|
|
52
|
-
Then the
|
|
52
|
+
Then the process should succeed even though no examples were run
|
|
53
53
|
|
|
54
54
|
Scenario: match on one word
|
|
55
55
|
When I run `rspec . --example example`
|
|
@@ -67,10 +67,6 @@ Feature: --example option
|
|
|
67
67
|
When I run `rspec . --example 'first group first example in first group'`
|
|
68
68
|
Then the examples should all pass
|
|
69
69
|
|
|
70
|
-
Scenario: one match in one file using regexp
|
|
71
|
-
When I run `rspec . --example 'first .* first example'`
|
|
72
|
-
Then the examples should all pass
|
|
73
|
-
|
|
74
70
|
Scenario: all examples in one group
|
|
75
71
|
When I run `rspec . --example 'first group'`
|
|
76
72
|
Then the examples should all pass
|
|
@@ -86,7 +82,7 @@ Feature: --example option
|
|
|
86
82
|
Scenario: Object#method
|
|
87
83
|
When I run `rspec . --example 'Array#length'`
|
|
88
84
|
Then the examples should all pass
|
|
89
|
-
|
|
85
|
+
|
|
90
86
|
Scenario: Multiple applications of example name option
|
|
91
87
|
When I run `rspec . --example 'first group' --example 'second group' --format d`
|
|
92
88
|
Then the examples should all pass
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
Feature: --tag option
|
|
2
2
|
|
|
3
3
|
Use the --tag (or -t) option to filter the examples by tags.
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
The tag can be a simple name or a name:value pair. In the first case,
|
|
6
6
|
examples with :name => true will be filtered. In the second case, examples
|
|
7
7
|
with :name => value will be filtered, where value is always a string. In
|
|
8
8
|
both cases, name is converted to a symbol.
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
Tags can also be used to exclude examples by adding a ~ before the tag. For
|
|
11
11
|
example ~tag will exclude all examples marked with :tag => true and
|
|
12
12
|
~tag:value will exclude all examples marked with :tag => value.
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
To be compatible with the Cucumber syntax, tags can optionally start with
|
|
15
15
|
an @ symbol, which will be ignored.
|
|
16
16
|
|
|
@@ -29,7 +29,7 @@ Feature: --tag option
|
|
|
29
29
|
|
|
30
30
|
Scenario: filter examples with non-existent tag
|
|
31
31
|
When I run `rspec . --tag mytag`
|
|
32
|
-
|
|
32
|
+
Then the process should succeed even though no examples were run
|
|
33
33
|
|
|
34
34
|
Scenario: filter examples with a simple tag
|
|
35
35
|
When I run `rspec . --tag focus`
|
|
@@ -49,7 +49,7 @@ Feature: --tag option
|
|
|
49
49
|
"""
|
|
50
50
|
And the output should contain "2 examples"
|
|
51
51
|
And the examples should all pass
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
Scenario: filter examples with a name:value tag and @
|
|
54
54
|
When I run `rspec . --tag @type:special`
|
|
55
55
|
Then the output should contain:
|
|
@@ -57,7 +57,7 @@ Feature: --tag option
|
|
|
57
57
|
include {:type=>"special"}
|
|
58
58
|
"""
|
|
59
59
|
And the examples should all pass
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
Scenario: exclude examples with a simple tag
|
|
62
62
|
When I run `rspec . --tag ~skip`
|
|
63
63
|
Then the output should contain "exclude {:skip=>true}"
|
|
@@ -67,7 +67,7 @@ Feature: --tag option
|
|
|
67
67
|
When I run `rspec . --tag ~@skip`
|
|
68
68
|
Then the output should contain "exclude {:skip=>true}"
|
|
69
69
|
Then the examples should all pass
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
Scenario: exclude examples with a name:value tag
|
|
72
72
|
When I run `rspec . --tag ~speed:slow`
|
|
73
73
|
Then the output should contain:
|
|
@@ -75,7 +75,7 @@ Feature: --tag option
|
|
|
75
75
|
exclude {:speed=>"slow"}
|
|
76
76
|
"""
|
|
77
77
|
Then the examples should all pass
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
Scenario: exclude examples with a name:value tag and @
|
|
80
80
|
When I run `rspec . --tag ~@speed:slow`
|
|
81
81
|
Then the output should contain:
|
|
@@ -89,3 +89,10 @@ Feature: --tag option
|
|
|
89
89
|
Then the output should contain "include {:focus=>true}"
|
|
90
90
|
And the output should contain "exclude {:skip=>true}"
|
|
91
91
|
And the examples should all pass
|
|
92
|
+
|
|
93
|
+
Scenario: exclude examples with multiple tags
|
|
94
|
+
When I run `rspec . --tag ~skip --tag ~speed:slow`
|
|
95
|
+
Then the output should contain one of the following:
|
|
96
|
+
| exclude {:skip=>true, :speed=>"slow"} |
|
|
97
|
+
| exclude {:speed=>"slow", :skip=>true} |
|
|
98
|
+
Then the examples should all pass
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Feature: Backtrace cleaning
|
|
2
|
+
|
|
3
|
+
To aid in diagnozing spec failures, RSpec cleans matching lines from backtraces. The default patterns cleaned are:
|
|
4
|
+
|
|
5
|
+
/\/lib\d*\/ruby\//,
|
|
6
|
+
/org\/jruby\//,
|
|
7
|
+
/bin\//,
|
|
8
|
+
/gems/,
|
|
9
|
+
/spec\/spec_helper\.rb/,
|
|
10
|
+
/lib\/rspec\/(core|expectations|matchers|mocks)/
|
|
11
|
+
|
|
12
|
+
This list can be modified or replaced with the `backtrace_clean_patterns` option. Additionally, rspec can be run with the `--backtrace` option to skip backtrace cleaning entirely.
|
|
13
|
+
|
|
14
|
+
Scenario: default configuration
|
|
15
|
+
Given a file named "spec/failing_spec.rb" with:
|
|
16
|
+
"""ruby
|
|
17
|
+
describe "2 + 2" do
|
|
18
|
+
it "is 5" do
|
|
19
|
+
(2+2).should eq(5)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
"""
|
|
23
|
+
When I run `rspec`
|
|
24
|
+
Then the output should contain "1 example, 1 failure"
|
|
25
|
+
And the output should not contain "lib/rspec/expectations"
|
|
26
|
+
|
|
27
|
+
Scenario: With a custom setting for backtrace_clean_patterns
|
|
28
|
+
Given a file named "spec/spec_helper.rb" with:
|
|
29
|
+
"""ruby
|
|
30
|
+
RSpec.configure do |config|
|
|
31
|
+
config.backtrace_clean_patterns = [
|
|
32
|
+
/spec_helper/
|
|
33
|
+
]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def foo
|
|
37
|
+
"bar"
|
|
38
|
+
end
|
|
39
|
+
"""
|
|
40
|
+
And a file named "spec/example_spec.rb" with:
|
|
41
|
+
"""ruby
|
|
42
|
+
require 'spec_helper'
|
|
43
|
+
describe "foo" do
|
|
44
|
+
it "returns baz" do
|
|
45
|
+
foo.should eq("baz")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
"""
|
|
49
|
+
When I run `rspec`
|
|
50
|
+
Then the output should contain "1 example, 1 failure"
|
|
51
|
+
And the output should contain "lib/rspec/expectations"
|
|
52
|
+
|
|
53
|
+
Scenario: Adding a pattern
|
|
54
|
+
Given a file named "spec/matchers/be_baz_matcher.rb" with:
|
|
55
|
+
"""ruby
|
|
56
|
+
RSpec::Matchers.define :be_baz do |_|
|
|
57
|
+
match do |actual|
|
|
58
|
+
actual == "baz"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
"""
|
|
62
|
+
And a file named "spec/example_spec.rb" with:
|
|
63
|
+
"""ruby
|
|
64
|
+
RSpec.configure do |config|
|
|
65
|
+
config.backtrace_clean_patterns << /be_baz_matcher/
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe "bar" do
|
|
69
|
+
it "is baz" do
|
|
70
|
+
"bar".should be_baz
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
"""
|
|
74
|
+
When I run `rspec`
|
|
75
|
+
Then the output should contain "1 example, 1 failure"
|
|
76
|
+
But the output should not contain "be_baz_matcher"
|
|
77
|
+
And the output should not contain "lib/rspec/expectations"
|
|
78
|
+
|
|
79
|
+
Scenario: Running with the --backtrace option
|
|
80
|
+
Given a file named "spec/matchers/be_baz_matcher.rb" with:
|
|
81
|
+
"""ruby
|
|
82
|
+
RSpec::Matchers.define :be_baz do |_|
|
|
83
|
+
match do |actual|
|
|
84
|
+
actual == "baz"
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
"""
|
|
88
|
+
And a file named "spec/example_spec.rb" with:
|
|
89
|
+
"""ruby
|
|
90
|
+
RSpec.configure do |config|
|
|
91
|
+
config.backtrace_clean_patterns << /be_baz_matcher/
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe "bar" do
|
|
95
|
+
it "is baz" do
|
|
96
|
+
"bar".should be_baz
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
"""
|
|
100
|
+
When I run `rspec --backtrace`
|
|
101
|
+
Then the output should contain "1 example, 1 failure"
|
|
102
|
+
And the output should not contain "be_baz_matcher"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Feature: failure exit code
|
|
2
|
+
|
|
3
|
+
Use the feature_exit_code option to set a custom exit code when RSpec fails.
|
|
4
|
+
|
|
5
|
+
RSpec.configure { |c| c.failure_exit_code = 42 }
|
|
6
|
+
|
|
7
|
+
Background:
|
|
8
|
+
Given a file named "spec/spec_helper.rb" with:
|
|
9
|
+
"""ruby
|
|
10
|
+
RSpec.configure { |c| c.failure_exit_code = 42 }
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
Scenario: a failing spec with the default exit code
|
|
14
|
+
Given a file named "spec/example_spec.rb" with:
|
|
15
|
+
"""ruby
|
|
16
|
+
describe "something" do
|
|
17
|
+
it "fails" do
|
|
18
|
+
fail
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
"""
|
|
22
|
+
When I run `rspec spec/example_spec.rb`
|
|
23
|
+
Then the exit status should be 1
|
|
24
|
+
|
|
25
|
+
Scenario: a failing spec with a custom exit code
|
|
26
|
+
Given a file named "spec/example_spec.rb" with:
|
|
27
|
+
"""ruby
|
|
28
|
+
require 'spec_helper'
|
|
29
|
+
describe "something" do
|
|
30
|
+
it "fails" do
|
|
31
|
+
fail
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
"""
|
|
35
|
+
When I run `rspec spec/example_spec.rb`
|
|
36
|
+
Then the exit status should be 42
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Feature: output_stream
|
|
2
|
+
|
|
3
|
+
Define a custom output stream (default `$stdout`). Aliases: `:output`, `:out`.
|
|
4
|
+
|
|
5
|
+
RSpec.configure { |c| c.output_stream = File.open('saved_output', 'w') }
|
|
6
|
+
|
|
7
|
+
Background:
|
|
8
|
+
Given a file named "spec/spec_helper.rb" with:
|
|
9
|
+
"""ruby
|
|
10
|
+
RSpec.configure {|c| c.output_stream = File.open('saved_output', 'w') }
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
Scenario: redirecting output
|
|
14
|
+
Given a file named "spec/example_spec.rb" with:
|
|
15
|
+
"""ruby
|
|
16
|
+
require 'spec_helper'
|
|
17
|
+
describe "an example" do
|
|
18
|
+
it "passes" do
|
|
19
|
+
true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
"""
|
|
23
|
+
When I run `rspec spec/example_spec.rb`
|
|
24
|
+
Then the file "saved_output" should contain "1 example, 0 failures"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Feature: pattern
|
|
2
|
+
|
|
3
|
+
Use the pattern option to tell RSpec to look for specs in files that match a pattern other than "**/*_spec.rb".
|
|
4
|
+
|
|
5
|
+
Background:
|
|
6
|
+
Given a file named "spec/example_spec.rb" with:
|
|
7
|
+
"""ruby
|
|
8
|
+
describe "two specs here" do
|
|
9
|
+
it "passes" do
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "passes too" do
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
"""
|
|
16
|
+
And a file named "spec/example_test.rb" with:
|
|
17
|
+
"""ruby
|
|
18
|
+
describe "only one spec" do
|
|
19
|
+
it "passes" do
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
Scenario: by default, RSpec runs files that match "**/*_spec.rb"
|
|
25
|
+
When I run `rspec`
|
|
26
|
+
Then the output should contain "2 examples, 0 failures"
|
|
27
|
+
|
|
28
|
+
Scenario: the --pattern flag makes RSpec run files matching the specified pattern and ignore the default pattern
|
|
29
|
+
When I run `rspec -P "**/*_test.rb"`
|
|
30
|
+
Then the output should contain "1 example, 0 failures"
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
Feature: Profile examples
|
|
2
|
+
|
|
3
|
+
The `--profile` command line option (available from `RSpec.configure` as
|
|
4
|
+
`#profile_examples`), when set, will cause RSpec to dump out a list of
|
|
5
|
+
your slowest examples. By default, it prints the 10 slowest examples,
|
|
6
|
+
but you can set it to a different value to have it print more or fewer
|
|
7
|
+
slow examples.
|
|
8
|
+
|
|
9
|
+
Background:
|
|
10
|
+
Given a file named "spec/spec_helper.rb" with:
|
|
11
|
+
"""ruby
|
|
12
|
+
"""
|
|
13
|
+
And a file named "spec/example_spec.rb" with:
|
|
14
|
+
"""ruby
|
|
15
|
+
require "spec_helper"
|
|
16
|
+
|
|
17
|
+
describe "something" do
|
|
18
|
+
it "sleeps for 0.1 secionds (example 1)" do
|
|
19
|
+
sleep 0.1
|
|
20
|
+
1.should == 1
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "sleeps for 0 seconds (example 2)" do
|
|
24
|
+
2.should == 2
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "sleeps for 0.15 seconds (example 3)" do
|
|
28
|
+
sleep 0.15
|
|
29
|
+
3.should == 3
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "sleeps for 0.05 seconds (example 4)" do
|
|
33
|
+
sleep 0.05
|
|
34
|
+
4.should == 4
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "sleeps for 0.05 seconds (example 5)" do
|
|
38
|
+
sleep 0.05
|
|
39
|
+
5.should == 5
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "sleeps for 0.05 seconds (example 6)" do
|
|
43
|
+
sleep 0.05
|
|
44
|
+
6.should == 6
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "sleeps for 0.05 seconds (example 7)" do
|
|
48
|
+
sleep 0.05
|
|
49
|
+
7.should == 7
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "sleeps for 0.05 seconds (example 8)" do
|
|
53
|
+
sleep 0.05
|
|
54
|
+
8.should == 8
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "sleeps for 0.05 seconds (example 9)" do
|
|
58
|
+
sleep 0.05
|
|
59
|
+
9.should == 9
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "sleeps for 0.05 seconds (example 10)" do
|
|
63
|
+
sleep 0.05
|
|
64
|
+
10.should == 10
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "sleeps for 0.05 seconds (example 11)" do
|
|
68
|
+
sleep 0.05
|
|
69
|
+
11.should == 11
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
Scenario: by default does not show profile
|
|
75
|
+
When I run `rspec spec`
|
|
76
|
+
Then the examples should all pass
|
|
77
|
+
And the output should not contain "example 1"
|
|
78
|
+
And the output should not contain "example 2"
|
|
79
|
+
And the output should not contain "example 3"
|
|
80
|
+
And the output should not contain "example 4"
|
|
81
|
+
And the output should not contain "example 5"
|
|
82
|
+
And the output should not contain "example 6"
|
|
83
|
+
And the output should not contain "example 7"
|
|
84
|
+
And the output should not contain "example 8"
|
|
85
|
+
And the output should not contain "example 9"
|
|
86
|
+
And the output should not contain "example 10"
|
|
87
|
+
And the output should not contain "example 11"
|
|
88
|
+
|
|
89
|
+
Scenario: setting `profile_examples` to true shows 10 examples
|
|
90
|
+
Given a file named "spec/spec_helper.rb" with:
|
|
91
|
+
"""ruby
|
|
92
|
+
RSpec.configure { |c| c.profile_examples = true }
|
|
93
|
+
"""
|
|
94
|
+
When I run `rspec spec`
|
|
95
|
+
Then the examples should all pass
|
|
96
|
+
And the output should contain "Top 10 slowest examples"
|
|
97
|
+
And the output should contain "example 1"
|
|
98
|
+
And the output should not contain "example 2"
|
|
99
|
+
And the output should contain "example 3"
|
|
100
|
+
And the output should contain "example 4"
|
|
101
|
+
And the output should contain "example 5"
|
|
102
|
+
And the output should contain "example 6"
|
|
103
|
+
And the output should contain "example 7"
|
|
104
|
+
And the output should contain "example 8"
|
|
105
|
+
And the output should contain "example 9"
|
|
106
|
+
And the output should contain "example 10"
|
|
107
|
+
And the output should contain "example 11"
|
|
108
|
+
|
|
109
|
+
Scenario: setting `profile_examples` to 2 shows 2 examples
|
|
110
|
+
Given a file named "spec/spec_helper.rb" with:
|
|
111
|
+
"""ruby
|
|
112
|
+
RSpec.configure { |c| c.profile_examples = 2 }
|
|
113
|
+
"""
|
|
114
|
+
When I run `rspec spec`
|
|
115
|
+
Then the examples should all pass
|
|
116
|
+
And the output should contain "Top 2 slowest examples"
|
|
117
|
+
And the output should contain "example 1"
|
|
118
|
+
And the output should not contain "example 2"
|
|
119
|
+
And the output should contain "example 3"
|
|
120
|
+
And the output should not contain "example 4"
|
|
121
|
+
And the output should not contain "example 5"
|
|
122
|
+
And the output should not contain "example 6"
|
|
123
|
+
And the output should not contain "example 7"
|
|
124
|
+
And the output should not contain "example 8"
|
|
125
|
+
And the output should not contain "example 9"
|
|
126
|
+
And the output should not contain "example 10"
|
|
127
|
+
And the output should not contain "example 11"
|
|
128
|
+
|
|
129
|
+
Scenario: setting profile examples through CLI
|
|
130
|
+
When I run `rspec spec --profile 2`
|
|
131
|
+
Then the examples should all pass
|
|
132
|
+
And the output should contain "Top 2 slowest examples"
|
|
133
|
+
And the output should contain "example 1"
|
|
134
|
+
And the output should not contain "example 2"
|
|
135
|
+
And the output should contain "example 3"
|
|
136
|
+
And the output should not contain "example 4"
|
|
137
|
+
And the output should not contain "example 5"
|
|
138
|
+
And the output should not contain "example 6"
|
|
139
|
+
And the output should not contain "example 7"
|
|
140
|
+
And the output should not contain "example 8"
|
|
141
|
+
And the output should not contain "example 9"
|
|
142
|
+
And the output should not contain "example 10"
|
|
143
|
+
And the output should not contain "example 11"
|
|
144
|
+
|
|
145
|
+
Scenario: Using `--no-profile` overrules config options
|
|
146
|
+
Given a file named "spec/spec_helper.rb" with:
|
|
147
|
+
"""ruby
|
|
148
|
+
RSpec.configure { |c| c.profile_examples = true }
|
|
149
|
+
"""
|
|
150
|
+
When I run `rspec spec --no-profile`
|
|
151
|
+
Then the examples should all pass
|
|
152
|
+
And the output should not contain "example 1"
|
|
153
|
+
And the output should not contain "example 2"
|
|
154
|
+
And the output should not contain "example 3"
|
|
155
|
+
And the output should not contain "example 4"
|
|
156
|
+
And the output should not contain "example 5"
|
|
157
|
+
And the output should not contain "example 6"
|
|
158
|
+
And the output should not contain "example 7"
|
|
159
|
+
And the output should not contain "example 8"
|
|
160
|
+
And the output should not contain "example 9"
|
|
161
|
+
And the output should not contain "example 10"
|
|
162
|
+
And the output should not contain "example 11"
|
|
163
|
+
|