rspec-core 2.14.8 → 2.99.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Changelog.md +54 -8
- data/features/command_line/order.feature +5 -8
- data/features/configuration/custom_settings.feature +10 -10
- data/features/configuration/deprecation_stream.feature +3 -3
- data/features/configuration/read_options_from_file.feature +1 -1
- data/features/example_groups/shared_examples.feature +2 -2
- data/features/hooks/around_hooks.feature +1 -1
- data/features/metadata/current_example.feature +43 -4
- data/features/metadata/user_defined.feature +12 -12
- data/lib/autotest/rspec2.rb +60 -56
- data/lib/rspec/core.rb +40 -2
- data/lib/rspec/core/caller_filter.rb +55 -0
- data/lib/rspec/core/command_line.rb +2 -2
- data/lib/rspec/core/configuration.rb +201 -13
- data/lib/rspec/core/deprecation.rb +2 -7
- data/lib/rspec/core/example.rb +5 -8
- data/lib/rspec/core/example_group.rb +101 -17
- data/lib/rspec/core/filter_manager.rb +2 -2
- data/lib/rspec/core/formatters/deprecation_formatter.rb +173 -15
- data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -12
- data/lib/rspec/core/hooks.rb +1 -1
- data/lib/rspec/core/memoized_helpers.rb +49 -17
- data/lib/rspec/core/metadata.rb +1 -1
- data/lib/rspec/core/option_parser.rb +8 -3
- data/lib/rspec/core/pending.rb +14 -10
- data/lib/rspec/core/rake_task.rb +30 -6
- data/lib/rspec/core/runner.rb +9 -0
- data/lib/rspec/core/shared_example_group.rb +11 -9
- data/lib/rspec/core/shared_example_group/collection.rb +3 -1
- data/lib/rspec/core/version.rb +1 -2
- data/spec/command_line/order_spec.rb +4 -4
- data/spec/rspec/core/backtrace_cleaner_spec.rb +10 -10
- data/spec/rspec/core/caller_filter_spec.rb +58 -0
- data/spec/rspec/core/command_line_spec.rb +1 -0
- data/spec/rspec/core/configuration_options_spec.rb +6 -6
- data/spec/rspec/core/configuration_spec.rb +285 -52
- data/spec/rspec/core/deprecation_spec.rb +10 -29
- data/spec/rspec/core/deprecations_spec.rb +0 -14
- data/spec/rspec/core/example_group_spec.rb +74 -56
- data/spec/rspec/core/example_spec.rb +54 -17
- data/spec/rspec/core/filter_manager_spec.rb +2 -2
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +156 -52
- data/spec/rspec/core/formatters/html_formatter_spec.rb +1 -1
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +1 -2
- data/spec/rspec/core/hooks_spec.rb +2 -0
- data/spec/rspec/core/memoized_helpers_spec.rb +154 -113
- data/spec/rspec/core/metadata_spec.rb +25 -25
- data/spec/rspec/core/option_parser_spec.rb +19 -1
- data/spec/rspec/core/project_initializer_spec.rb +4 -4
- data/spec/rspec/core/rake_task_spec.rb +25 -4
- data/spec/rspec/core/shared_context_spec.rb +4 -4
- data/spec/rspec/core/shared_example_group_spec.rb +1 -1
- data/spec/rspec/core_spec.rb +36 -2
- data/spec/spec_helper.rb +3 -0
- data/spec/support/helper_methods.rb +16 -1
- data/spec/support/shared_example_groups.rb +1 -0
- data/spec/support/silence_dsl_deprecations.rb +32 -0
- metadata +10 -7
- data/spec/rspec/core/formatters/text_mate_formatted-2.1.0.html +0 -425
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTdkZDRlZWFhNzlmYjQ5NmE0MDkxYzVlMjhmOGVkM2I5ZTgwYzZhOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmRhMTUxODliMzRmOTczZmZkYjAyNjk3NGFkMmY3MzRmYTY2MDVhZg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTZkZWQyOWRhMmE4NTRiNmRhY2I0Zjc1Mzg2MzgwYjFkNzdiYjBjNzI4ZGY5
|
10
|
+
YzZkNjdhZDhlOTMyNzFiZTBlMjE4MDQ4OTYxY2MwNzZhZjQ5ODdlODFmNDgx
|
11
|
+
N2YxNmY2MDczNWFhNWM4YjdlY2YwMjA5ZDZjMDNiZmMyMGIyMzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjBlYmZlMTY4ZWI1NDQ5NDY3MTgzYWVkMGRjODE3NDJkNzk3MmUzNTU5ZmEw
|
14
|
+
NGY3NWE1YTRiMjMxNTdmMjJjOTk3ZjA0NDU3NTk5NGZhOTQ2ZDQ2NWJhM2Nj
|
15
|
+
ZDgxZmI0NzI5MWQ4ZjVhOGIwNmU0M2VhZWU3YmQ2MTc4MmNkY2I=
|
data/Changelog.md
CHANGED
@@ -1,10 +1,55 @@
|
|
1
|
-
### 2.
|
2
|
-
[
|
1
|
+
### 2.99.0.beta1 / 2013-11-07
|
2
|
+
[full changelog](http://github.com/rspec/rspec-core/compare/v2.14.7...v2.99.0.beta1)
|
3
3
|
|
4
|
-
|
4
|
+
Enhancements
|
5
5
|
|
6
|
-
*
|
7
|
-
|
6
|
+
* Block-based DSL methods that run in the context of an example
|
7
|
+
(`it`, `before(:each)`, `after(:each)`, `let` and `subject`)
|
8
|
+
now yield the example as a block argument. (David Chelimsky)
|
9
|
+
* Warn when the name of more than one example group is submitted to
|
10
|
+
`include_examples` and it's aliases. (David Chelimsky)
|
11
|
+
* Add `expose_current_running_example_as` config option for
|
12
|
+
use during the upgrade process when external gems use the
|
13
|
+
deprecated `RSpec::Core::ExampleGroup#example` and
|
14
|
+
`RSpec::Core::ExampleGroup#running_example` methods. (Myron Marston)
|
15
|
+
* Limit spamminess of deprecation messages. (Bradley Schaefer, Loren Segal)
|
16
|
+
* Add `config.raise_errors_for_deprecations!` option, which turns
|
17
|
+
deprecations warnings into errors to surface the full backtrace
|
18
|
+
of the call site. (Myron Marston)
|
19
|
+
|
20
|
+
Deprecations
|
21
|
+
|
22
|
+
* Deprecate `RSpec::Core::ExampleGroup#example` and
|
23
|
+
`RSpec::Core::ExampleGroup#running_example` methods. If you need
|
24
|
+
access to the example (e.g. to get its metadata), use a block argument
|
25
|
+
instead. (David Chelimsky)
|
26
|
+
* Deprecate use of `autotest/rspec2` in favour of `rspec-autotest`. (Jon Rowe)
|
27
|
+
* Deprecate RSpec's built-in debugger support. Use a CLI option like
|
28
|
+
`-rruby-debug` (for the ruby-debug gem) or `-rdebugger` (for the
|
29
|
+
debugger gem) instead. (Myron Marston)
|
30
|
+
* Deprecate `RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values = false`.
|
31
|
+
RSpec 3 will not support having this option set to `false`. (Myron Marston)
|
32
|
+
* Deprecate accessing a `let` or `subject` declaration in
|
33
|
+
a `after(:all)` hook. (Myron Marston, Jon Rowe)
|
34
|
+
* Deprecate built-in `its` usage in favor of `rspec-its` gem due to planned
|
35
|
+
removal in RSpec 3. (Peter Alfvin)
|
36
|
+
* Deprecate `RSpec::Core::PendingExampleFixedError` in favor of
|
37
|
+
`RSpec::Core::Pending::PendingExampleFixedError`. (Myron Marston)
|
38
|
+
* Deprecate `RSpec::Core::Configuration#out` and
|
39
|
+
`RSpec::Core::Configuration#output` in favor of
|
40
|
+
`RSpec::Core::Configuration#output_stream`. (Myron Marston)
|
41
|
+
* Deprecate legacy ordering APIs.
|
42
|
+
* You should use `register_ordering(:global)` instead of these:
|
43
|
+
* `RSpec::Core::Configuration#order_examples`
|
44
|
+
* `RSpec::Core::Configuration#order_groups`
|
45
|
+
* `RSpec::Core::Configuration#order_groups_and_examples`
|
46
|
+
* These are deprecated with no replacement because in RSpec 3
|
47
|
+
ordering is a property of individual example groups rather than
|
48
|
+
just a global property of the entire test suite:
|
49
|
+
* `RSpec::Core::Configuration#order`
|
50
|
+
* `RSpec::Core::Configuration#randomize?`
|
51
|
+
* `--order default` is deprecated in favor of `--order defined`
|
52
|
+
(Myron Marston)
|
8
53
|
|
9
54
|
### 2.14.7 / 2013-10-29
|
10
55
|
[full changelog](http://github.com/rspec/rspec-core/compare/v2.14.6...v2.14.7)
|
@@ -27,7 +72,8 @@ Bug fixes:
|
|
27
72
|
|
28
73
|
* Format stringified numbers correctly when mathn library is loaded.
|
29
74
|
(Jay Hayes)
|
30
|
-
* Fix an issue that prevented the use of frozen error objects. (Lars
|
75
|
+
* Fix an issue that prevented the use of frozen error objects. (Lars
|
76
|
+
Gierth)
|
31
77
|
|
32
78
|
### 2.14.5 / 2013-08-13
|
33
79
|
[full changelog](http://github.com/rspec/rspec-core/compare/v2.14.4...v2.14.5)
|
@@ -106,7 +152,7 @@ Enhancements
|
|
106
152
|
* Apply focus to examples defined with `fit` (equivalent of
|
107
153
|
`it "description", focus: true`) (Michael de Silva)
|
108
154
|
|
109
|
-
Bug
|
155
|
+
Bug fix
|
110
156
|
|
111
157
|
* Ensure methods defined by `let` take precedence over others
|
112
158
|
when there is a name collision (e.g. from an included module).
|
@@ -141,7 +187,7 @@ Enhancements
|
|
141
187
|
(Konstantin Haase).
|
142
188
|
* Add cucumber documentation for --require command line option
|
143
189
|
(Bradley Schaefer)
|
144
|
-
* Expose
|
190
|
+
* Expose configuration options via config:
|
145
191
|
* `config.libs` returns the libs configured to be added onto the load path
|
146
192
|
* `full_backtrace?` returns the state of the backtrace cleaner
|
147
193
|
* `debug?` returns true when the debugger is loaded
|
@@ -1,13 +1,10 @@
|
|
1
1
|
Feature: --order (new in rspec-core-2.8)
|
2
2
|
|
3
3
|
Use the `--order` option to tell RSpec how to order the files, groups, and
|
4
|
-
examples. Options are `
|
4
|
+
examples. Options are `defined` and `rand`.
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
* files are ordered based on the underlying file system's order (typically
|
9
|
-
case-sensitive alpha on *nix OS's and case-insenstive alpha in Windows)
|
10
|
-
* groups/examples are loaded in the order in which they are declared
|
6
|
+
`defined` is the default, which executes groups and examples in the
|
7
|
+
order they are defined as the spec files are loaded.
|
11
8
|
|
12
9
|
Use `rand` to randomize the order of files, groups within files, and
|
13
10
|
examples within groups.*
|
@@ -20,10 +17,10 @@ Feature: --order (new in rspec-core-2.8)
|
|
20
17
|
|
21
18
|
<h3>Examples</h3>
|
22
19
|
|
23
|
-
--order
|
20
|
+
--order defined
|
24
21
|
--order rand
|
25
22
|
--order rand:123
|
26
23
|
--seed 123 # same as --order rand:123
|
27
24
|
|
28
|
-
The `
|
25
|
+
The `defined` option is only necessary when you have `--order rand` stored in a
|
29
26
|
config file (e.g. `.rspec`) and you want to override it from the command line.
|
@@ -15,17 +15,17 @@ Feature: custom settings
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "acts false by default" do
|
18
|
-
RSpec.configuration.custom_setting.should
|
18
|
+
RSpec.configuration.custom_setting.should be_falsey
|
19
19
|
end
|
20
20
|
|
21
21
|
it "is exposed as a predicate" do
|
22
|
-
RSpec.configuration.custom_setting?.should
|
22
|
+
RSpec.configuration.custom_setting?.should be_falsey
|
23
23
|
end
|
24
24
|
|
25
25
|
it "can be overridden" do
|
26
26
|
RSpec.configuration.custom_setting = true
|
27
|
-
RSpec.configuration.custom_setting.should
|
28
|
-
RSpec.configuration.custom_setting?.should
|
27
|
+
RSpec.configuration.custom_setting.should be_truthy
|
28
|
+
RSpec.configuration.custom_setting?.should be_truthy
|
29
29
|
end
|
30
30
|
end
|
31
31
|
"""
|
@@ -41,17 +41,17 @@ Feature: custom settings
|
|
41
41
|
|
42
42
|
describe "custom setting" do
|
43
43
|
it "is true by default" do
|
44
|
-
RSpec.configuration.custom_setting.should
|
44
|
+
RSpec.configuration.custom_setting.should be_truthy
|
45
45
|
end
|
46
46
|
|
47
47
|
it "is exposed as a predicate" do
|
48
|
-
RSpec.configuration.custom_setting?.should
|
48
|
+
RSpec.configuration.custom_setting?.should be_truthy
|
49
49
|
end
|
50
50
|
|
51
51
|
it "can be overridden" do
|
52
52
|
RSpec.configuration.custom_setting = false
|
53
|
-
RSpec.configuration.custom_setting.should
|
54
|
-
RSpec.configuration.custom_setting?.should
|
53
|
+
RSpec.configuration.custom_setting.should be_falsey
|
54
|
+
RSpec.configuration.custom_setting?.should be_falsey
|
55
55
|
end
|
56
56
|
end
|
57
57
|
"""
|
@@ -71,11 +71,11 @@ Feature: custom settings
|
|
71
71
|
|
72
72
|
describe "custom setting" do
|
73
73
|
it "returns the value set in the last cofigure block to get eval'd" do
|
74
|
-
RSpec.configuration.custom_setting.should
|
74
|
+
RSpec.configuration.custom_setting.should be_truthy
|
75
75
|
end
|
76
76
|
|
77
77
|
it "is exposed as a predicate" do
|
78
|
-
RSpec.configuration.custom_setting?.should
|
78
|
+
RSpec.configuration.custom_setting?.should be_truthy
|
79
79
|
end
|
80
80
|
end
|
81
81
|
"""
|
@@ -27,7 +27,7 @@ Feature: deprecation_stream
|
|
27
27
|
end
|
28
28
|
"""
|
29
29
|
When I run `rspec spec/example_spec.rb`
|
30
|
-
Then the output should contain "
|
30
|
+
Then the output should contain "Deprecation Warnings:\n\nFoo#bar is deprecated"
|
31
31
|
|
32
32
|
Scenario: configure using the path to a file
|
33
33
|
Given a file named "spec/example_spec.rb" with:
|
@@ -39,7 +39,7 @@ Feature: deprecation_stream
|
|
39
39
|
end
|
40
40
|
"""
|
41
41
|
When I run `rspec spec/example_spec.rb`
|
42
|
-
Then the output should not contain "
|
42
|
+
Then the output should not contain "Deprecation Warnings:"
|
43
43
|
But the output should contain "1 deprecation logged to deprecations.txt"
|
44
44
|
And the file "deprecations.txt" should contain "Foo#bar is deprecated"
|
45
45
|
|
@@ -53,6 +53,6 @@ Feature: deprecation_stream
|
|
53
53
|
end
|
54
54
|
"""
|
55
55
|
When I run `rspec spec/example_spec.rb`
|
56
|
-
Then the output should not contain "
|
56
|
+
Then the output should not contain "Deprecation Warnings:"
|
57
57
|
But the output should contain "1 deprecation logged to deprecations.txt"
|
58
58
|
And the file "deprecations.txt" should contain "Foo#bar is deprecated"
|
@@ -66,7 +66,7 @@ Feature: read command line configuration options from files
|
|
66
66
|
"""ruby
|
67
67
|
describe "custom options file" do
|
68
68
|
it "causes .rspec to be ignored" do
|
69
|
-
RSpec.configuration.color_enabled.should
|
69
|
+
RSpec.configuration.color_enabled.should be_falsey
|
70
70
|
end
|
71
71
|
end
|
72
72
|
"""
|
@@ -53,13 +53,13 @@ Feature: shared examples
|
|
53
53
|
describe "#include?" do
|
54
54
|
context "with an an item that is in the collection" do
|
55
55
|
it "returns true" do
|
56
|
-
collection.include?(7).should
|
56
|
+
collection.include?(7).should be_truthy
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
context "with an an item that is not in the collection" do
|
61
61
|
it "returns false" do
|
62
|
-
collection.include?(9).should
|
62
|
+
collection.include?(9).should be_falsey
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -1,14 +1,53 @@
|
|
1
1
|
Feature: current example
|
2
2
|
|
3
3
|
You can reference the example object, and access its metadata, using
|
4
|
-
|
4
|
+
a block argument to it, before and after hooks, let, and subject.
|
5
5
|
|
6
6
|
Scenario: access the example object from within an example
|
7
7
|
Given a file named "spec/example_spec.rb" with:
|
8
8
|
"""ruby
|
9
|
-
describe "
|
10
|
-
|
11
|
-
example.description.
|
9
|
+
describe "example as block arg to it, before, and after" do
|
10
|
+
before do |example|
|
11
|
+
expect(example.description).to eq("is the example object")
|
12
|
+
end
|
13
|
+
|
14
|
+
after do |example|
|
15
|
+
expect(example.description).to eq("is the example object")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "is the example object" do |example|
|
19
|
+
expect(example.description).to eq("is the example object")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "example as block arg to let" do
|
24
|
+
let(:the_description) do |example|
|
25
|
+
example.description
|
26
|
+
end
|
27
|
+
|
28
|
+
it "is the example object" do |example|
|
29
|
+
expect(the_description).to eq("is the example object")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "example as block arg to subject" do
|
34
|
+
subject do |example|
|
35
|
+
example.description
|
36
|
+
end
|
37
|
+
|
38
|
+
it "is the example object" do |example|
|
39
|
+
expect(subject).to eq("is the example object")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "example as block arg to subject with a name" do
|
44
|
+
subject(:the_subject) do |example|
|
45
|
+
example.description
|
46
|
+
end
|
47
|
+
|
48
|
+
it "is the example object" do |example|
|
49
|
+
expect(the_subject).to eq("is the example object")
|
50
|
+
expect(subject).to eq("is the example object")
|
12
51
|
end
|
13
52
|
end
|
14
53
|
"""
|
@@ -25,20 +25,20 @@ Feature: User-defined metadata
|
|
25
25
|
Given a file named "define_group_metadata_with_hash_spec.rb" with:
|
26
26
|
"""ruby
|
27
27
|
describe "a group with user-defined metadata", :foo => 17 do
|
28
|
-
it 'has access to the metadata in the example' do
|
28
|
+
it 'has access to the metadata in the example' do |example|
|
29
29
|
example.metadata[:foo].should eq(17)
|
30
30
|
end
|
31
31
|
|
32
|
-
it 'does not have access to metadata defined on sub-groups' do
|
32
|
+
it 'does not have access to metadata defined on sub-groups' do |example|
|
33
33
|
example.metadata.should_not include(:bar)
|
34
34
|
end
|
35
35
|
|
36
36
|
describe 'a sub-group with user-defined metadata', :bar => 12 do
|
37
|
-
it 'has access to the sub-group metadata' do
|
37
|
+
it 'has access to the sub-group metadata' do |example|
|
38
38
|
example.metadata[:foo].should eq(17)
|
39
39
|
end
|
40
40
|
|
41
|
-
it 'also has access to metadata defined on parent groups' do
|
41
|
+
it 'also has access to metadata defined on parent groups' do |example|
|
42
42
|
example.metadata[:bar].should eq(12)
|
43
43
|
end
|
44
44
|
end
|
@@ -51,12 +51,12 @@ Feature: User-defined metadata
|
|
51
51
|
Given a file named "define_example_metadata_with_hash_spec.rb" with:
|
52
52
|
"""ruby
|
53
53
|
describe "a group with no user-defined metadata" do
|
54
|
-
it 'has an example with metadata', :foo => 17 do
|
54
|
+
it 'has an example with metadata', :foo => 17 do |example|
|
55
55
|
example.metadata[:foo].should eq(17)
|
56
56
|
example.metadata.should_not include(:bar)
|
57
57
|
end
|
58
58
|
|
59
|
-
it 'has another example with metadata', :bar => 12, :bazz => 33 do
|
59
|
+
it 'has another example with metadata', :bar => 12, :bazz => 33 do |example|
|
60
60
|
example.metadata[:bar].should eq(12)
|
61
61
|
example.metadata[:bazz].should eq(33)
|
62
62
|
example.metadata.should_not include(:foo)
|
@@ -70,12 +70,12 @@ Feature: User-defined metadata
|
|
70
70
|
Given a file named "override_metadata_spec.rb" with:
|
71
71
|
"""ruby
|
72
72
|
describe "a group with user-defined metadata", :foo => 'bar' do
|
73
|
-
it 'can be overridden by an example', :foo => 'bazz' do
|
73
|
+
it 'can be overridden by an example', :foo => 'bazz' do |example|
|
74
74
|
example.metadata[:foo].should == 'bazz'
|
75
75
|
end
|
76
76
|
|
77
77
|
describe "a sub-group with an override", :foo => 'goo' do
|
78
|
-
it 'can be overridden by a sub-group' do
|
78
|
+
it 'can be overridden by a sub-group' do |example|
|
79
79
|
example.metadata[:foo].should == 'goo'
|
80
80
|
end
|
81
81
|
end
|
@@ -92,19 +92,19 @@ Feature: User-defined metadata
|
|
92
92
|
end
|
93
93
|
|
94
94
|
describe "a group with simple metadata", :fast, :simple, :bug => 73 do
|
95
|
-
it 'has `:fast => true` metadata' do
|
95
|
+
it 'has `:fast => true` metadata' do |example|
|
96
96
|
example.metadata[:fast].should == true
|
97
97
|
end
|
98
98
|
|
99
|
-
it 'has `:simple => true` metadata' do
|
99
|
+
it 'has `:simple => true` metadata' do |example|
|
100
100
|
example.metadata[:simple].should == true
|
101
101
|
end
|
102
102
|
|
103
|
-
it 'can still use a hash for metadata' do
|
103
|
+
it 'can still use a hash for metadata' do |example|
|
104
104
|
example.metadata[:bug].should eq(73)
|
105
105
|
end
|
106
106
|
|
107
|
-
it 'can define simple metadata on an example', :special do
|
107
|
+
it 'can define simple metadata on an example', :special do |example|
|
108
108
|
example.metadata[:special].should == true
|
109
109
|
end
|
110
110
|
end
|
data/lib/autotest/rspec2.rb
CHANGED
@@ -1,73 +1,77 @@
|
|
1
|
-
|
2
|
-
require 'rspec/
|
1
|
+
begin
|
2
|
+
require 'rspec/autotest'
|
3
|
+
rescue LoadError
|
4
|
+
require 'autotest'
|
3
5
|
|
4
|
-
# Derived from the `Autotest` class, extends the `autotest` command to work
|
5
|
-
# with RSpec.
|
6
|
-
#
|
7
|
-
# @note this will be extracted to a separate gem when we release rspec-3.
|
8
|
-
class Autotest::Rspec2 < Autotest
|
6
|
+
# Derived from the `Autotest` class, extends the `autotest` command to work
|
7
|
+
# with RSpec.
|
8
|
+
#
|
9
|
+
# @note this will be extracted to a separate gem when we release rspec-3.
|
10
|
+
class Autotest::Rspec2 < Autotest
|
9
11
|
|
10
|
-
|
12
|
+
RSPEC_EXECUTABLE = File.expand_path('../../../exe/rspec', __FILE__)
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
def initialize
|
15
|
+
super()
|
16
|
+
clear_mappings
|
17
|
+
setup_rspec_project_mappings
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
# Example for Ruby 1.8: http://rubular.com/r/AOXNVDrZpx
|
20
|
+
# Example for Ruby 1.9: http://rubular.com/r/85ag5AZ2jP
|
21
|
+
self.failed_results_re = /^\s*\d+\).*\n\s+(?:\e\[\d*m)?Failure.*(\n(?:\e\[\d*m)?\s+#\s(.*)?:\d+(?::.*)?(?:\e\[\d*m)?)+$/m
|
22
|
+
self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
# Adds conventional spec-to-file mappings to Autotest configuation.
|
26
|
+
def setup_rspec_project_mappings
|
27
|
+
add_mapping(%r%^spec/.*_spec\.rb$%) { |filename, _|
|
28
|
+
filename
|
29
|
+
}
|
30
|
+
add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
|
31
|
+
["spec/#{m[1]}_spec.rb"]
|
32
|
+
}
|
33
|
+
add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
|
34
|
+
files_matching %r%^spec/.*_spec\.rb$%
|
35
|
+
}
|
36
|
+
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
# Overrides Autotest's implementation to read rspec output
|
39
|
+
def consolidate_failures(failed)
|
40
|
+
filters = new_hash_of_arrays
|
41
|
+
failed.each do |spec, trace|
|
42
|
+
if trace =~ /(.*spec\.rb)/
|
43
|
+
filters[$1] << spec
|
44
|
+
end
|
42
45
|
end
|
46
|
+
return filters
|
43
47
|
end
|
44
|
-
return filters
|
45
|
-
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
# Overrides Autotest's implementation to generate the rspec command to run
|
50
|
+
def make_test_cmd(files_to_test)
|
51
|
+
files_to_test.empty? ? '' :
|
52
|
+
%|#{prefix}"#{ruby}"#{suffix} -S "#{RSPEC_EXECUTABLE}" --tty #{normalize(files_to_test).keys.flatten.map { |f| %|"#{f}"|}.join(' ')}|
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
# Generates a map of filenames to Arrays for Autotest
|
56
|
+
def normalize(files_to_test)
|
57
|
+
files_to_test.keys.inject({}) do |result, filename|
|
58
|
+
result.merge!(File.expand_path(filename) => [])
|
59
|
+
end
|
57
60
|
end
|
58
|
-
end
|
59
61
|
|
60
|
-
|
62
|
+
private
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
def suffix
|
65
|
+
using_bundler? ? "" : defined?(:Gem) ? " -rrubygems" : ""
|
66
|
+
end
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
-
|
68
|
+
def using_bundler?
|
69
|
+
prefix =~ /bundle exec/
|
70
|
+
end
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
+
def gemfile?
|
73
|
+
File.exist?('./Gemfile')
|
74
|
+
end
|
72
75
|
end
|
76
|
+
Autotest.add_hook(:ran_command) { warn "\n\e[31mUsing the built in rspec-core autotest support is deprecated and will be removed in RSpec 3. Please switch to the rspec-autotest gem\e[0m" }
|
73
77
|
end
|