rspec-core 2.99.2 → 3.0.0.beta1
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.
- 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
|
@@ -88,7 +88,7 @@ Feature: mock with flexmock
|
|
|
88
88
|
|
|
89
89
|
describe "RSpec.configuration.mock_framework.framework_name" do
|
|
90
90
|
it "returns :flexmock" do
|
|
91
|
-
RSpec.configuration.mock_framework.framework_name.
|
|
91
|
+
expect(RSpec.configuration.mock_framework.framework_name).to eq(:flexmock)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
"""
|
|
@@ -88,7 +88,7 @@ Feature: mock with mocha
|
|
|
88
88
|
|
|
89
89
|
describe "RSpec.configuration.mock_framework.framework_name" do
|
|
90
90
|
it "returns :mocha" do
|
|
91
|
-
RSpec.configuration.mock_framework.framework_name.
|
|
91
|
+
expect(RSpec.configuration.mock_framework.framework_name).to eq(:mocha)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
"""
|
|
@@ -88,7 +88,7 @@ Feature: mock with rr
|
|
|
88
88
|
|
|
89
89
|
describe "RSpec.configuration.mock_framework.framework_name" do
|
|
90
90
|
it "returns :rr" do
|
|
91
|
-
RSpec.configuration.mock_framework.framework_name.
|
|
91
|
+
expect(RSpec.configuration.mock_framework.framework_name).to eq(:rr)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
"""
|
|
@@ -13,7 +13,7 @@ Feature: mock with rspec
|
|
|
13
13
|
describe "mocking with RSpec" do
|
|
14
14
|
it "passes when it should" do
|
|
15
15
|
receiver = double('receiver')
|
|
16
|
-
receiver.
|
|
16
|
+
expect(receiver).to receive(:message)
|
|
17
17
|
receiver.message
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -31,7 +31,7 @@ Feature: mock with rspec
|
|
|
31
31
|
describe "mocking with RSpec" do
|
|
32
32
|
it "fails when it should" do
|
|
33
33
|
receiver = double('receiver')
|
|
34
|
-
receiver.
|
|
34
|
+
expect(receiver).to receive(:message)
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
"""
|
|
@@ -49,7 +49,7 @@ Feature: mock with rspec
|
|
|
49
49
|
it "is listed as pending" do
|
|
50
50
|
pending do
|
|
51
51
|
receiver = double('receiver')
|
|
52
|
-
receiver.
|
|
52
|
+
expect(receiver).to receive(:message)
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
end
|
|
@@ -69,7 +69,7 @@ Feature: mock with rspec
|
|
|
69
69
|
it "fails with FIXED" do
|
|
70
70
|
pending do
|
|
71
71
|
receiver = double('receiver')
|
|
72
|
-
receiver.
|
|
72
|
+
expect(receiver).to receive(:message)
|
|
73
73
|
receiver.message
|
|
74
74
|
end
|
|
75
75
|
end
|
|
@@ -89,7 +89,7 @@ Feature: mock with rspec
|
|
|
89
89
|
|
|
90
90
|
describe "RSpec.configuration.mock_framework.framework_name" do
|
|
91
91
|
it "returns :rspec" do
|
|
92
|
-
RSpec.configuration.mock_framework.framework_name.
|
|
92
|
+
expect(RSpec.configuration.mock_framework.framework_name).to eq(:rspec)
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
"""
|
|
@@ -65,7 +65,7 @@ Feature: pending examples
|
|
|
65
65
|
describe "an example" do
|
|
66
66
|
it "is implemented but waiting" do
|
|
67
67
|
pending("something else getting finished") do
|
|
68
|
-
true.
|
|
68
|
+
expect(true).to be(true)
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
end
|
|
@@ -113,7 +113,7 @@ Feature: pending examples
|
|
|
113
113
|
"""ruby
|
|
114
114
|
describe "an example" do
|
|
115
115
|
it "checks something" do
|
|
116
|
-
(3+4).
|
|
116
|
+
expect(3+4).to eq(7)
|
|
117
117
|
end
|
|
118
118
|
specify do
|
|
119
119
|
pending
|
|
@@ -135,10 +135,10 @@ Feature: pending examples
|
|
|
135
135
|
"""ruby
|
|
136
136
|
describe "an example" do
|
|
137
137
|
it "checks something" do
|
|
138
|
-
(3+4).
|
|
138
|
+
expect(3+4).to eq(7)
|
|
139
139
|
end
|
|
140
140
|
pending do
|
|
141
|
-
"string".reverse.
|
|
141
|
+
expect("string".reverse).to eq("gnirts")
|
|
142
142
|
end
|
|
143
143
|
end
|
|
144
144
|
"""
|
|
@@ -176,7 +176,7 @@ Feature: pending examples
|
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
describe "a passing spec" do
|
|
179
|
-
def run_test; true.
|
|
179
|
+
def run_test; expect(true).to be(true); end
|
|
180
180
|
|
|
181
181
|
it "fails when pending with a true :if condition" do
|
|
182
182
|
pending("true :if", :if => true) { run_test }
|
|
@@ -8,7 +8,7 @@ end
|
|
|
8
8
|
|
|
9
9
|
Then /^the output should not contain any of these:$/ do |table|
|
|
10
10
|
table.raw.flatten.each do |string|
|
|
11
|
-
all_output.
|
|
11
|
+
expect(all_output).not_to match(regexp(string))
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -17,7 +17,7 @@ Then /^the output should contain one of the following:$/ do |table|
|
|
|
17
17
|
all_output =~ regexp(string)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
matching_output.
|
|
20
|
+
expect(matching_output.count).to eq(1)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
Then /^the example(?:s)? should(?: all)? pass$/ do
|
|
@@ -38,7 +38,7 @@ Then /^the backtrace\-normalized output should contain:$/ do |partial_output|
|
|
|
38
38
|
line =~ /(^\s+# [^:]+:\d+)/ ? $1 : line # http://rubular.com/r/zDD7DdWyzF
|
|
39
39
|
end.join("\n")
|
|
40
40
|
|
|
41
|
-
normalized_output.
|
|
41
|
+
expect(normalized_output).to match(regexp(partial_output))
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# This step can be generalized if it's ever used to test other colors
|
|
@@ -13,7 +13,7 @@ Feature: explicit subject
|
|
|
13
13
|
describe Array, "with some elements" do
|
|
14
14
|
subject { [1,2,3] }
|
|
15
15
|
it "should have the prescribed elements" do
|
|
16
|
-
subject.
|
|
16
|
+
expect(subject).to eq([1,2,3])
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
"""
|
|
@@ -27,7 +27,7 @@ Feature: explicit subject
|
|
|
27
27
|
subject { [1,2,3] }
|
|
28
28
|
describe "with some elements" do
|
|
29
29
|
it "should have the prescribed elements" do
|
|
30
|
-
subject.
|
|
30
|
+
expect(subject).to eq([1,2,3])
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -42,7 +42,7 @@ Feature: explicit subject
|
|
|
42
42
|
subject { [] }
|
|
43
43
|
before { subject.push(1,2,3) }
|
|
44
44
|
it "should have the prescribed elements" do
|
|
45
|
-
subject.
|
|
45
|
+
expect(subject).to eq([1,2,3])
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
"""
|
|
@@ -57,7 +57,7 @@ Feature: explicit subject
|
|
|
57
57
|
subject { prepared_array }
|
|
58
58
|
describe "with some elements" do
|
|
59
59
|
it "should have the prescribed elements" do
|
|
60
|
-
subject.
|
|
60
|
+
expect(subject).to eq([1,2,3])
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
end
|
|
@@ -71,9 +71,9 @@ Feature: explicit subject
|
|
|
71
71
|
describe Array do
|
|
72
72
|
describe "#[]" do
|
|
73
73
|
context "with index out of bounds" do
|
|
74
|
-
before { Array.
|
|
74
|
+
before { expect(Array).to receive(:one_two_three).once.and_return([1,2,3]) }
|
|
75
75
|
subject { Array.one_two_three[42] }
|
|
76
|
-
it {
|
|
76
|
+
it { should be_nil }
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
end
|
|
@@ -89,10 +89,10 @@ Feature: explicit subject
|
|
|
89
89
|
let(:prepared_array) { [1,2,3] }
|
|
90
90
|
subject! { prepared_array.pop }
|
|
91
91
|
it "removes the last value from the array" do
|
|
92
|
-
prepared_array.
|
|
92
|
+
expect(prepared_array).to eq([1,2])
|
|
93
93
|
end
|
|
94
94
|
it "returns the last value of the array" do
|
|
95
|
-
subject.
|
|
95
|
+
expect(subject).to eq(3)
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Feature: implicit receiver
|
|
2
|
+
|
|
3
|
+
When `should` is called in an example without an explicit receiver, it is
|
|
4
|
+
invoked against the subject (explicit or implicit).
|
|
5
|
+
|
|
6
|
+
Scenario: implicit subject
|
|
7
|
+
Given a file named "example_spec.rb" with:
|
|
8
|
+
"""ruby
|
|
9
|
+
describe Array do
|
|
10
|
+
describe "when first created" do
|
|
11
|
+
it { should be_empty }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
"""
|
|
15
|
+
When I run `rspec example_spec.rb`
|
|
16
|
+
Then the examples should all pass
|
|
17
|
+
|
|
18
|
+
Scenario: explicit subject
|
|
19
|
+
Given a file named "example_spec.rb" with:
|
|
20
|
+
"""ruby
|
|
21
|
+
describe Array do
|
|
22
|
+
describe "with 3 items" do
|
|
23
|
+
subject { [1,2,3] }
|
|
24
|
+
it { should_not be_empty }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
"""
|
|
28
|
+
When I run `rspec example_spec.rb`
|
|
29
|
+
Then the examples should all pass
|
|
@@ -12,7 +12,7 @@ Feature: implicitly defined subject
|
|
|
12
12
|
"""ruby
|
|
13
13
|
describe Array do
|
|
14
14
|
it "should be empty when first created" do
|
|
15
|
-
subject.
|
|
15
|
+
expect(subject).to be_empty
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
"""
|
|
@@ -25,7 +25,7 @@ Feature: implicitly defined subject
|
|
|
25
25
|
describe Array do
|
|
26
26
|
describe "when first created" do
|
|
27
27
|
it "should be empty" do
|
|
28
|
-
subject.
|
|
28
|
+
expect(subject).to be_empty
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -47,13 +47,13 @@ Feature: implicitly defined subject
|
|
|
47
47
|
describe ArrayWithOneElement do
|
|
48
48
|
context "referenced as subject" do
|
|
49
49
|
it "should be empty (because it is the Array declared at the top)" do
|
|
50
|
-
subject.
|
|
50
|
+
expect(subject).to be_empty
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
context "created in the example" do
|
|
55
55
|
it "should not be empty" do
|
|
56
|
-
ArrayWithOneElement.new.
|
|
56
|
+
expect(ArrayWithOneElement.new).not_to be_empty
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
end
|
data/features/support/env.rb
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
require 'aruba/cucumber'
|
|
2
2
|
|
|
3
|
-
timeouts = { 'java' => 60 }
|
|
4
|
-
|
|
5
3
|
Before do
|
|
6
|
-
|
|
4
|
+
if RUBY_PLATFORM =~ /java/ || defined?(Rubinius)
|
|
5
|
+
@aruba_timeout_seconds = 60
|
|
6
|
+
else
|
|
7
|
+
@aruba_timeout_seconds = 10
|
|
8
|
+
end
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
Aruba.configure do |config|
|
|
@@ -12,3 +14,8 @@ Aruba.configure do |config|
|
|
|
12
14
|
end
|
|
13
15
|
end if RUBY_PLATFORM == 'java'
|
|
14
16
|
|
|
17
|
+
Aruba.configure do |config|
|
|
18
|
+
config.before_cmd do |cmd|
|
|
19
|
+
set_env('RBXOPT', "-Xint=true #{ENV['RBXOPT']}") # disable JIT since these processes are so short lived
|
|
20
|
+
end
|
|
21
|
+
end if defined?(Rubinius)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
if defined?(Cucumber)
|
|
2
|
+
require 'shellwords'
|
|
3
|
+
Before do
|
|
4
|
+
set_env('SPEC_OPTS', "-r#{Shellwords.escape(__FILE__)}")
|
|
5
|
+
end
|
|
6
|
+
else
|
|
7
|
+
RSpec.configure do |rspec|
|
|
8
|
+
rspec.mock_with :rspec do |mocks|
|
|
9
|
+
mocks.syntax = :expect
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
rspec.expect_with :rspec do |expectations|
|
|
13
|
+
expectations.syntax = :expect
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/rspec/core.rb
CHANGED
|
@@ -11,27 +11,27 @@ end
|
|
|
11
11
|
require 'set'
|
|
12
12
|
require 'time'
|
|
13
13
|
require 'rbconfig'
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
require_rspec['core/version']
|
|
16
|
+
|
|
17
|
+
require 'rspec/support/caller_filter'
|
|
18
|
+
require 'rspec/core/warnings'
|
|
19
|
+
require 'rspec/support/warnings'
|
|
20
|
+
|
|
21
|
+
require_rspec['core/flat_map']
|
|
15
22
|
require_rspec['core/filter_manager']
|
|
16
23
|
require_rspec['core/dsl']
|
|
17
|
-
require_rspec['core/extensions/kernel']
|
|
18
|
-
require_rspec['core/extensions/instance_eval_with_args']
|
|
19
|
-
require_rspec['core/extensions/module_eval_with_args']
|
|
20
|
-
require_rspec['core/extensions/ordered']
|
|
21
|
-
require_rspec['core/deprecation']
|
|
22
|
-
require_rspec['core/backward_compatibility']
|
|
23
24
|
require_rspec['core/reporter']
|
|
24
25
|
|
|
25
|
-
require_rspec['core/metadata_hash_builder']
|
|
26
26
|
require_rspec['core/hooks']
|
|
27
27
|
require_rspec['core/memoized_helpers']
|
|
28
28
|
require_rspec['core/metadata']
|
|
29
29
|
require_rspec['core/pending']
|
|
30
30
|
require_rspec['core/formatters']
|
|
31
|
+
require_rspec['core/ordering']
|
|
31
32
|
|
|
32
33
|
require_rspec['core/world']
|
|
33
34
|
require_rspec['core/configuration']
|
|
34
|
-
require_rspec['core/project_initializer']
|
|
35
35
|
require_rspec['core/option_parser']
|
|
36
36
|
require_rspec['core/configuration_options']
|
|
37
37
|
require_rspec['core/command_line']
|
|
@@ -40,19 +40,10 @@ require_rspec['core/example']
|
|
|
40
40
|
require_rspec['core/shared_example_group/collection']
|
|
41
41
|
require_rspec['core/shared_example_group']
|
|
42
42
|
require_rspec['core/example_group']
|
|
43
|
-
require_rspec['core/version']
|
|
44
43
|
|
|
45
44
|
module RSpec
|
|
46
45
|
autoload :SharedContext, 'rspec/core/shared_context'
|
|
47
46
|
|
|
48
|
-
class << self
|
|
49
|
-
# @private
|
|
50
|
-
# Counts the number of times RSpec.reset needs to be called to prevent
|
|
51
|
-
# a warning about reset's no longer being implicitly invoked.
|
|
52
|
-
attr_accessor :resets_required
|
|
53
|
-
RSpec.resets_required = 0
|
|
54
|
-
end
|
|
55
|
-
|
|
56
47
|
# @private
|
|
57
48
|
def self.wants_to_quit
|
|
58
49
|
# Used internally to determine what to do when a SIGINT is received
|
|
@@ -78,34 +69,9 @@ module RSpec
|
|
|
78
69
|
end
|
|
79
70
|
|
|
80
71
|
# @private
|
|
81
|
-
# Query to check if the user has called RSpec.reset
|
|
82
|
-
def self.user_has_called_reset?
|
|
83
|
-
@user_has_called_reset ||= false
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# @private
|
|
87
|
-
# Warns that RSpec 3.0.0 will no longer call reset for users
|
|
88
|
-
def self.warn_about_calling_reset
|
|
89
|
-
RSpec.warn_deprecation(<<-EOD)
|
|
90
|
-
Calling `RSpec::Core::Runner.run` will no longer implicitly invoke
|
|
91
|
-
`RSpec.reset` as of RSpec 3.0.0. If you need RSpec to be reset between your
|
|
92
|
-
calls to `RSpec::Core::Runner.run` please invoke `RSpec.reset` manually in the
|
|
93
|
-
appropriate place.
|
|
94
|
-
EOD
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# @public
|
|
98
72
|
# Used internally to ensure examples get reloaded between multiple runs in
|
|
99
73
|
# the same process.
|
|
100
74
|
def self.reset
|
|
101
|
-
RSpec.resets_required -= 1
|
|
102
|
-
internal_reset
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# @private
|
|
106
|
-
# @see RSpec.reset
|
|
107
|
-
# Warns if the user has invoked RSpec.run twice in the same process.
|
|
108
|
-
def self.internal_reset
|
|
109
75
|
@world = nil
|
|
110
76
|
@configuration = nil
|
|
111
77
|
end
|
|
@@ -203,15 +169,14 @@ WARNING
|
|
|
203
169
|
# it.
|
|
204
170
|
class Time
|
|
205
171
|
class << self
|
|
206
|
-
define_method(:now
|
|
172
|
+
define_method(:now, &::Time.method(:now))
|
|
207
173
|
end
|
|
208
174
|
end
|
|
209
175
|
|
|
210
176
|
# @private path to executable file
|
|
211
177
|
def self.path_to_executable
|
|
212
|
-
File.expand_path('../../../exe/rspec', __FILE__)
|
|
178
|
+
@path_to_executable ||= File.expand_path('../../../exe/rspec', __FILE__)
|
|
213
179
|
end
|
|
214
|
-
|
|
215
180
|
end
|
|
216
181
|
|
|
217
182
|
MODULES_TO_AUTOLOAD = {
|
|
@@ -236,5 +201,3 @@ WARNING
|
|
|
236
201
|
::RSpec.const_get(name)
|
|
237
202
|
end
|
|
238
203
|
end
|
|
239
|
-
|
|
240
|
-
require_rspec['core/backward_compatibility']
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# This code was (mostly) ported from the backports gem (https://github.com/marcandre/backports).
|
|
2
|
+
# The goal is to provide a random number generator in Ruby versions that do not have one.
|
|
3
|
+
# This was added to support localization of random spec ordering.
|
|
4
|
+
#
|
|
5
|
+
# These were in multiple files in backports, but merged into one here.
|
|
6
|
+
|
|
7
|
+
module RSpec
|
|
8
|
+
module Core
|
|
9
|
+
# Methods used internally by the backports.
|
|
10
|
+
module Backports
|
|
11
|
+
# Helper method to coerce a value into a specific class.
|
|
12
|
+
# Raises a TypeError if the coercion fails or the returned value
|
|
13
|
+
# is not of the right class.
|
|
14
|
+
# (from Rubinius)
|
|
15
|
+
def self.coerce_to(obj, cls, meth)
|
|
16
|
+
return obj if obj.kind_of?(cls)
|
|
17
|
+
|
|
18
|
+
begin
|
|
19
|
+
ret = obj.__send__(meth)
|
|
20
|
+
rescue Exception => e
|
|
21
|
+
raise TypeError, "Coercion error: #{obj.inspect}.#{meth} => #{cls} failed:\n" \
|
|
22
|
+
"(#{e.message})"
|
|
23
|
+
end
|
|
24
|
+
raise TypeError, "Coercion error: obj.#{meth} did NOT return a #{cls} (was #{ret.class})" unless ret.kind_of? cls
|
|
25
|
+
ret
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.coerce_to_int(obj)
|
|
29
|
+
coerce_to(obj, Integer, :to_int)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Used internally to make it easy to deal with optional arguments
|
|
33
|
+
# (from Rubinius)
|
|
34
|
+
Undefined = Object.new
|
|
35
|
+
|
|
36
|
+
class Random
|
|
37
|
+
# An implementation of Mersenne Twister MT19937 in Ruby
|
|
38
|
+
class MT19937
|
|
39
|
+
STATE_SIZE = 624
|
|
40
|
+
LAST_STATE = STATE_SIZE - 1
|
|
41
|
+
PAD_32_BITS = 0xffffffff
|
|
42
|
+
|
|
43
|
+
# See seed=
|
|
44
|
+
def initialize(seed)
|
|
45
|
+
self.seed = seed
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
LAST_31_BITS = 0x7fffffff
|
|
49
|
+
OFFSET = 397
|
|
50
|
+
|
|
51
|
+
# Generates a completely new state out of the previous one.
|
|
52
|
+
def next_state
|
|
53
|
+
STATE_SIZE.times do |i|
|
|
54
|
+
mix = @state[i] & 0x80000000 | @state[i+1 - STATE_SIZE] & 0x7fffffff
|
|
55
|
+
@state[i] = @state[i+OFFSET - STATE_SIZE] ^ (mix >> 1)
|
|
56
|
+
@state[i] ^= 0x9908b0df if mix.odd?
|
|
57
|
+
end
|
|
58
|
+
@last_read = -1
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Seed must be either an Integer (only the first 32 bits will be used)
|
|
62
|
+
# or an Array of Integers (of which only the first 32 bits will be used)
|
|
63
|
+
#
|
|
64
|
+
# No conversion or type checking is done at this level
|
|
65
|
+
def seed=(seed)
|
|
66
|
+
case seed
|
|
67
|
+
when Integer
|
|
68
|
+
@state = Array.new(STATE_SIZE)
|
|
69
|
+
@state[0] = seed & PAD_32_BITS
|
|
70
|
+
(1..LAST_STATE).each do |i|
|
|
71
|
+
@state[i] = (1812433253 * (@state[i-1] ^ @state[i-1]>>30) + i)& PAD_32_BITS
|
|
72
|
+
end
|
|
73
|
+
@last_read = LAST_STATE
|
|
74
|
+
when Array
|
|
75
|
+
self.seed = 19650218
|
|
76
|
+
i=1
|
|
77
|
+
j=0
|
|
78
|
+
[STATE_SIZE, seed.size].max.times do
|
|
79
|
+
@state[i] = (@state[i] ^ (@state[i-1] ^ @state[i-1]>>30) * 1664525) + j + seed[j] & PAD_32_BITS
|
|
80
|
+
if (i+=1) >= STATE_SIZE
|
|
81
|
+
@state[0] = @state[-1]
|
|
82
|
+
i = 1
|
|
83
|
+
end
|
|
84
|
+
j = 0 if (j+=1) >= seed.size
|
|
85
|
+
end
|
|
86
|
+
(STATE_SIZE-1).times do
|
|
87
|
+
@state[i] = (@state[i] ^ (@state[i-1] ^ @state[i-1]>>30) * 1566083941) - i & PAD_32_BITS
|
|
88
|
+
if (i+=1) >= STATE_SIZE
|
|
89
|
+
@state[0] = @state[-1]
|
|
90
|
+
i = 1
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
@state[0] = 0x80000000
|
|
94
|
+
else
|
|
95
|
+
raise ArgumentError, "Seed must be an Integer or an Array"
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Returns a random Integer from the range 0 ... (1 << 32)
|
|
100
|
+
def random_32_bits
|
|
101
|
+
next_state if @last_read >= LAST_STATE
|
|
102
|
+
@last_read += 1
|
|
103
|
+
y = @state[@last_read]
|
|
104
|
+
# Tempering
|
|
105
|
+
y ^= (y >> 11)
|
|
106
|
+
y ^= (y << 7) & 0x9d2c5680
|
|
107
|
+
y ^= (y << 15) & 0xefc60000
|
|
108
|
+
y ^= (y >> 18)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Supplement the MT19937 class with methods to do
|
|
112
|
+
# conversions the same way as MRI.
|
|
113
|
+
# No argument checking is done here either.
|
|
114
|
+
|
|
115
|
+
FLOAT_FACTOR = 1.0/9007199254740992.0
|
|
116
|
+
# generates a random number on [0,1) with 53-bit resolution
|
|
117
|
+
def random_float
|
|
118
|
+
((random_32_bits >> 5) * 67108864.0 + (random_32_bits >> 6)) * FLOAT_FACTOR;
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Returns an integer within 0...upto
|
|
122
|
+
def random_integer(upto)
|
|
123
|
+
n = upto - 1
|
|
124
|
+
nb_full_32 = 0
|
|
125
|
+
while n > PAD_32_BITS
|
|
126
|
+
n >>= 32
|
|
127
|
+
nb_full_32 += 1
|
|
128
|
+
end
|
|
129
|
+
mask = mask_32_bits(n)
|
|
130
|
+
begin
|
|
131
|
+
rand = random_32_bits & mask
|
|
132
|
+
nb_full_32.times do
|
|
133
|
+
rand <<= 32
|
|
134
|
+
rand |= random_32_bits
|
|
135
|
+
end
|
|
136
|
+
end until rand < upto
|
|
137
|
+
rand
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def random_bytes(nb)
|
|
141
|
+
nb_32_bits = (nb + 3) / 4
|
|
142
|
+
random = nb_32_bits.times.map { random_32_bits }
|
|
143
|
+
random.pack("L" * nb_32_bits)[0, nb]
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def state_as_bignum
|
|
147
|
+
b = 0
|
|
148
|
+
@state.each_with_index do |val, i|
|
|
149
|
+
b |= val << (32 * i)
|
|
150
|
+
end
|
|
151
|
+
b
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def left # It's actually the number of words left + 1, as per MRI...
|
|
155
|
+
MT19937::STATE_SIZE - @last_read
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def marshal_dump
|
|
159
|
+
[state_as_bignum, left]
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def marshal_load(ary)
|
|
163
|
+
b, left = ary
|
|
164
|
+
@last_read = MT19937::STATE_SIZE - left
|
|
165
|
+
@state = Array.new(STATE_SIZE)
|
|
166
|
+
STATE_SIZE.times do |i|
|
|
167
|
+
@state[i] = b & PAD_32_BITS
|
|
168
|
+
b >>= 32
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Convert an Integer seed of arbitrary size to either a single 32 bit integer, or an Array of 32 bit integers
|
|
173
|
+
def self.convert_seed(seed)
|
|
174
|
+
seed = seed.abs
|
|
175
|
+
long_values = []
|
|
176
|
+
begin
|
|
177
|
+
long_values << (seed & PAD_32_BITS)
|
|
178
|
+
seed >>= 32
|
|
179
|
+
end until seed == 0
|
|
180
|
+
|
|
181
|
+
long_values.pop if long_values[-1] == 1 && long_values.size > 1 # Done to allow any kind of sequence of integers
|
|
182
|
+
|
|
183
|
+
long_values.size > 1 ? long_values : long_values.first
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def self.[](seed)
|
|
187
|
+
new(convert_seed(seed))
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
private
|
|
191
|
+
|
|
192
|
+
MASK_BY = [1,2,4,8,16]
|
|
193
|
+
def mask_32_bits(n)
|
|
194
|
+
MASK_BY.each do |shift|
|
|
195
|
+
n |= n >> shift
|
|
196
|
+
end
|
|
197
|
+
n
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Implementation corresponding to the actual Random class of Ruby
|
|
202
|
+
# The actual random generator (mersenne twister) is in MT19937.
|
|
203
|
+
# Ruby specific conversions are handled in bits_and_bytes.
|
|
204
|
+
# The high level stuff (argument checking) is done here.
|
|
205
|
+
module Implementation
|
|
206
|
+
attr_reader :seed
|
|
207
|
+
|
|
208
|
+
def initialize(seed = 0)
|
|
209
|
+
super()
|
|
210
|
+
seed_rand seed
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def seed_rand(new_seed = 0)
|
|
214
|
+
new_seed = Backports.coerce_to_int(new_seed)
|
|
215
|
+
@seed = nil unless defined?(@seed)
|
|
216
|
+
old, @seed = @seed, new_seed.nonzero? || Random.new_seed
|
|
217
|
+
@mt = MT19937[ @seed ]
|
|
218
|
+
old
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def rand(limit = Backports::Undefined)
|
|
222
|
+
case limit
|
|
223
|
+
when Backports::Undefined
|
|
224
|
+
@mt.random_float
|
|
225
|
+
when Float
|
|
226
|
+
limit * @mt.random_float unless limit <= 0
|
|
227
|
+
when Range
|
|
228
|
+
_rand_range(limit)
|
|
229
|
+
else
|
|
230
|
+
limit = Backports.coerce_to_int(limit)
|
|
231
|
+
@mt.random_integer(limit) unless limit <= 0
|
|
232
|
+
end || raise(ArgumentError, "invalid argument #{limit}")
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def bytes(nb)
|
|
236
|
+
nb = Backports.coerce_to_int(nb)
|
|
237
|
+
raise ArgumentError, "negative size" if nb < 0
|
|
238
|
+
@mt.random_bytes(nb)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def ==(other)
|
|
242
|
+
other.is_a?(Random) &&
|
|
243
|
+
seed == other.seed &&
|
|
244
|
+
left == other.send(:left) &&
|
|
245
|
+
state == other.send(:state)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def marshal_dump
|
|
249
|
+
@mt.marshal_dump << @seed
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def marshal_load(ary)
|
|
253
|
+
@seed = ary.pop
|
|
254
|
+
@mt = MT19937.allocate
|
|
255
|
+
@mt.marshal_load(ary)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
private
|
|
259
|
+
|
|
260
|
+
def state
|
|
261
|
+
@mt.state_as_bignum
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def left
|
|
265
|
+
@mt.left
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def _rand_range(limit)
|
|
269
|
+
range = limit.end - limit.begin
|
|
270
|
+
if (!range.is_a?(Float)) && range.respond_to?(:to_int) && range = Backports.coerce_to_int(range)
|
|
271
|
+
range += 1 unless limit.exclude_end?
|
|
272
|
+
limit.begin + @mt.random_integer(range) unless range <= 0
|
|
273
|
+
elsif range = Backports.coerce_to(range, Float, :to_f)
|
|
274
|
+
if range < 0
|
|
275
|
+
nil
|
|
276
|
+
elsif limit.exclude_end?
|
|
277
|
+
limit.begin + @mt.random_float * range unless range <= 0
|
|
278
|
+
else
|
|
279
|
+
# cheat a bit... this will reduce the nb of random bits
|
|
280
|
+
loop do
|
|
281
|
+
r = @mt.random_float * range * 1.0001
|
|
282
|
+
break limit.begin + r unless r > range
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def self.new_seed
|
|
290
|
+
(2 ** 62) + Kernel.rand(2 ** 62)
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
class Random
|
|
295
|
+
include Implementation
|
|
296
|
+
class << self
|
|
297
|
+
include Implementation
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
end
|