rspec-core 2.99.2 → 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +103 -191
- data/License.txt +1 -0
- data/README.md +4 -25
- data/features/Upgrade.md +2 -14
- data/features/command_line/dry_run.feature +29 -0
- data/features/command_line/example_name_option.feature +1 -1
- data/features/command_line/fail_fast.feature +26 -0
- data/features/command_line/format_option.feature +3 -3
- data/features/command_line/line_number_option.feature +16 -11
- data/features/command_line/order.feature +2 -3
- data/features/command_line/pattern_option.feature +3 -3
- data/features/command_line/randomization.feature +63 -0
- data/features/command_line/require_option.feature +2 -2
- data/features/command_line/ruby.feature +1 -1
- data/features/configuration/alias_example_to.feature +13 -22
- data/features/configuration/{backtrace_clean_patterns.feature → backtrace_exclusion_patterns.feature} +17 -14
- data/features/configuration/custom_settings.feature +11 -11
- data/features/configuration/overriding_global_ordering.feature +93 -0
- data/features/configuration/profile.feature +13 -13
- data/features/configuration/read_options_from_file.feature +7 -7
- data/features/example_groups/basic_structure.feature +1 -1
- data/features/example_groups/shared_context.feature +8 -8
- data/features/example_groups/shared_examples.feature +6 -14
- data/features/expectation_framework_integration/configure_expectation_framework.feature +27 -122
- data/features/filtering/exclusion_filters.feature +2 -5
- data/features/filtering/inclusion_filters.feature +1 -5
- data/features/formatters/json_formatter.feature +2 -2
- data/features/formatters/text_formatter.feature +4 -4
- data/features/helper_methods/arbitrary_methods.feature +2 -2
- data/features/helper_methods/let.feature +5 -5
- data/features/helper_methods/modules.feature +5 -8
- data/features/hooks/around_hooks.feature +2 -2
- data/features/hooks/before_and_after_hooks.feature +14 -14
- data/features/hooks/filtering.feature +12 -14
- data/features/metadata/described_class.feature +1 -1
- data/features/metadata/user_defined.feature +16 -29
- data/features/mock_framework_integration/use_flexmock.feature +1 -1
- data/features/mock_framework_integration/use_mocha.feature +1 -1
- data/features/mock_framework_integration/use_rr.feature +1 -1
- data/features/mock_framework_integration/use_rspec.feature +5 -5
- data/features/pending/pending_examples.feature +5 -5
- data/features/spec_files/arbitrary_file_suffix.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +3 -3
- data/features/subject/explicit_subject.feature +8 -8
- data/features/subject/implicit_receiver.feature +29 -0
- data/features/subject/implicit_subject.feature +4 -4
- data/features/support/env.rb +10 -3
- data/features/support/require_expect_syntax_in_aruba_specs.rb +16 -0
- data/lib/rspec/core.rb +11 -48
- data/lib/rspec/core/backport_random.rb +302 -0
- data/lib/rspec/core/backtrace_formatter.rb +65 -0
- data/lib/rspec/core/command_line.rb +7 -18
- data/lib/rspec/core/configuration.rb +202 -507
- data/lib/rspec/core/configuration_options.rb +17 -30
- data/lib/rspec/core/example.rb +29 -39
- data/lib/rspec/core/example_group.rb +166 -259
- data/lib/rspec/core/filter_manager.rb +30 -47
- data/lib/rspec/core/flat_map.rb +17 -0
- data/lib/rspec/core/formatters.rb +0 -138
- data/lib/rspec/core/formatters/base_formatter.rb +46 -1
- data/lib/rspec/core/formatters/base_text_formatter.rb +38 -61
- data/lib/rspec/core/formatters/deprecation_formatter.rb +21 -52
- data/lib/rspec/core/formatters/helpers.rb +0 -28
- data/lib/rspec/core/formatters/html_formatter.rb +1 -1
- data/lib/rspec/core/formatters/json_formatter.rb +38 -9
- data/lib/rspec/core/formatters/snippet_extractor.rb +14 -5
- data/lib/rspec/core/hooks.rb +55 -39
- data/lib/rspec/core/memoized_helpers.rb +17 -167
- data/lib/rspec/core/metadata.rb +16 -64
- data/lib/rspec/core/option_parser.rb +30 -39
- data/lib/rspec/core/ordering.rb +154 -0
- data/lib/rspec/core/pending.rb +12 -69
- data/lib/rspec/core/project_initializer.rb +12 -10
- data/lib/rspec/core/rake_task.rb +5 -108
- data/lib/rspec/core/reporter.rb +15 -18
- data/lib/rspec/core/runner.rb +16 -30
- data/lib/rspec/core/shared_context.rb +3 -5
- data/lib/rspec/core/shared_example_group.rb +3 -51
- data/lib/rspec/core/shared_example_group/collection.rb +1 -19
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/warnings.rb +22 -0
- data/lib/rspec/core/world.rb +12 -8
- data/spec/command_line/order_spec.rb +20 -23
- data/spec/rspec/core/backtrace_formatter_spec.rb +216 -0
- data/spec/rspec/core/command_line_spec.rb +32 -48
- data/spec/rspec/core/configuration_options_spec.rb +19 -50
- data/spec/rspec/core/configuration_spec.rb +142 -713
- data/spec/rspec/core/drb_command_line_spec.rb +2 -0
- data/spec/rspec/core/dsl_spec.rb +0 -1
- data/spec/rspec/core/example_group_spec.rb +192 -223
- data/spec/rspec/core/example_spec.rb +40 -16
- data/spec/rspec/core/filter_manager_spec.rb +2 -2
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -41
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +5 -123
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +2 -87
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +2 -3
- data/spec/rspec/core/formatters/{text_mate_formatted.html → html_formatted-1.8.7-jruby.html} +44 -25
- data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +477 -0
- data/spec/rspec/core/formatters/{html_formatted.html → html_formatted-1.8.7.html} +42 -25
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +425 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +416 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +477 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +419 -0
- data/spec/rspec/core/formatters/html_formatted-2.0.0.html +425 -0
- data/spec/rspec/core/formatters/html_formatter_spec.rb +21 -46
- data/spec/rspec/core/formatters/json_formatter_spec.rb +97 -8
- data/spec/rspec/core/hooks_filtering_spec.rb +5 -5
- data/spec/rspec/core/hooks_spec.rb +61 -47
- data/spec/rspec/core/memoized_helpers_spec.rb +20 -322
- data/spec/rspec/core/metadata_spec.rb +1 -24
- data/spec/rspec/core/option_parser_spec.rb +20 -62
- data/spec/rspec/core/ordering_spec.rb +102 -0
- data/spec/rspec/core/pending_example_spec.rb +0 -40
- data/spec/rspec/core/project_initializer_spec.rb +1 -25
- data/spec/rspec/core/rake_task_spec.rb +5 -72
- data/spec/rspec/core/random_spec.rb +47 -0
- data/spec/rspec/core/reporter_spec.rb +23 -48
- data/spec/rspec/core/runner_spec.rb +31 -39
- data/spec/rspec/core/shared_context_spec.rb +3 -15
- data/spec/rspec/core/shared_example_group/collection_spec.rb +4 -17
- data/spec/rspec/core/shared_example_group_spec.rb +12 -45
- data/spec/rspec/core/{deprecation_spec.rb → warnings_spec.rb} +3 -1
- data/spec/rspec/core_spec.rb +4 -21
- data/spec/spec_helper.rb +41 -5
- data/spec/support/helper_methods.rb +0 -29
- data/spec/support/sandboxed_mock_space.rb +0 -16
- data/spec/support/shared_example_groups.rb +7 -36
- data/spec/support/stderr_splitter.rb +36 -0
- metadata +163 -157
- metadata.gz.sig +1 -0
- data/exe/autospec +0 -13
- data/features/Autotest.md +0 -38
- data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
- data/features/subject/attribute_of_subject.feature +0 -124
- data/features/subject/one_liner_syntax.feature +0 -71
- data/lib/autotest/discover.rb +0 -10
- data/lib/autotest/rspec2.rb +0 -77
- data/lib/rspec/core/backtrace_cleaner.rb +0 -46
- data/lib/rspec/core/backward_compatibility.rb +0 -55
- data/lib/rspec/core/caller_filter.rb +0 -60
- data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
- data/lib/rspec/core/deprecation.rb +0 -26
- data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
- data/lib/rspec/core/extensions/kernel.rb +0 -9
- data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
- data/lib/rspec/core/extensions/ordered.rb +0 -27
- data/lib/rspec/core/formatters/console_codes.rb +0 -42
- data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
- data/lib/rspec/core/metadata_hash_builder.rb +0 -97
- data/lib/rspec/core/minitest_assertions_adapter.rb +0 -28
- data/lib/rspec/core/test_unit_assertions_adapter.rb +0 -30
- data/spec/autotest/discover_spec.rb +0 -49
- data/spec/autotest/failed_results_re_spec.rb +0 -45
- data/spec/autotest/rspec_spec.rb +0 -133
- data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
- data/spec/rspec/core/caller_filter_spec.rb +0 -58
- data/spec/rspec/core/deprecations_spec.rb +0 -59
- data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
- data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
- data/spec/rspec/core/pending_spec.rb +0 -27
- data/spec/support/silence_dsl_deprecations.rb +0 -32
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ut�>X??�!�ԯ���h?u�n�� s������%a��sc��j(x��9b:9a�}��]�L�#mO>2��Z�lHs�AOi�dE�P��;K�����|6�h9/���2�5>fD�{��$�Zx߿�B~��j��g�|"ʙ��Z�!���������D=�'��F"�=r���ϋ�lK(�t�E0k�k_��P��.����Ѫ��.��W\l��9��wsP��RB�VN�ׯi�JW��j��9h�u�4R�8��5�-J�
|
data/exe/autospec
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'rspec/core/deprecation'
|
3
|
-
RSpec.warn_deprecation <<-WARNING
|
4
|
-
************************************************************
|
5
|
-
REMOVAL NOTICE: you are using behaviour that has been
|
6
|
-
removed from rspec-2.
|
7
|
-
|
8
|
-
* The 'autospec' command is no longer supported.
|
9
|
-
* Please use 'autotest' instead.
|
10
|
-
|
11
|
-
This message will be removed from a future version of rspec.
|
12
|
-
************************************************************
|
13
|
-
WARNING
|
data/features/Autotest.md
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
RSpec ships with a specialized subclass of Autotest. To use it, just add a
|
2
|
-
`.rspec` file to your project's root directory, and run the `autotest` command
|
3
|
-
as normal:
|
4
|
-
|
5
|
-
$ autotest
|
6
|
-
|
7
|
-
## Bundler
|
8
|
-
|
9
|
-
The `autotest` command generates a shell command that runs your specs. If you
|
10
|
-
are using Bundler, and you want the shell command to include `bundle exec`,
|
11
|
-
require the Autotest bundler plugin in a `.autotest` file in the project's root
|
12
|
-
directory or your home directory:
|
13
|
-
|
14
|
-
# in .autotest
|
15
|
-
require "autotest/bundler"
|
16
|
-
|
17
|
-
## Upgrading from previous versions of rspec
|
18
|
-
|
19
|
-
Previous versions of RSpec used a different mechanism for telling autotest to
|
20
|
-
invoke RSpec's Autotest extension: it generated an `autotest/discover.rb` file
|
21
|
-
in the project's root directory. This is no longer necessary with the new
|
22
|
-
approach of RSpec looking for a `.rspec` file, so feel free to delete the
|
23
|
-
`autotest/discover.rb` file in the project root if you have one.
|
24
|
-
|
25
|
-
## Gotchas
|
26
|
-
|
27
|
-
### Invalid Option: --tty
|
28
|
-
|
29
|
-
The `--tty` option was [added in rspec-core-2.2.1](changelog), and is used
|
30
|
-
internally by RSpec. If you see an error citing it as an invalid option, you'll
|
31
|
-
probably see there are two or more versions of rspec-core in the backtrace: one
|
32
|
-
< 2.2.1 and one >= 2.2.1.
|
33
|
-
|
34
|
-
This usually happens because you have a newer rspec-core installed, and an
|
35
|
-
older rspec-core specified in a Bundler Gemfile. If this is the case, you can:
|
36
|
-
|
37
|
-
1. specify the newer version in the Gemfile (recommended)
|
38
|
-
2. prefix the `autotest` command with `bundle exec`
|
@@ -1,52 +0,0 @@
|
|
1
|
-
Feature: treat symbols as metadata keys with true values
|
2
|
-
|
3
|
-
Use the treat_symbols_as_metadata_keys_with_true_values option to tell RSpec that :key is shorthand for :key => true.
|
4
|
-
|
5
|
-
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = true }
|
6
|
-
|
7
|
-
Background:
|
8
|
-
Given a file named "spec/spec_helper.rb" with:
|
9
|
-
"""ruby
|
10
|
-
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = true }
|
11
|
-
"""
|
12
|
-
|
13
|
-
Scenario: by default, symbols without values are ignored and the specs are filtered out
|
14
|
-
Given a file named "spec/example_spec.rb" with:
|
15
|
-
"""ruby
|
16
|
-
describe "failed filtering" do
|
17
|
-
it "this will be filted out", :some_tag do
|
18
|
-
true
|
19
|
-
end
|
20
|
-
|
21
|
-
it "so will this" do
|
22
|
-
false
|
23
|
-
end
|
24
|
-
end
|
25
|
-
"""
|
26
|
-
When I run `rspec spec/example_spec.rb --tag some_tag`
|
27
|
-
Then the output should contain "0 examples, 0 failures"
|
28
|
-
And the output should contain "All examples were filtered out"
|
29
|
-
|
30
|
-
Scenario: when treat_symbols_as_metadata_keys_with_true_values is true, specs can be tagged with only a symbol
|
31
|
-
Given a file named "spec/example_spec.rb" with:
|
32
|
-
"""ruby
|
33
|
-
require "spec_helper"
|
34
|
-
describe "run me", :some_tag do
|
35
|
-
it "runs" do
|
36
|
-
true
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "run one of these" do
|
41
|
-
it "run this one", :some_tag do
|
42
|
-
true
|
43
|
-
end
|
44
|
-
|
45
|
-
it "but not me" do
|
46
|
-
false
|
47
|
-
end
|
48
|
-
end
|
49
|
-
"""
|
50
|
-
When I run `rspec spec/example_spec.rb --tag some_tag`
|
51
|
-
Then the output should contain "2 examples, 0 failures"
|
52
|
-
And the output should contain "Run options: include {:some_tag=>true}"
|
@@ -1,124 +0,0 @@
|
|
1
|
-
Feature: attribute of subject
|
2
|
-
|
3
|
-
WARNING: `its` will be extracted from rspec-core-3.0 into its own gem.
|
4
|
-
|
5
|
-
Use the `its` method as a short-hand to generate a nested example group with
|
6
|
-
a single example that specifies the expected value of an attribute of the
|
7
|
-
subject. This can be used with an implicit or explicit subject.
|
8
|
-
|
9
|
-
`its` accepts a symbol or a string, and a block representing the example.
|
10
|
-
|
11
|
-
its(:size) { should eq(1) }
|
12
|
-
its("length") { should eq(1) }
|
13
|
-
|
14
|
-
You can use a string with dots to specify a nested attribute (i.e. an
|
15
|
-
attribute of the attribute of the subject).
|
16
|
-
|
17
|
-
its("phone_numbers.size") { should eq(2) }
|
18
|
-
|
19
|
-
When the subject is a hash, you can pass in an array with a single key to
|
20
|
-
access the value at that key in the hash.
|
21
|
-
|
22
|
-
its([:key]) { should eq(value) }
|
23
|
-
|
24
|
-
Scenario: specify value of an attribute
|
25
|
-
Given a file named "example_spec.rb" with:
|
26
|
-
"""ruby
|
27
|
-
describe Array do
|
28
|
-
context "when first created" do
|
29
|
-
its(:size) { should eq(0) }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
"""
|
33
|
-
When I run `rspec example_spec.rb --format documentation`
|
34
|
-
Then the output should contain:
|
35
|
-
"""
|
36
|
-
Array
|
37
|
-
when first created
|
38
|
-
size
|
39
|
-
should eq 0
|
40
|
-
"""
|
41
|
-
|
42
|
-
Scenario: specify value of a nested attribute
|
43
|
-
Given a file named "example_spec.rb" with:
|
44
|
-
"""ruby
|
45
|
-
class Person
|
46
|
-
attr_reader :phone_numbers
|
47
|
-
def initialize
|
48
|
-
@phone_numbers = []
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe Person do
|
53
|
-
context "with one phone number (555-1212)"do
|
54
|
-
subject do
|
55
|
-
person = Person.new
|
56
|
-
person.phone_numbers << "555-1212"
|
57
|
-
person
|
58
|
-
end
|
59
|
-
|
60
|
-
its("phone_numbers.first") { should eq("555-1212") }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
"""
|
64
|
-
When I run `rspec example_spec.rb --format documentation`
|
65
|
-
Then the output should contain:
|
66
|
-
"""
|
67
|
-
Person
|
68
|
-
with one phone number (555-1212)
|
69
|
-
phone_numbers.first
|
70
|
-
should eq "555-1212"
|
71
|
-
"""
|
72
|
-
|
73
|
-
Scenario: specify value of an attribute of a hash
|
74
|
-
Given a file named "example_spec.rb" with:
|
75
|
-
"""ruby
|
76
|
-
describe Hash do
|
77
|
-
context "with two items" do
|
78
|
-
subject do
|
79
|
-
{:one => 'one', :two => 'two'}
|
80
|
-
end
|
81
|
-
|
82
|
-
its(:size) { should eq(2) }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
"""
|
86
|
-
When I run `rspec example_spec.rb`
|
87
|
-
Then the examples should all pass
|
88
|
-
|
89
|
-
Scenario: specify value for key in a hash
|
90
|
-
Given a file named "example_spec.rb" with:
|
91
|
-
"""ruby
|
92
|
-
describe Hash do
|
93
|
-
context "with keys :one and 'two'" do
|
94
|
-
subject do
|
95
|
-
{:one => 1, "two" => 2}
|
96
|
-
end
|
97
|
-
|
98
|
-
its([:one]) { should eq(1) }
|
99
|
-
its(["two"]) { should eq(2) }
|
100
|
-
end
|
101
|
-
end
|
102
|
-
"""
|
103
|
-
When I run `rspec example_spec.rb`
|
104
|
-
Then the examples should all pass
|
105
|
-
|
106
|
-
Scenario: specify value for key in a hash-like object
|
107
|
-
Given a file named "example_spec.rb" with:
|
108
|
-
"""ruby
|
109
|
-
require 'matrix'
|
110
|
-
|
111
|
-
describe Matrix do
|
112
|
-
context "with values [[1, 2], [3, 4]]" do
|
113
|
-
subject do
|
114
|
-
Matrix[[1, 2], [3, 4]]
|
115
|
-
end
|
116
|
-
|
117
|
-
its([0, 1]) { should eq(2) }
|
118
|
-
its([1, 0]) { should eq(3) }
|
119
|
-
its([1, 2]) { should be_nil }
|
120
|
-
end
|
121
|
-
end
|
122
|
-
"""
|
123
|
-
When I run `rspec example_spec.rb`
|
124
|
-
Then the examples should all pass
|
@@ -1,71 +0,0 @@
|
|
1
|
-
Feature: One-liner syntax
|
2
|
-
|
3
|
-
RSpec supports a one-liner syntax for setting an expectation
|
4
|
-
on the `subject`. RSpec will give the examples a doc string
|
5
|
-
that is auto-generated from the matcher used in the example.
|
6
|
-
This is designed specifically to help avoid duplication in
|
7
|
-
situations where the doc string and the matcher used in the
|
8
|
-
example mirror each other exactly. When used excessively,
|
9
|
-
it can produce documentation output that does not read well
|
10
|
-
or contribute to understanding the object you are describing.
|
11
|
-
|
12
|
-
This comes in two flavors:
|
13
|
-
|
14
|
-
* `is_expected` is defined simply as `expect(subject)` and is
|
15
|
-
designed for when you are using rspec-expectations with its
|
16
|
-
newer expect-based syntax.
|
17
|
-
* `should` was designed back when rspec-expectations only had
|
18
|
-
a should-based syntax. However, it continues to be available
|
19
|
-
and work even if the `:should` syntax is disabled (since that
|
20
|
-
merely removes `Object#should` but this is
|
21
|
-
`RSpec::Core::ExampleGroup#should`).
|
22
|
-
|
23
|
-
Note: this feature is only available when using rspec-expectations.
|
24
|
-
|
25
|
-
Scenario: implicit subject
|
26
|
-
Given a file named "example_spec.rb" with:
|
27
|
-
"""ruby
|
28
|
-
describe Array do
|
29
|
-
describe "when first created" do
|
30
|
-
# Rather than:
|
31
|
-
# it "should be empty" do
|
32
|
-
# subject.should be_empty
|
33
|
-
# end
|
34
|
-
|
35
|
-
it { should be_empty }
|
36
|
-
# or
|
37
|
-
it { is_expected.to be_empty }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
"""
|
41
|
-
When I run `rspec example_spec.rb --format doc`
|
42
|
-
Then the examples should all pass
|
43
|
-
And the output should contain:
|
44
|
-
"""
|
45
|
-
Array
|
46
|
-
when first created
|
47
|
-
should be empty
|
48
|
-
should be empty
|
49
|
-
"""
|
50
|
-
|
51
|
-
Scenario: explicit subject
|
52
|
-
Given a file named "example_spec.rb" with:
|
53
|
-
"""ruby
|
54
|
-
describe Array do
|
55
|
-
describe "with 3 items" do
|
56
|
-
subject { [1,2,3] }
|
57
|
-
it { should_not be_empty }
|
58
|
-
# or
|
59
|
-
it { is_expected.not_to be_empty }
|
60
|
-
end
|
61
|
-
end
|
62
|
-
"""
|
63
|
-
When I run `rspec example_spec.rb --format doc`
|
64
|
-
Then the examples should all pass
|
65
|
-
And the output should contain:
|
66
|
-
"""
|
67
|
-
Array
|
68
|
-
with 3 items
|
69
|
-
should not be empty
|
70
|
-
should not be empty
|
71
|
-
"""
|
data/lib/autotest/discover.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
# try to load rspec/autotest so we can check if the constant is defined below.
|
3
|
-
require 'rspec/autotest'
|
4
|
-
rescue LoadError
|
5
|
-
# ignore. We print a deprecation warning later.
|
6
|
-
end
|
7
|
-
|
8
|
-
if File.exist?("./.rspec") && !defined?(::RSpec::Autotest)
|
9
|
-
Autotest.add_discovery { "rspec2" }
|
10
|
-
end
|
data/lib/autotest/rspec2.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'rspec/autotest'
|
3
|
-
rescue LoadError
|
4
|
-
require 'autotest'
|
5
|
-
|
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
|
11
|
-
|
12
|
-
RSPEC_EXECUTABLE = File.expand_path('../../../exe/rspec', __FILE__)
|
13
|
-
|
14
|
-
def initialize
|
15
|
-
super()
|
16
|
-
clear_mappings
|
17
|
-
setup_rspec_project_mappings
|
18
|
-
|
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
|
24
|
-
|
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
|
37
|
-
|
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
|
45
|
-
end
|
46
|
-
return filters
|
47
|
-
end
|
48
|
-
|
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
|
54
|
-
|
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
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
def suffix
|
65
|
-
using_bundler? ? "" : defined?(:Gem) ? " -rrubygems" : ""
|
66
|
-
end
|
67
|
-
|
68
|
-
def using_bundler?
|
69
|
-
prefix =~ /bundle exec/
|
70
|
-
end
|
71
|
-
|
72
|
-
def gemfile?
|
73
|
-
File.exist?('./Gemfile')
|
74
|
-
end
|
75
|
-
end
|
76
|
-
Autotest.add_hook(:ran_command) { warn "\n\e[31mrspec-core's built in autotest support is deprecated and will be removed in RSpec 3. Please switch to the rspec-autotest gem.\e[0m" }
|
77
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module RSpec
|
2
|
-
module Core
|
3
|
-
class BacktraceCleaner
|
4
|
-
|
5
|
-
DEFAULT_EXCLUSION_PATTERNS = [
|
6
|
-
/\/lib\d*\/ruby\//,
|
7
|
-
/org\/jruby\//,
|
8
|
-
/bin\//,
|
9
|
-
%r|/gems/|,
|
10
|
-
/spec\/spec_helper\.rb/,
|
11
|
-
/lib\/rspec\/(core|expectations|matchers|mocks)/
|
12
|
-
]
|
13
|
-
|
14
|
-
attr_accessor :inclusion_patterns
|
15
|
-
attr_accessor :exclusion_patterns
|
16
|
-
|
17
|
-
def initialize(inclusion_patterns=nil, exclusion_patterns=DEFAULT_EXCLUSION_PATTERNS.dup)
|
18
|
-
@exclusion_patterns = exclusion_patterns
|
19
|
-
|
20
|
-
if inclusion_patterns.nil?
|
21
|
-
@inclusion_patterns = (matches_an_exclusion_pattern? Dir.getwd) ? [Regexp.new(Dir.getwd)] : []
|
22
|
-
else
|
23
|
-
@inclusion_patterns = inclusion_patterns
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def exclude?(line)
|
28
|
-
@inclusion_patterns.none? {|p| line =~ p} and matches_an_exclusion_pattern?(line)
|
29
|
-
end
|
30
|
-
|
31
|
-
def full_backtrace=(true_or_false)
|
32
|
-
@exclusion_patterns = true_or_false ? [] : DEFAULT_EXCLUSION_PATTERNS.dup
|
33
|
-
end
|
34
|
-
|
35
|
-
def full_backtrace?
|
36
|
-
@exclusion_patterns.empty?
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def matches_an_exclusion_pattern?(line)
|
42
|
-
@exclusion_patterns.any? {|p| line =~ p}
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
module RSpec
|
2
|
-
module Core
|
3
|
-
# @private
|
4
|
-
module ConstMissing
|
5
|
-
# Used to print deprecation warnings for Rspec and Spec constants (use
|
6
|
-
# RSpec instead)
|
7
|
-
def const_missing(name)
|
8
|
-
case name
|
9
|
-
when :Rspec, :Spec
|
10
|
-
RSpec.deprecate(name.to_s, :replacement => "RSpec")
|
11
|
-
RSpec
|
12
|
-
else
|
13
|
-
begin
|
14
|
-
super
|
15
|
-
rescue Exception => e
|
16
|
-
e.backtrace.reject! {|l| l =~ Regexp.compile(__FILE__) }
|
17
|
-
raise e
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
module Runner
|
25
|
-
# @deprecated use RSpec.configure instead.
|
26
|
-
def self.configure(&block)
|
27
|
-
RSpec.deprecate("Spec::Runner.configure", :replacement => "RSpec.configure")
|
28
|
-
RSpec.configure(&block)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# @private
|
33
|
-
module Rake
|
34
|
-
# Used to print deprecation warnings for Rake::SpecTask constant (use
|
35
|
-
# RSpec::Core::RakeTask instead)
|
36
|
-
def self.const_missing(name)
|
37
|
-
case name
|
38
|
-
when :SpecTask
|
39
|
-
RSpec.deprecate("Spec::Rake::SpecTask", :replacement => "RSpec::Core::RakeTask")
|
40
|
-
require 'rspec/core/rake_task'
|
41
|
-
RSpec::Core::RakeTask
|
42
|
-
else
|
43
|
-
begin
|
44
|
-
super
|
45
|
-
rescue Exception => e
|
46
|
-
e.backtrace.reject! {|l| l =~ Regexp.compile(__FILE__) }
|
47
|
-
raise e
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
Object.extend(RSpec::Core::ConstMissing)
|