rspec-core 2.5.2 → 2.6.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +7 -0
- data/Gemfile +10 -13
- data/README.md +4 -1
- data/Rakefile +29 -12
- data/cucumber.yml +1 -1
- data/features/.nav +10 -4
- data/features/Autotest.md +31 -7
- data/features/Changelog.md +36 -6
- data/features/command_line/configure.feature +2 -2
- data/features/command_line/example_name_option.feature +10 -10
- data/features/command_line/exit_status.feature +4 -4
- data/features/command_line/format_option.feature +4 -4
- data/features/command_line/line_number_appended_to_path.feature +11 -11
- data/features/command_line/line_number_option.feature +2 -2
- data/features/command_line/rake_task.feature +3 -3
- data/features/command_line/tag.feature +26 -10
- data/features/configuration/alias_example_to.feature +48 -0
- data/features/configuration/custom_settings.feature +3 -3
- data/features/configuration/fail_fast.feature +3 -3
- data/features/configuration/read_options_from_file.feature +4 -4
- data/features/example_groups/basic_structure.feature +11 -15
- data/features/example_groups/shared_context.feature +74 -0
- data/features/example_groups/shared_example_group.feature +21 -17
- data/features/expectation_framework_integration/configure_expectation_framework.feature +15 -4
- data/features/filtering/exclusion_filters.feature +28 -4
- data/features/filtering/{implicit_filters.feature → if_and_unless.feature} +9 -7
- data/features/filtering/inclusion_filters.feature +26 -3
- data/features/filtering/run_all_when_everything_filtered.feature +1 -1
- data/features/formatters/custom_formatter.feature +1 -1
- data/features/formatters/text_formatter.feature +45 -0
- data/features/helper_methods/arbitrary_methods.feature +2 -2
- data/features/helper_methods/let.feature +2 -2
- data/features/helper_methods/modules.feature +149 -0
- data/features/hooks/around_hooks.feature +11 -11
- data/features/hooks/before_and_after_hooks.feature +15 -19
- data/features/hooks/filtering.feature +160 -124
- data/features/metadata/current_example.feature +17 -0
- data/features/metadata/described_class.feature +2 -2
- data/features/metadata/user_defined.feature +111 -0
- data/features/mock_framework_integration/use_any_framework.feature +1 -1
- data/features/mock_framework_integration/use_flexmock.feature +83 -10
- data/features/mock_framework_integration/use_mocha.feature +84 -10
- data/features/mock_framework_integration/use_rr.feature +85 -10
- data/features/mock_framework_integration/use_rspec.feature +84 -10
- data/features/pending/pending_examples.feature +8 -8
- data/features/spec_files/arbitrary_file_suffix.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +11 -1
- data/features/subject/attribute_of_subject.feature +24 -4
- data/features/subject/explicit_subject.feature +5 -5
- data/features/subject/implicit_receiver.feature +2 -2
- data/features/subject/implicit_subject.feature +2 -2
- data/features/support/env.rb +6 -1
- data/lib/rspec/core.rb +22 -0
- data/lib/rspec/core/backward_compatibility.rb +12 -2
- data/lib/rspec/core/command_line.rb +1 -4
- data/lib/rspec/core/configuration.rb +25 -17
- data/lib/rspec/core/configuration_options.rb +6 -23
- data/lib/rspec/core/drb_command_line.rb +5 -11
- data/lib/rspec/core/example.rb +29 -21
- data/lib/rspec/core/example_group.rb +36 -4
- data/lib/rspec/core/formatters/base_formatter.rb +6 -0
- data/lib/rspec/core/formatters/base_text_formatter.rb +1 -1
- data/lib/rspec/core/formatters/helpers.rb +0 -4
- data/lib/rspec/core/hooks.rb +14 -4
- data/lib/rspec/core/metadata.rb +1 -1
- data/lib/rspec/core/metadata_hash_builder.rb +93 -0
- data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
- data/lib/rspec/core/mocking/with_mocha.rb +2 -0
- data/lib/rspec/core/mocking/with_rr.rb +2 -0
- data/lib/rspec/core/mocking/with_rspec.rb +3 -1
- data/lib/rspec/core/option_parser.rb +5 -2
- data/lib/rspec/core/pending.rb +10 -3
- data/lib/rspec/core/reporter.rb +2 -2
- data/lib/rspec/core/runner.rb +7 -1
- data/lib/rspec/core/shared_example_group.rb +18 -4
- data/lib/rspec/core/subject.rb +4 -6
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +16 -4
- data/rspec-core.gemspec +4 -3
- data/spec.txt +1126 -0
- data/spec/autotest/failed_results_re_spec.rb +2 -2
- data/spec/rspec/core/command_line_spec.rb +0 -2
- data/spec/rspec/core/configuration_spec.rb +84 -1
- data/spec/rspec/core/deprecations_spec.rb +21 -0
- data/spec/rspec/core/drb_command_line_spec.rb +3 -11
- data/spec/rspec/core/example_group_spec.rb +213 -56
- data/spec/rspec/core/example_spec.rb +110 -0
- data/spec/rspec/core/formatters/base_formatter_spec.rb +23 -2
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +9 -0
- data/spec/rspec/core/formatters/helpers_spec.rb +1 -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 +8 -10
- 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/progress_formatter_spec.rb +0 -1
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +8 -10
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +5 -5
- data/spec/rspec/core/hooks_spec.rb +86 -0
- data/spec/rspec/core/metadata_spec.rb +7 -7
- data/spec/rspec/core/option_parser_spec.rb +8 -0
- data/spec/rspec/core/pending_example_spec.rb +12 -51
- data/spec/rspec/core/reporter_spec.rb +19 -3
- data/spec/rspec/core/resources/formatter_specs.rb +7 -1
- data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
- data/spec/rspec/core/runner_spec.rb +35 -10
- data/spec/rspec/core/shared_example_group_spec.rb +57 -21
- data/spec/rspec/core/subject_spec.rb +32 -11
- data/spec/rspec/core/world_spec.rb +38 -15
- data/spec/rspec/core_spec.rb +28 -0
- data/spec/spec_helper.rb +22 -2
- data/spec/support/matchers.rb +44 -13
- data/spec/support/shared_example_groups.rb +41 -0
- metadata +39 -16
@@ -1,23 +1,97 @@
|
|
1
1
|
Feature: mock with rspec
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
RSpec uses its own mocking framework by default, or you can configure it
|
4
|
+
explicitly.
|
5
5
|
|
6
|
-
Scenario:
|
7
|
-
Given a file named "
|
6
|
+
Scenario: passing message expectation
|
7
|
+
Given a file named "example_spec.rb" with:
|
8
8
|
"""
|
9
9
|
RSpec.configure do |config|
|
10
10
|
config.mock_framework = :rspec
|
11
11
|
end
|
12
12
|
|
13
|
-
describe "
|
14
|
-
it "
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
describe "mocking with RSpec" do
|
14
|
+
it "passes when it should" do
|
15
|
+
receiver = double('receiver')
|
16
|
+
receiver.should_receive(:message)
|
17
|
+
receiver.message
|
18
18
|
end
|
19
19
|
end
|
20
20
|
"""
|
21
|
-
When I run
|
21
|
+
When I run `rspec example_spec.rb`
|
22
22
|
Then the examples should all pass
|
23
|
+
|
24
|
+
Scenario: failing message expecation
|
25
|
+
Given a file named "example_spec.rb" with:
|
26
|
+
"""
|
27
|
+
RSpec.configure do |config|
|
28
|
+
config.mock_framework = :rspec
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "mocking with RSpec" do
|
32
|
+
it "fails when it should" do
|
33
|
+
receiver = double('receiver')
|
34
|
+
receiver.should_receive(:message)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
"""
|
38
|
+
When I run `rspec example_spec.rb`
|
39
|
+
Then the output should contain "1 example, 1 failure"
|
40
|
+
|
41
|
+
Scenario: failing message expectation in pending block (remains pending)
|
42
|
+
Given a file named "example_spec.rb" with:
|
43
|
+
"""
|
44
|
+
RSpec.configure do |config|
|
45
|
+
config.mock_framework = :rspec
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "failed message expectation in a pending block" do
|
49
|
+
it "is listed as pending" do
|
50
|
+
pending do
|
51
|
+
receiver = double('receiver')
|
52
|
+
receiver.should_receive(:message)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
"""
|
57
|
+
When I run `rspec example_spec.rb`
|
58
|
+
Then the output should contain "1 example, 0 failures, 1 pending"
|
23
59
|
And the exit status should be 0
|
60
|
+
|
61
|
+
Scenario: passing message expectation in pending block (fails)
|
62
|
+
Given a file named "example_spec.rb" with:
|
63
|
+
"""
|
64
|
+
RSpec.configure do |config|
|
65
|
+
config.mock_framework = :rspec
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "passing message expectation in a pending block" do
|
69
|
+
it "fails with FIXED" do
|
70
|
+
pending do
|
71
|
+
receiver = double('receiver')
|
72
|
+
receiver.should_receive(:message)
|
73
|
+
receiver.message
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
"""
|
78
|
+
When I run `rspec example_spec.rb`
|
79
|
+
Then the output should contain "FIXED"
|
80
|
+
Then the output should contain "1 example, 1 failure"
|
81
|
+
And the exit status should be 1
|
82
|
+
|
83
|
+
Scenario: accessing RSpec.configuration.mock_framework.framework_name
|
84
|
+
Given a file named "example_spec.rb" with:
|
85
|
+
"""
|
86
|
+
RSpec.configure do |config|
|
87
|
+
config.mock_framework = :rspec
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "RSpec.configuration.mock_framework.framework_name" do
|
91
|
+
it "returns :rspec" do
|
92
|
+
RSpec.configuration.mock_framework.framework_name.should eq(:rspec)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
"""
|
96
|
+
When I run `rspec example_spec.rb`
|
97
|
+
Then the examples should all pass
|
@@ -10,7 +10,7 @@ Feature: pending examples
|
|
10
10
|
it "is a pending example"
|
11
11
|
end
|
12
12
|
"""
|
13
|
-
When I run
|
13
|
+
When I run `rspec example_without_block_spec.rb`
|
14
14
|
Then the exit status should be 0
|
15
15
|
And the output should contain "1 example, 0 failures, 1 pending"
|
16
16
|
And the output should contain "Not Yet Implemented"
|
@@ -26,7 +26,7 @@ Feature: pending examples
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
"""
|
29
|
-
When I run
|
29
|
+
When I run `rspec pending_without_block_spec.rb`
|
30
30
|
Then the exit status should be 0
|
31
31
|
And the output should contain "1 example, 0 failures, 1 pending"
|
32
32
|
And the output should contain:
|
@@ -48,7 +48,7 @@ Feature: pending examples
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
"""
|
51
|
-
When I run
|
51
|
+
When I run `rspec pending_with_failing_block_spec.rb`
|
52
52
|
Then the exit status should be 0
|
53
53
|
And the output should contain "1 example, 0 failures, 1 pending"
|
54
54
|
And the output should contain:
|
@@ -70,7 +70,7 @@ Feature: pending examples
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
"""
|
73
|
-
When I run
|
73
|
+
When I run `rspec pending_with_passing_block_spec.rb`
|
74
74
|
Then the exit status should not be 0
|
75
75
|
And the output should contain "1 example, 1 failure"
|
76
76
|
And the output should contain "FIXED"
|
@@ -86,7 +86,7 @@ Feature: pending examples
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
"""
|
89
|
-
When I run
|
89
|
+
When I run `rspec pending_with_xit_spec.rb`
|
90
90
|
Then the exit status should be 0
|
91
91
|
And the output should contain "1 example, 0 failures, 1 pending"
|
92
92
|
And the output should contain:
|
@@ -107,7 +107,7 @@ Feature: pending examples
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
"""
|
110
|
-
When I run
|
110
|
+
When I run `rspec pending_with_no_docstring_spec.rb --format documentation`
|
111
111
|
Then the exit status should be 0
|
112
112
|
And the output should contain "2 examples, 0 failures, 1 pending"
|
113
113
|
And the output should contain:
|
@@ -129,7 +129,7 @@ Feature: pending examples
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
"""
|
132
|
-
When I run
|
132
|
+
When I run `rspec pending_with_no_docstring_spec.rb --format documentation`
|
133
133
|
Then the exit status should be 0
|
134
134
|
And the output should contain "2 examples, 0 failures, 1 pending"
|
135
135
|
And the output should contain:
|
@@ -182,7 +182,7 @@ Feature: pending examples
|
|
182
182
|
end
|
183
183
|
end
|
184
184
|
"""
|
185
|
-
When I run
|
185
|
+
When I run `rspec ./conditionally_pending_spec.rb`
|
186
186
|
Then the output should contain "8 examples, 4 failures, 2 pending"
|
187
187
|
And the output should contain:
|
188
188
|
"""
|
@@ -6,7 +6,7 @@ end
|
|
6
6
|
|
7
7
|
Then /^the output should not contain any of these:$/ do |table|
|
8
8
|
table.raw.flatten.each do |string|
|
9
|
-
|
9
|
+
all_output.should_not =~ regexp(string)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -18,3 +18,13 @@ end
|
|
18
18
|
Then /^the file "([^"]*)" should contain:$/ do |file, partial_content|
|
19
19
|
check_file_content(file, partial_content, true)
|
20
20
|
end
|
21
|
+
|
22
|
+
Then /^the backtrace\-normalized output should contain:$/ do |partial_output|
|
23
|
+
# ruby 1.9 includes additional stuff in the backtrace,
|
24
|
+
# so we need to normalize it to compare it with our expected output.
|
25
|
+
normalized_output = all_output.split("\n").map do |line|
|
26
|
+
line =~ /(^\s+# [^:]+:\d+)/ ? $1 : line # http://rubular.com/r/zDD7DdWyzF
|
27
|
+
end.join("\n")
|
28
|
+
|
29
|
+
normalized_output.should =~ regexp(partial_output)
|
30
|
+
end
|
@@ -28,7 +28,7 @@ Feature: attribute of subject
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
"""
|
31
|
-
When I run
|
31
|
+
When I run `rspec example_spec.rb --format documentation`
|
32
32
|
Then the output should contain:
|
33
33
|
"""
|
34
34
|
Array
|
@@ -59,7 +59,7 @@ Feature: attribute of subject
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
"""
|
62
|
-
When I run
|
62
|
+
When I run `rspec example_spec.rb --format documentation`
|
63
63
|
Then the output should contain:
|
64
64
|
"""
|
65
65
|
Person
|
@@ -81,7 +81,7 @@ Feature: attribute of subject
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
"""
|
84
|
-
When I run
|
84
|
+
When I run `rspec example_spec.rb`
|
85
85
|
Then the examples should all pass
|
86
86
|
|
87
87
|
Scenario: specify value for key in a hash
|
@@ -98,5 +98,25 @@ Feature: attribute of subject
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
"""
|
101
|
-
When I run
|
101
|
+
When I run `rspec example_spec.rb`
|
102
|
+
Then the examples should all pass
|
103
|
+
|
104
|
+
Scenario: specify value for key in a hash-like object
|
105
|
+
Given a file named "example_spec.rb" with:
|
106
|
+
"""
|
107
|
+
require 'matrix'
|
108
|
+
|
109
|
+
describe Matrix do
|
110
|
+
context "with values [[1, 2], [3, 4]]" do
|
111
|
+
subject do
|
112
|
+
Matrix[[1, 2], [3, 4]]
|
113
|
+
end
|
114
|
+
|
115
|
+
its([0, 1]) { should eq(2) }
|
116
|
+
its([1, 0]) { should eq(3) }
|
117
|
+
its([1, 2]) { should be_nil }
|
118
|
+
end
|
119
|
+
end
|
120
|
+
"""
|
121
|
+
When I run `rspec example_spec.rb`
|
102
122
|
Then the examples should all pass
|
@@ -13,7 +13,7 @@ Feature: explicit subject
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
"""
|
16
|
-
When I run
|
16
|
+
When I run `rspec top_level_subject_spec.rb`
|
17
17
|
Then the examples should all pass
|
18
18
|
|
19
19
|
Scenario: subject in a nested group
|
@@ -28,7 +28,7 @@ Feature: explicit subject
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
"""
|
31
|
-
When I run
|
31
|
+
When I run `rspec nested_subject_spec.rb`
|
32
32
|
Then the examples should all pass
|
33
33
|
|
34
34
|
Scenario: access subject from before block
|
@@ -42,7 +42,7 @@ Feature: explicit subject
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
"""
|
45
|
-
When I run
|
45
|
+
When I run `rspec top_level_subject_spec.rb`
|
46
46
|
Then the examples should all pass
|
47
47
|
|
48
48
|
Scenario: invoke helper method from subject block
|
@@ -58,7 +58,7 @@ Feature: explicit subject
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
"""
|
61
|
-
When I run
|
61
|
+
When I run `rspec helper_subject_spec.rb`
|
62
62
|
Then the examples should all pass
|
63
63
|
|
64
64
|
Scenario: subject block is invoked at most once per example
|
@@ -74,5 +74,5 @@ Feature: explicit subject
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
"""
|
77
|
-
When I run
|
77
|
+
When I run `rspec nil_subject_spec.rb`
|
78
78
|
Then the examples should all pass
|
@@ -12,7 +12,7 @@ Feature: implicit receiver
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
"""
|
15
|
-
When I run
|
15
|
+
When I run `rspec example_spec.rb`
|
16
16
|
Then the examples should all pass
|
17
17
|
|
18
18
|
Scenario: explicit subject
|
@@ -25,5 +25,5 @@ Feature: implicit receiver
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
"""
|
28
|
-
When I run
|
28
|
+
When I run `rspec example_spec.rb`
|
29
29
|
Then the examples should all pass
|
@@ -12,7 +12,7 @@ Feature: implicit subject
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
"""
|
15
|
-
When I run
|
15
|
+
When I run `rspec ./top_level_subject_spec.rb`
|
16
16
|
Then the examples should all pass
|
17
17
|
|
18
18
|
Scenario: subject in a nested group
|
@@ -26,5 +26,5 @@ Feature: implicit subject
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
"""
|
29
|
-
When I run
|
29
|
+
When I run `rspec nested_subject_spec.rb`
|
30
30
|
Then the examples should all pass
|
data/features/support/env.rb
CHANGED
data/lib/rspec/core.rb
CHANGED
@@ -4,6 +4,7 @@ require 'rspec/core/deprecation'
|
|
4
4
|
require 'rspec/core/backward_compatibility'
|
5
5
|
require 'rspec/core/reporter'
|
6
6
|
|
7
|
+
require 'rspec/core/metadata_hash_builder'
|
7
8
|
require 'rspec/core/hooks'
|
8
9
|
require 'rspec/core/subject'
|
9
10
|
require 'rspec/core/let'
|
@@ -53,12 +54,33 @@ module RSpec
|
|
53
54
|
end
|
54
55
|
|
55
56
|
def self.configure
|
57
|
+
warn_about_deprecated_configure if RSpec.world.example_groups.any?
|
56
58
|
yield configuration if block_given?
|
57
59
|
end
|
58
60
|
|
59
61
|
def self.clear_remaining_example_groups
|
60
62
|
world.example_groups.clear
|
61
63
|
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def self.warn_about_deprecated_configure
|
68
|
+
warn <<-NOTICE
|
69
|
+
|
70
|
+
*****************************************************************
|
71
|
+
DEPRECATION WARNING: you are using deprecated behaviour that will
|
72
|
+
be removed from RSpec 3.
|
73
|
+
|
74
|
+
You have set some configuration options after an example group has
|
75
|
+
already been defined. In RSpec 3, this will not be allowed. All
|
76
|
+
configuration should happen before the first example group is
|
77
|
+
defined. The configuration is happening at:
|
78
|
+
|
79
|
+
#{caller[1]}
|
80
|
+
*****************************************************************
|
81
|
+
|
82
|
+
NOTICE
|
83
|
+
end
|
62
84
|
end
|
63
85
|
|
64
86
|
require 'rspec/core/backward_compatibility'
|
@@ -17,7 +17,12 @@ be removed from a future version of RSpec.
|
|
17
17
|
WARNING
|
18
18
|
RSpec
|
19
19
|
else
|
20
|
-
|
20
|
+
begin
|
21
|
+
super
|
22
|
+
rescue Exception => e
|
23
|
+
e.backtrace.reject! {|l| l =~ Regexp.compile(__FILE__) }
|
24
|
+
raise e
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
@@ -38,7 +43,12 @@ WARNING
|
|
38
43
|
require 'rspec/core/rake_task'
|
39
44
|
RSpec::Core::RakeTask
|
40
45
|
else
|
41
|
-
|
46
|
+
begin
|
47
|
+
super
|
48
|
+
rescue Exception => e
|
49
|
+
e.backtrace.reject! {|l| l =~ Regexp.compile(__FILE__) }
|
50
|
+
raise e
|
51
|
+
end
|
42
52
|
end
|
43
53
|
end
|
44
54
|
|
@@ -16,10 +16,7 @@ module RSpec
|
|
16
16
|
@configuration.output_stream ||= out
|
17
17
|
@options.configure(@configuration)
|
18
18
|
@configuration.load_spec_files
|
19
|
-
@
|
20
|
-
@configuration.configure_expectation_framework
|
21
|
-
@world.announce_inclusion_filter
|
22
|
-
@world.announce_exclusion_filter
|
19
|
+
@world.announce_filters
|
23
20
|
|
24
21
|
@configuration.reporter.report(@world.example_count) do |reporter|
|
25
22
|
begin
|
@@ -33,6 +33,8 @@ module RSpec
|
|
33
33
|
add_setting :include_or_extend_modules
|
34
34
|
add_setting :backtrace_clean_patterns
|
35
35
|
add_setting :tty
|
36
|
+
add_setting :treat_symbols_as_metadata_keys_with_true_values, :default => false
|
37
|
+
add_setting :expecting_with_rspec
|
36
38
|
|
37
39
|
def initialize
|
38
40
|
@color_enabled = false
|
@@ -46,10 +48,10 @@ module RSpec
|
|
46
48
|
/lib\/rspec\/(core|expectations|matchers|mocks)/
|
47
49
|
]
|
48
50
|
|
49
|
-
|
51
|
+
self.exclusion_filter = {
|
50
52
|
:if => lambda { |value, metadata| metadata.has_key?(:if) && !value },
|
51
53
|
:unless => lambda { |value| value }
|
52
|
-
|
54
|
+
}
|
53
55
|
end
|
54
56
|
|
55
57
|
# :call-seq:
|
@@ -169,13 +171,11 @@ module RSpec
|
|
169
171
|
|
170
172
|
# Returns the configured expectation framework adapter module(s)
|
171
173
|
def expectation_frameworks
|
172
|
-
settings[:expectation_frameworks]
|
173
|
-
|
174
|
-
[RSpec::Core::ExpectationFrameworkAdapter]
|
175
|
-
end
|
174
|
+
expect_with :rspec unless settings[:expectation_frameworks]
|
175
|
+
settings[:expectation_frameworks]
|
176
176
|
end
|
177
177
|
|
178
|
-
# Delegates to expect_with
|
178
|
+
# Delegates to expect_with([framework])
|
179
179
|
def expectation_framework=(framework)
|
180
180
|
expect_with([framework])
|
181
181
|
end
|
@@ -195,6 +195,7 @@ module RSpec
|
|
195
195
|
case framework
|
196
196
|
when :rspec
|
197
197
|
require 'rspec/core/expecting/with_rspec'
|
198
|
+
self.expecting_with_rspec = true
|
198
199
|
when :stdlib
|
199
200
|
require 'rspec/core/expecting/with_stdlib'
|
200
201
|
else
|
@@ -304,7 +305,8 @@ EOM
|
|
304
305
|
|
305
306
|
# E.g. alias_example_to :crazy_slow, :speed => 'crazy_slow' defines
|
306
307
|
# crazy_slow as an example variant that has the crazy_slow speed option
|
307
|
-
def alias_example_to(new_name,
|
308
|
+
def alias_example_to(new_name, *args)
|
309
|
+
extra_options = build_metadata_hash_from(args)
|
308
310
|
RSpec::Core::ExampleGroup.alias_example_to(new_name, extra_options)
|
309
311
|
end
|
310
312
|
|
@@ -333,7 +335,15 @@ EOM
|
|
333
335
|
RSpec::Core::ExampleGroup.alias_it_should_behave_like_to(new_name, report_label)
|
334
336
|
end
|
335
337
|
|
336
|
-
def filter_run_including(
|
338
|
+
def filter_run_including(*args)
|
339
|
+
force_overwrite = if args.last.is_a?(Hash) || args.last.is_a?(Symbol)
|
340
|
+
false
|
341
|
+
else
|
342
|
+
args.pop
|
343
|
+
end
|
344
|
+
|
345
|
+
options = build_metadata_hash_from(args)
|
346
|
+
|
337
347
|
if filter and filter[:line_number] || filter[:full_description]
|
338
348
|
warn "Filtering by #{options.inspect} is not possible since " \
|
339
349
|
"you are already filtering by #{filter.inspect}"
|
@@ -348,24 +358,22 @@ EOM
|
|
348
358
|
|
349
359
|
alias_method :filter_run, :filter_run_including
|
350
360
|
|
351
|
-
def filter_run_excluding(
|
361
|
+
def filter_run_excluding(*args)
|
362
|
+
options = build_metadata_hash_from(args)
|
352
363
|
self.exclusion_filter = (exclusion_filter || {}).merge(options)
|
353
364
|
end
|
354
365
|
|
355
|
-
def include(mod,
|
366
|
+
def include(mod, *args)
|
367
|
+
filters = build_metadata_hash_from(args)
|
356
368
|
include_or_extend_modules << [:include, mod, filters]
|
357
369
|
end
|
358
370
|
|
359
|
-
def extend(mod,
|
371
|
+
def extend(mod, *args)
|
372
|
+
filters = build_metadata_hash_from(args)
|
360
373
|
include_or_extend_modules << [:extend, mod, filters]
|
361
374
|
end
|
362
375
|
|
363
376
|
def configure_group(group)
|
364
|
-
modules = {
|
365
|
-
:include => group.included_modules.dup,
|
366
|
-
:extend => group.ancestors.dup
|
367
|
-
}
|
368
|
-
|
369
377
|
include_or_extend_modules.each do |include_or_extend, mod, filters|
|
370
378
|
next unless filters.empty? || group.apply?(:any?, filters)
|
371
379
|
group.send(include_or_extend, mod)
|