rspec-core 2.3.1 → 2.4.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.markdown +22 -0
- data/Rakefile +2 -2
- data/features/command_line/README.md +6 -0
- data/features/command_line/configure.feature +16 -14
- data/features/command_line/example_name_option.feature +3 -3
- data/features/command_line/format_option.feature +73 -0
- data/features/command_line/line_number_appended_to_path.feature +1 -1
- data/features/command_line/line_number_option.feature +2 -2
- data/features/command_line/tag.feature +7 -7
- data/features/configuration/read_options_from_file.feature +29 -16
- data/features/hooks/before_and_after_hooks.feature +9 -14
- data/features/hooks/filtering.feature +174 -0
- data/features/step_definitions/additional_cli_steps.rb +4 -0
- data/features/subject/attribute_of_subject.feature +68 -18
- data/lib/rspec/core/command_line_configuration.rb +16 -16
- data/lib/rspec/core/configuration.rb +14 -15
- data/lib/rspec/core/configuration_options.rb +46 -22
- data/lib/rspec/core/example.rb +16 -6
- data/lib/rspec/core/example_group.rb +11 -11
- data/lib/rspec/core/formatters/base_text_formatter.rb +2 -1
- data/lib/rspec/core/hooks.rb +8 -8
- data/lib/rspec/core/option_parser.rb +13 -3
- data/lib/rspec/core/pending.rb +2 -0
- data/lib/rspec/core/rake_task.rb +1 -1
- data/lib/rspec/core/subject.rb +2 -0
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +2 -2
- data/spec/rspec/core/configuration_options_spec.rb +147 -151
- data/spec/rspec/core/configuration_spec.rb +67 -19
- data/spec/rspec/core/example_spec.rb +12 -10
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +25 -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 +37 -24
- 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/html_formatter_spec.rb +7 -7
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +19 -19
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +51 -33
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +19 -19
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +26 -26
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +26 -26
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +7 -7
- data/spec/rspec/core/hooks_filtering_spec.rb +54 -0
- data/spec/rspec/core/option_parser_spec.rb +53 -17
- data/spec/rspec/core/rake_task_spec.rb +21 -0
- data/spec/spec_helper.rb +1 -1
- metadata +14 -8
data/History.markdown
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
## rspec-core release history (incomplete)
|
2
2
|
|
3
|
+
### 2.4.0 / 2011-01-02
|
4
|
+
|
5
|
+
[full changelog](http://github.com/rspec/rspec-core/compare/v2.3.1...v2.4.0)
|
6
|
+
|
7
|
+
* Enhancements
|
8
|
+
* start the debugger on -d so the stack trace is visible when it stops
|
9
|
+
(Clifford Heath)
|
10
|
+
* apply hook filtering to examples as well as groups (Myron Marston)
|
11
|
+
* support multiple formatters, each with their own output
|
12
|
+
* show exception classes in failure messages unless they come from RSpec
|
13
|
+
matchers or message expectations
|
14
|
+
* before(:all) { pending } sets all examples to pending
|
15
|
+
|
16
|
+
* Bug fixes
|
17
|
+
* fix bug due to change in behavior of reject in Ruby 1.9.3-dev (Shota Fukumori)
|
18
|
+
* fix bug when running in jruby: be explicit about passing block to super
|
19
|
+
(John Firebaugh)
|
20
|
+
* rake task doesn't choke on paths with quotes (Janmejay Singh)
|
21
|
+
* restore --options option from rspec-1
|
22
|
+
* require 'ostruct' to fix bug with its([key]) (Kim Burgestrand)
|
23
|
+
* --configure option generates .rspec file instead of autotest/discover.rb
|
24
|
+
|
3
25
|
### 2.3.1 / 2010-12-16
|
4
26
|
|
5
27
|
[full changelog](http://github.com/rspec/rspec-core/compare/v2.3.0...v2.3.1)
|
data/Rakefile
CHANGED
@@ -57,10 +57,10 @@ task :clobber do
|
|
57
57
|
rm_rf 'coverage'
|
58
58
|
end
|
59
59
|
|
60
|
-
desc "Push cukes to relishapp using the relish-client-gem"
|
60
|
+
desc "Push docs/cukes to relishapp using the relish-client-gem"
|
61
61
|
task :relish, :version do |t, args|
|
62
62
|
raise "rake relish[VERSION]" unless args[:version]
|
63
|
-
sh "relish push
|
63
|
+
sh "relish push rspec/rspec-core:#{args[:version]}"
|
64
64
|
end
|
65
65
|
|
66
66
|
Rake::RDocTask.new do |rdoc|
|
@@ -1,20 +1,22 @@
|
|
1
|
-
Feature: configure
|
1
|
+
Feature: --configure option
|
2
2
|
|
3
3
|
Use the --configure option on the command line to generate configuration
|
4
4
|
files.
|
5
5
|
|
6
|
-
The only supported argument, so far, is "autotest", which creates
|
7
|
-
|
6
|
+
The only supported argument, so far, is "autotest", which creates a .rspec
|
7
|
+
file in your project root directory. When autotest sees this file, it knows
|
8
|
+
to load RSpec's Autotest subclass.
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
Scenario: generate .rspec file for autotest
|
11
|
+
When I run "rspec --configure autotest"
|
12
|
+
Then the following files should exist:
|
13
|
+
| .rspec |
|
14
|
+
And the stdout should contain ".rspec file did not exist, so it was created."
|
11
15
|
|
12
|
-
Scenario:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
And the file "autotest/discover.rb" should contain "Autotest.add_discovery"
|
20
|
-
And the stdout should contain "autotest/discover.rb has been added"
|
16
|
+
Scenario: .rspec file already exists
|
17
|
+
Given a file named ".rspec" with:
|
18
|
+
"""
|
19
|
+
--color
|
20
|
+
"""
|
21
|
+
When I run "rspec --configure autotest"
|
22
|
+
Then the stdout should contain ".rspec file already exists, so nothing was changed."
|
@@ -1,13 +1,13 @@
|
|
1
|
-
Feature: example
|
1
|
+
Feature: --example option
|
2
2
|
|
3
|
-
Use the --example (or -e) option to filter
|
3
|
+
Use the --example (or -e) option to filter examples by name.
|
4
4
|
|
5
5
|
The argument is compiled to a Ruby Regexp, and matched against the full
|
6
6
|
description of the example, which is the concatenation of descriptions of the
|
7
7
|
group (including any nested groups) and the example.
|
8
8
|
|
9
9
|
This allows you to run a single uniquely named example, all examples with
|
10
|
-
similar names, all the
|
10
|
+
similar names, all the examples in a uniquely named group, etc, etc.
|
11
11
|
|
12
12
|
Background:
|
13
13
|
Given a file named "first_spec.rb" with:
|
@@ -0,0 +1,73 @@
|
|
1
|
+
Feature: --format option
|
2
|
+
|
3
|
+
Use the --format option to tell RSpec how to format the output.
|
4
|
+
|
5
|
+
RSpec ships with a few formatters built in. By default, it uses the progress
|
6
|
+
formatter, which generates output like this:
|
7
|
+
|
8
|
+
....F.....*.....
|
9
|
+
|
10
|
+
A '.' represents a passing example, 'F' is failing, and '*' is pending.
|
11
|
+
|
12
|
+
To see the documentation strings passed to each describe(), context(), and it()
|
13
|
+
method, use the documentation formatter:
|
14
|
+
|
15
|
+
$ rspec spec --format documentation
|
16
|
+
|
17
|
+
You can also specify an output target (STDOUT by default) by appending a
|
18
|
+
filename to the argument:
|
19
|
+
|
20
|
+
$ rspec spec --format documentation:rspec.output.txt
|
21
|
+
|
22
|
+
Background:
|
23
|
+
Given a file named "example_spec.rb" with:
|
24
|
+
"""
|
25
|
+
describe "something" do
|
26
|
+
it "does something that passes" do
|
27
|
+
5.should eq(5)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "does something that fails" do
|
31
|
+
5.should eq(4)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "does something that is pending", :pending => true do
|
35
|
+
5.should be > 3
|
36
|
+
end
|
37
|
+
end
|
38
|
+
"""
|
39
|
+
|
40
|
+
Scenario: progress bar format (default)
|
41
|
+
When I run "rspec example_spec.rb"
|
42
|
+
Then the output should contain ".F*"
|
43
|
+
|
44
|
+
Scenario: documentation format
|
45
|
+
When I run "rspec example_spec.rb --format documentation"
|
46
|
+
Then the output should contain:
|
47
|
+
"""
|
48
|
+
something
|
49
|
+
does something that passes
|
50
|
+
does something that fails (FAILED - 1)
|
51
|
+
does something that is pending (PENDING: Not Yet Implemented)
|
52
|
+
"""
|
53
|
+
|
54
|
+
Scenario: documentation format saved to a file
|
55
|
+
When I run "rspec example_spec.rb --format documentation --out rspec.txt"
|
56
|
+
Then the file "rspec.txt" should contain:
|
57
|
+
"""
|
58
|
+
something
|
59
|
+
does something that passes
|
60
|
+
does something that fails (FAILED - 1)
|
61
|
+
does something that is pending (PENDING: Not Yet Implemented)
|
62
|
+
"""
|
63
|
+
|
64
|
+
Scenario: multiple formats
|
65
|
+
When I run "rspec example_spec.rb --format progress --format documentation --out rspec.txt"
|
66
|
+
Then the output should contain ".F*"
|
67
|
+
And the file "rspec.txt" should contain:
|
68
|
+
"""
|
69
|
+
something
|
70
|
+
does something that passes
|
71
|
+
does something that fails (FAILED - 1)
|
72
|
+
does something that is pending (PENDING: Not Yet Implemented)
|
73
|
+
"""
|
@@ -1,8 +1,8 @@
|
|
1
|
-
Feature: line
|
1
|
+
Feature: --line option
|
2
2
|
|
3
3
|
To run a single example or group, you can use the --line option:
|
4
4
|
|
5
|
-
|
5
|
+
rspec path/to/example_spec.rb --line 37
|
6
6
|
|
7
7
|
Scenario: standard examples
|
8
8
|
Given a file named "example_spec.rb" with:
|
@@ -1,18 +1,18 @@
|
|
1
|
-
Feature: tag option
|
1
|
+
Feature: --tag option
|
2
2
|
|
3
|
-
Use the --tag (or -t) option to filter the examples
|
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
|
-
with :name => value will be filtered, where value is always a string.
|
8
|
-
|
7
|
+
with :name => value will be filtered, where value is always a string. In
|
8
|
+
both cases, name is converted to a symbol.
|
9
9
|
|
10
|
-
Tags can also be used to exclude examples by adding a ~ before the tag.
|
11
|
-
|
10
|
+
Tags can also be used to exclude examples by adding a ~ before the tag. For
|
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
|
|
17
17
|
Background:
|
18
18
|
Given a file named "tagged_spec.rb" with:
|
@@ -8,7 +8,7 @@ Feature: read command line configuration options from files
|
|
8
8
|
|
9
9
|
Options declared in the local file override those in the global file, while
|
10
10
|
those declared in RSpec.configure will override any ".rspec" file.
|
11
|
-
|
11
|
+
|
12
12
|
Scenario: color set in .rspec
|
13
13
|
Given a file named ".rspec" with:
|
14
14
|
"""
|
@@ -33,30 +33,43 @@ Feature: read command line configuration options from files
|
|
33
33
|
When I run "rspec ./spec/example_spec.rb"
|
34
34
|
Then the output should contain "1 example, 0 failures"
|
35
35
|
|
36
|
-
Scenario:
|
37
|
-
Given a file named ".
|
36
|
+
Scenario: custom options file
|
37
|
+
Given a file named "my.options" with:
|
38
|
+
"""
|
39
|
+
--format documentation
|
40
|
+
"""
|
41
|
+
And a file named "spec/example_spec.rb" with:
|
42
|
+
"""
|
43
|
+
describe "formatter set in custom options file" do
|
44
|
+
it "sets formatter" do
|
45
|
+
RSpec.configuration.formatters.first.
|
46
|
+
should be_a(RSpec::Core::Formatters::DocumentationFormatter)
|
47
|
+
end
|
48
|
+
end
|
38
49
|
"""
|
39
|
-
|
50
|
+
When I run "rspec spec/example_spec.rb --options my.options"
|
51
|
+
Then the output should contain "1 example, 0 failures"
|
52
|
+
|
53
|
+
Scenario: RSpec ignores ./.rspec when custom options file is used
|
54
|
+
Given a file named "my.options" with:
|
40
55
|
"""
|
41
|
-
|
56
|
+
--format documentation
|
42
57
|
"""
|
43
|
-
|
58
|
+
And a file named ".rspec" with:
|
59
|
+
"""
|
60
|
+
--color
|
44
61
|
"""
|
45
62
|
And a file named "spec/example_spec.rb" with:
|
46
63
|
"""
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
context "when set with RSpec.configure and in spec.opts" do
|
51
|
-
it "takes the value set in spec.opts" do
|
52
|
-
RSpec.configuration.formatter.should be_an(RSpec::Core::Formatters::DocumentationFormatter)
|
53
|
-
end
|
64
|
+
describe "custom options file" do
|
65
|
+
it "causes .rspec to be ignored" do
|
66
|
+
RSpec.configuration.color_enabled.should be_false
|
54
67
|
end
|
55
68
|
end
|
56
69
|
"""
|
57
|
-
When I run "rspec
|
70
|
+
When I run "rspec spec/example_spec.rb --options my.options"
|
58
71
|
Then the output should contain "1 example, 0 failures"
|
59
|
-
|
72
|
+
|
60
73
|
Scenario: using ERB in .rspec
|
61
74
|
Given a file named ".rspec" with:
|
62
75
|
"""
|
@@ -66,7 +79,7 @@ Feature: read command line configuration options from files
|
|
66
79
|
"""
|
67
80
|
describe "formatter" do
|
68
81
|
it "is set to documentation" do
|
69
|
-
RSpec.configuration.
|
82
|
+
RSpec.configuration.formatters.first.should be_an(RSpec::Core::Formatters::DocumentationFormatter)
|
70
83
|
end
|
71
84
|
end
|
72
85
|
"""
|
@@ -1,19 +1,16 @@
|
|
1
1
|
Feature: before and after hooks
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
So that I can control the environment in which it is run
|
3
|
+
Use `before` and `after` hooks to execute arbitrary code before and/or
|
4
|
+
after the body of an example is run:
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
before(:each) # run before each example
|
7
|
+
before(:all) # run one time only, before all of the examples in a group
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
after(:each) # run after each example
|
10
|
+
after(:all) # run one time only, after all of the examples in a group
|
12
11
|
|
13
|
-
|
14
|
-
after(:all) blocks are run once after all of the examples in a group
|
12
|
+
Before and after blocks are called in the following order:
|
15
13
|
|
16
|
-
Before and after blocks are called in the following order:
|
17
14
|
before suite
|
18
15
|
before all
|
19
16
|
before each
|
@@ -21,10 +18,8 @@ Feature: before and after hooks
|
|
21
18
|
after all
|
22
19
|
after suite
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
applied to all groups or subsets of all groups defined by example group
|
27
|
-
types.
|
21
|
+
`before` and `after` hooks can be defined directly in the example groups they
|
22
|
+
should run in, or in a global RSpec.configure block.
|
28
23
|
|
29
24
|
Scenario: define before(:each) block
|
30
25
|
Given a file named "before_each_spec.rb" with:
|
@@ -0,0 +1,174 @@
|
|
1
|
+
Feature: Global Hook Filtering
|
2
|
+
|
3
|
+
Before/After/Around hooks defined in the RSpec configuration block
|
4
|
+
can be filtered using metadata. Arbitrary metadata can be applied
|
5
|
+
to an example or example group, and used to make a hook only apply
|
6
|
+
to examples with the given metadata.
|
7
|
+
|
8
|
+
Scenario: Filter before(:each) hooks using arbitrary metadata
|
9
|
+
Given a file named "filter_before_each_hooks_spec.rb" with:
|
10
|
+
"""
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.before(:each, :foo => :bar) { puts "In hook" }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "group 1" do
|
16
|
+
it("example 1") { }
|
17
|
+
it("example 2", :foo => :bar) { }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "group 2", :foo => :bar do
|
21
|
+
it("example 1") { }
|
22
|
+
it("example 2", :foo => :bar) { }
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
When I run "rspec filter_before_each_hooks_spec.rb --format documentation"
|
26
|
+
Then the output should contain "4 examples, 0 failures"
|
27
|
+
And the output should contain:
|
28
|
+
"""
|
29
|
+
group 1
|
30
|
+
example 1
|
31
|
+
In hook
|
32
|
+
example 2
|
33
|
+
|
34
|
+
group 2
|
35
|
+
In hook
|
36
|
+
example 1
|
37
|
+
In hook
|
38
|
+
example 2
|
39
|
+
"""
|
40
|
+
|
41
|
+
Scenario: Filter after(:each) hooks using arbitrary metadata
|
42
|
+
Given a file named "filter_after_each_hooks_spec.rb" with:
|
43
|
+
"""
|
44
|
+
RSpec.configure do |config|
|
45
|
+
config.after(:each, :foo => :bar) { puts "In hook" }
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "group 1" do
|
49
|
+
it("example 1") { }
|
50
|
+
it("example 2", :foo => :bar) { }
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "group 2", :foo => :bar do
|
54
|
+
it("example 1") { }
|
55
|
+
it("example 2", :foo => :bar) { }
|
56
|
+
end
|
57
|
+
"""
|
58
|
+
When I run "rspec filter_after_each_hooks_spec.rb --format documentation"
|
59
|
+
Then the output should contain "4 examples, 0 failures"
|
60
|
+
And the output should contain:
|
61
|
+
"""
|
62
|
+
group 1
|
63
|
+
example 1
|
64
|
+
In hook
|
65
|
+
example 2
|
66
|
+
|
67
|
+
group 2
|
68
|
+
In hook
|
69
|
+
example 1
|
70
|
+
In hook
|
71
|
+
example 2
|
72
|
+
"""
|
73
|
+
|
74
|
+
Scenario: Filter around(:each) hooks using arbitrary metadata
|
75
|
+
Given a file named "filter_around_each_hooks_spec.rb" with:
|
76
|
+
"""
|
77
|
+
RSpec.configure do |config|
|
78
|
+
config.around(:each, :foo => :bar) do |example|
|
79
|
+
puts "Start hook"
|
80
|
+
example.run
|
81
|
+
puts "End hook"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "group 1" do
|
86
|
+
it("example 1") { }
|
87
|
+
it("example 2", :foo => :bar) { }
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "group 2", :foo => :bar do
|
91
|
+
it("example 1") { }
|
92
|
+
it("example 2", :foo => :bar) { }
|
93
|
+
end
|
94
|
+
"""
|
95
|
+
When I run "rspec filter_around_each_hooks_spec.rb --format documentation"
|
96
|
+
Then the output should contain "4 examples, 0 failures"
|
97
|
+
And the output should contain:
|
98
|
+
"""
|
99
|
+
group 1
|
100
|
+
example 1
|
101
|
+
Start hook
|
102
|
+
End hook
|
103
|
+
example 2
|
104
|
+
|
105
|
+
group 2
|
106
|
+
Start hook
|
107
|
+
End hook
|
108
|
+
example 1
|
109
|
+
Start hook
|
110
|
+
End hook
|
111
|
+
example 2
|
112
|
+
"""
|
113
|
+
|
114
|
+
Scenario: Filter before(:all) hooks using arbitrary metadata
|
115
|
+
Given a file named "filter_before_all_hooks_spec.rb" with:
|
116
|
+
"""
|
117
|
+
RSpec.configure do |config|
|
118
|
+
config.before(:all, :foo => :bar) { puts "In hook" }
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "group 1" do
|
122
|
+
it("example 1") { }
|
123
|
+
it("example 2") { }
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "group 2", :foo => :bar do
|
127
|
+
it("example 1") { }
|
128
|
+
it("example 2") { }
|
129
|
+
end
|
130
|
+
"""
|
131
|
+
When I run "rspec filter_before_all_hooks_spec.rb --format documentation"
|
132
|
+
Then the output should contain "4 examples, 0 failures"
|
133
|
+
And the output should contain:
|
134
|
+
"""
|
135
|
+
group 1
|
136
|
+
example 1
|
137
|
+
example 2
|
138
|
+
|
139
|
+
group 2
|
140
|
+
In hook
|
141
|
+
example 1
|
142
|
+
example 2
|
143
|
+
"""
|
144
|
+
|
145
|
+
Scenario: Filter after(:all) hooks using arbitrary metadata
|
146
|
+
Given a file named "filter_after_all_hooks_spec.rb" with:
|
147
|
+
"""
|
148
|
+
RSpec.configure do |config|
|
149
|
+
config.after(:all, :foo => :bar) { puts "In hook" }
|
150
|
+
end
|
151
|
+
|
152
|
+
describe "group 1" do
|
153
|
+
it("example 1") { }
|
154
|
+
it("example 2") { }
|
155
|
+
end
|
156
|
+
|
157
|
+
describe "group 2", :foo => :bar do
|
158
|
+
it("example 1") { }
|
159
|
+
it("example 2") { }
|
160
|
+
end
|
161
|
+
"""
|
162
|
+
When I run "rspec filter_after_all_hooks_spec.rb --format documentation"
|
163
|
+
Then the output should contain "4 examples, 0 failures"
|
164
|
+
And the output should contain:
|
165
|
+
"""
|
166
|
+
group 1
|
167
|
+
example 1
|
168
|
+
example 2
|
169
|
+
|
170
|
+
group 2
|
171
|
+
example 1
|
172
|
+
example 2
|
173
|
+
In hook
|
174
|
+
"""
|