rspec-core 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +9 -4
- data/Guardfile +3 -3
- data/README.md +1 -1
- data/features/.nav +7 -2
- data/features/{README.markdown → Autotest.md} +17 -20
- data/features/Changelog.md +57 -2
- data/features/README.md +17 -0
- data/features/Upgrade.md +8 -66
- 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/line_number_appended_to_path.feature +11 -11
- data/features/command_line/line_number_option.feature +9 -9
- data/features/command_line/tag.feature +9 -9
- 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/shared_example_group.feature +4 -4
- data/features/expectation_framework_integration/configure_expectation_framework.feature +8 -9
- data/features/filtering/exclusion_filters.feature +1 -1
- data/features/filtering/run_all_when_everything_filtered.feature +1 -1
- data/features/formatters/custom_formatter.feature +17 -13
- data/features/helper_methods/arbitrary_methods.feature +40 -0
- data/features/helper_methods/let.feature +50 -0
- data/features/hooks/before_and_after_hooks.feature +10 -10
- data/features/hooks/filtering.feature +37 -20
- data/features/metadata/described_class.feature +1 -1
- 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 +1 -1
- data/features/spec_files/arbitrary_file_suffix.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +1 -1
- data/features/subject/attribute_of_subject.feature +2 -2
- 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/lib/autotest/rspec2.rb +63 -13
- data/lib/rspec/core/configuration.rb +0 -1
- data/lib/rspec/core/configuration_options.rb +15 -12
- data/lib/rspec/core/example.rb +14 -6
- data/lib/rspec/core/example_group.rb +5 -4
- data/lib/rspec/core/formatters/base_formatter.rb +1 -1
- data/lib/rspec/core/formatters/documentation_formatter.rb +1 -1
- data/lib/rspec/core/formatters/html_formatter.rb +131 -32
- data/lib/rspec/core/formatters/snippet_extractor.rb +1 -1
- data/lib/rspec/core/hooks.rb +16 -1
- data/lib/rspec/core/option_parser.rb +6 -6
- data/lib/rspec/core/rake_task.rb +1 -1
- data/lib/rspec/core/subject.rb +7 -7
- data/lib/rspec/core/version.rb +1 -1
- data/rspec-core.gemspec +0 -12
- data/script/FullBuildRakeFile +63 -0
- data/script/cucumber +1 -0
- data/script/full_build +1 -0
- data/script/spec +1 -0
- data/spec/autotest/failed_results_re_spec.rb +22 -5
- data/spec/autotest/rspec_spec.rb +132 -16
- data/spec/rspec/core/configuration_options_spec.rb +38 -6
- data/spec/rspec/core/example_group_spec.rb +15 -64
- data/spec/rspec/core/formatters/base_formatter_spec.rb +23 -0
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +150 -48
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +151 -49
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +150 -48
- data/spec/rspec/core/formatters/html_formatted-1.9.1.html +150 -48
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +150 -48
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +150 -48
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +151 -49
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +150 -48
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +150 -48
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +150 -48
- data/spec/rspec/core/hooks_filtering_spec.rb +49 -0
- data/spec/rspec/core/rake_task_spec.rb +3 -3
- data/spec/rspec/core/subject_spec.rb +81 -0
- metadata +20 -22
- data/History.markdown +0 -186
- data/Upgrade.markdown +0 -345
@@ -1,11 +1,11 @@
|
|
1
|
-
Feature:
|
1
|
+
Feature: filters
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
`before`/`after`/`around` hooks defined in the RSpec configuration block can
|
4
|
+
be filtered using metadata. Arbitrary metadata can be applied to an example
|
5
|
+
or example group, and used to make a hook only apply to examples with the
|
6
|
+
given metadata.
|
7
7
|
|
8
|
-
Scenario:
|
8
|
+
Scenario: filter `before(:each)` hooks using arbitrary metadata
|
9
9
|
Given a file named "filter_before_each_hooks_spec.rb" with:
|
10
10
|
"""
|
11
11
|
RSpec.configure do |config|
|
@@ -23,8 +23,7 @@ Feature: Global Hook Filtering
|
|
23
23
|
end
|
24
24
|
"""
|
25
25
|
When I run "rspec filter_before_each_hooks_spec.rb --format documentation"
|
26
|
-
Then the output should contain
|
27
|
-
And the output should contain:
|
26
|
+
Then the output should contain:
|
28
27
|
"""
|
29
28
|
group 1
|
30
29
|
example 1
|
@@ -38,7 +37,7 @@ Feature: Global Hook Filtering
|
|
38
37
|
example 2
|
39
38
|
"""
|
40
39
|
|
41
|
-
Scenario:
|
40
|
+
Scenario: filter `after(:each)` hooks using arbitrary metadata
|
42
41
|
Given a file named "filter_after_each_hooks_spec.rb" with:
|
43
42
|
"""
|
44
43
|
RSpec.configure do |config|
|
@@ -56,8 +55,7 @@ Feature: Global Hook Filtering
|
|
56
55
|
end
|
57
56
|
"""
|
58
57
|
When I run "rspec filter_after_each_hooks_spec.rb --format documentation"
|
59
|
-
Then the output should contain
|
60
|
-
And the output should contain:
|
58
|
+
Then the output should contain:
|
61
59
|
"""
|
62
60
|
group 1
|
63
61
|
example 1
|
@@ -71,7 +69,7 @@ Feature: Global Hook Filtering
|
|
71
69
|
example 2
|
72
70
|
"""
|
73
71
|
|
74
|
-
Scenario:
|
72
|
+
Scenario: filter around(:each) hooks using arbitrary metadata
|
75
73
|
Given a file named "filter_around_each_hooks_spec.rb" with:
|
76
74
|
"""
|
77
75
|
RSpec.configure do |config|
|
@@ -93,8 +91,7 @@ Feature: Global Hook Filtering
|
|
93
91
|
end
|
94
92
|
"""
|
95
93
|
When I run "rspec filter_around_each_hooks_spec.rb --format documentation"
|
96
|
-
Then the output should contain
|
97
|
-
And the output should contain:
|
94
|
+
Then the output should contain:
|
98
95
|
"""
|
99
96
|
group 1
|
100
97
|
example 1
|
@@ -111,7 +108,7 @@ Feature: Global Hook Filtering
|
|
111
108
|
example 2
|
112
109
|
"""
|
113
110
|
|
114
|
-
Scenario:
|
111
|
+
Scenario: filter before(:all) hooks using arbitrary metadata
|
115
112
|
Given a file named "filter_before_all_hooks_spec.rb" with:
|
116
113
|
"""
|
117
114
|
RSpec.configure do |config|
|
@@ -127,10 +124,15 @@ Feature: Global Hook Filtering
|
|
127
124
|
it("example 1") { }
|
128
125
|
it("example 2") { }
|
129
126
|
end
|
127
|
+
|
128
|
+
describe "group 3" do
|
129
|
+
describe "subgroup 1", :foo => :bar do
|
130
|
+
it("example 1") { }
|
131
|
+
end
|
132
|
+
end
|
130
133
|
"""
|
131
134
|
When I run "rspec filter_before_all_hooks_spec.rb --format documentation"
|
132
|
-
Then the output should contain
|
133
|
-
And the output should contain:
|
135
|
+
Then the output should contain:
|
134
136
|
"""
|
135
137
|
group 1
|
136
138
|
example 1
|
@@ -140,9 +142,14 @@ Feature: Global Hook Filtering
|
|
140
142
|
In hook
|
141
143
|
example 1
|
142
144
|
example 2
|
145
|
+
|
146
|
+
group 3
|
147
|
+
subgroup 1
|
148
|
+
In hook
|
149
|
+
example 1
|
143
150
|
"""
|
144
151
|
|
145
|
-
Scenario:
|
152
|
+
Scenario: filter after(:all) hooks using arbitrary metadata
|
146
153
|
Given a file named "filter_after_all_hooks_spec.rb" with:
|
147
154
|
"""
|
148
155
|
RSpec.configure do |config|
|
@@ -158,10 +165,15 @@ Feature: Global Hook Filtering
|
|
158
165
|
it("example 1") { }
|
159
166
|
it("example 2") { }
|
160
167
|
end
|
168
|
+
|
169
|
+
describe "group 3" do
|
170
|
+
describe "subgroup 1", :foo => :bar do
|
171
|
+
it("example 1") { }
|
172
|
+
end
|
173
|
+
end
|
161
174
|
"""
|
162
175
|
When I run "rspec filter_after_all_hooks_spec.rb --format documentation"
|
163
|
-
Then the output should contain
|
164
|
-
And the output should contain:
|
176
|
+
Then the output should contain:
|
165
177
|
"""
|
166
178
|
group 1
|
167
179
|
example 1
|
@@ -171,4 +183,9 @@ Feature: Global Hook Filtering
|
|
171
183
|
example 1
|
172
184
|
example 2
|
173
185
|
In hook
|
186
|
+
|
187
|
+
group 3
|
188
|
+
subgroup 1
|
189
|
+
example 1
|
190
|
+
In hook
|
174
191
|
"""
|
@@ -10,7 +10,7 @@ Then /^the output should not contain any of these:$/ do |table|
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
Then /^the example(s)? should( all)? pass$/ do
|
13
|
+
Then /^the example(?:s)? should(?: all)? pass$/ do
|
14
14
|
Then %q{the output should contain "0 failures"}
|
15
15
|
Then %q{the exit status should be 0}
|
16
16
|
end
|
@@ -82,7 +82,7 @@ Feature: attribute of subject
|
|
82
82
|
end
|
83
83
|
"""
|
84
84
|
When I run "rspec example_spec.rb"
|
85
|
-
Then the
|
85
|
+
Then the examples should all pass
|
86
86
|
|
87
87
|
Scenario: specify value for key in a hash
|
88
88
|
Given a file named "example_spec.rb" with:
|
@@ -99,4 +99,4 @@ Feature: attribute of subject
|
|
99
99
|
end
|
100
100
|
"""
|
101
101
|
When I run "rspec example_spec.rb"
|
102
|
-
Then the
|
102
|
+
Then the examples should all pass
|
@@ -14,7 +14,7 @@ Feature: explicit subject
|
|
14
14
|
end
|
15
15
|
"""
|
16
16
|
When I run "rspec top_level_subject_spec.rb"
|
17
|
-
Then the
|
17
|
+
Then the examples should all pass
|
18
18
|
|
19
19
|
Scenario: subject in a nested group
|
20
20
|
Given a file named "nested_subject_spec.rb" with:
|
@@ -29,7 +29,7 @@ Feature: explicit subject
|
|
29
29
|
end
|
30
30
|
"""
|
31
31
|
When I run "rspec nested_subject_spec.rb"
|
32
|
-
Then the
|
32
|
+
Then the examples should all pass
|
33
33
|
|
34
34
|
Scenario: access subject from before block
|
35
35
|
Given a file named "top_level_subject_spec.rb" with:
|
@@ -43,7 +43,7 @@ Feature: explicit subject
|
|
43
43
|
end
|
44
44
|
"""
|
45
45
|
When I run "rspec top_level_subject_spec.rb"
|
46
|
-
Then the
|
46
|
+
Then the examples should all pass
|
47
47
|
|
48
48
|
Scenario: invoke helper method from subject block
|
49
49
|
Given a file named "helper_subject_spec.rb" with:
|
@@ -59,7 +59,7 @@ Feature: explicit subject
|
|
59
59
|
end
|
60
60
|
"""
|
61
61
|
When I run "rspec helper_subject_spec.rb"
|
62
|
-
Then the
|
62
|
+
Then the examples should all pass
|
63
63
|
|
64
64
|
Scenario: subject block is invoked at most once per example
|
65
65
|
Given a file named "nil_subject_spec.rb" with:
|
@@ -75,4 +75,4 @@ Feature: explicit subject
|
|
75
75
|
end
|
76
76
|
"""
|
77
77
|
When I run "rspec nil_subject_spec.rb"
|
78
|
-
Then the
|
78
|
+
Then the examples should all pass
|
@@ -13,7 +13,7 @@ Feature: implicit receiver
|
|
13
13
|
end
|
14
14
|
"""
|
15
15
|
When I run "rspec example_spec.rb"
|
16
|
-
Then the
|
16
|
+
Then the examples should all pass
|
17
17
|
|
18
18
|
Scenario: explicit subject
|
19
19
|
Given a file named "example_spec.rb" with:
|
@@ -26,4 +26,4 @@ Feature: implicit receiver
|
|
26
26
|
end
|
27
27
|
"""
|
28
28
|
When I run "rspec example_spec.rb"
|
29
|
-
Then the
|
29
|
+
Then the examples should all pass
|
@@ -13,7 +13,7 @@ Feature: implicit subject
|
|
13
13
|
end
|
14
14
|
"""
|
15
15
|
When I run "rspec ./top_level_subject_spec.rb"
|
16
|
-
Then the
|
16
|
+
Then the examples should all pass
|
17
17
|
|
18
18
|
Scenario: subject in a nested group
|
19
19
|
Given a file named "nested_subject_spec.rb" with:
|
@@ -27,4 +27,4 @@ Feature: implicit subject
|
|
27
27
|
end
|
28
28
|
"""
|
29
29
|
When I run "rspec nested_subject_spec.rb"
|
30
|
-
Then the
|
30
|
+
Then the examples should all pass
|
data/lib/autotest/rspec2.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
require 'autotest'
|
2
|
+
require 'rspec/core/deprecation'
|
2
3
|
|
3
4
|
class RSpecCommandError < StandardError; end
|
4
5
|
|
5
6
|
class Autotest::Rspec2 < Autotest
|
6
7
|
|
7
|
-
|
8
|
+
attr_reader :cl_args, :skip_bundler
|
9
|
+
alias_method :skip_bundler?, :skip_bundler
|
10
|
+
|
11
|
+
SPEC_PROGRAM = File.expand_path('../../../bin/rspec', __FILE__)
|
8
12
|
|
9
13
|
def initialize
|
10
|
-
super
|
14
|
+
super()
|
15
|
+
@cl_args = ARGV.dup << "--tty"
|
16
|
+
@skip_bundler = @cl_args.delete("--skip-bundler")
|
11
17
|
clear_mappings
|
12
18
|
setup_rspec_project_mappings
|
13
19
|
|
14
20
|
# Example for Ruby 1.8: http://rubular.com/r/AOXNVDrZpx
|
15
21
|
# Example for Ruby 1.9: http://rubular.com/r/85ag5AZ2jP
|
16
|
-
self.failed_results_re = /^\s*\d+\).*\n\s+Failure.*(\n\s+#\s(.*)?:\d+(?::.*)?)+$/m
|
22
|
+
self.failed_results_re = /^\s*\d+\).*\n\s+(?:\e\[\d*m)?Failure.*(\n(?:\e\[\d*m)?\s+#\s(.*)?:\d+(?::.*)?(?:\e\[\d*m)?)+$/m
|
17
23
|
self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
|
18
24
|
end
|
19
25
|
|
@@ -40,16 +46,9 @@ class Autotest::Rspec2 < Autotest
|
|
40
46
|
end
|
41
47
|
|
42
48
|
def make_test_cmd(files_to_test)
|
49
|
+
warn_about_bundler if rspec_wants_bundler? && !autotest_wants_bundler?
|
43
50
|
files_to_test.empty? ? '' :
|
44
|
-
"#{
|
45
|
-
end
|
46
|
-
|
47
|
-
def bundle_exec
|
48
|
-
using_bundler? ? "bundle exec " : ""
|
49
|
-
end
|
50
|
-
|
51
|
-
def require_rubygems
|
52
|
-
using_bundler? ? "" : defined?(:Gem) ? "-rrubygems " : " "
|
51
|
+
"#{prefix}#{ruby}#{suffix} -S #{SPEC_PROGRAM} #{cl_args.join(' ')} #{normalize(files_to_test).keys.flatten.map { |f| "'#{f}'"}.join(' ')}"
|
53
52
|
end
|
54
53
|
|
55
54
|
def normalize(files_to_test)
|
@@ -59,8 +58,59 @@ class Autotest::Rspec2 < Autotest
|
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
61
|
+
def warn_about_bundler
|
62
|
+
RSpec.warn_deprecation <<-WARNING
|
63
|
+
|
64
|
+
****************************************************************************
|
65
|
+
DEPRECATION WARNING: you are using deprecated behaviour that will be removed
|
66
|
+
from a future version of RSpec.
|
67
|
+
|
68
|
+
RSpec's autotest extension is relying on the presence of a Gemfile in the
|
69
|
+
project root directory to generate a command including 'bundle exec'.
|
70
|
+
|
71
|
+
You have two options to suppress this message:
|
72
|
+
|
73
|
+
If you want to include 'bundle exec' in the command, add a .autotest file to
|
74
|
+
the project root with the following content:
|
75
|
+
|
76
|
+
require 'autotest/bundler'
|
77
|
+
|
78
|
+
If you want to _not_include 'bundle exec' in the command, pass --skip-bundler
|
79
|
+
to autotest as an extra argument, like this:
|
80
|
+
|
81
|
+
autotest -- --skip-bundler
|
82
|
+
*****************************************************************
|
83
|
+
WARNING
|
84
|
+
end
|
85
|
+
|
86
|
+
alias_method :autotest_prefix, :prefix
|
87
|
+
|
88
|
+
def rspec_prefix
|
89
|
+
(rspec_wants_bundler? && !autotest_wants_bundler?) ? "bundle exec " : ""
|
90
|
+
end
|
91
|
+
|
92
|
+
def prefix
|
93
|
+
skip_bundler? ? "#{rspec_prefix}#{autotest_prefix}".gsub("bundle exec","") : "#{rspec_prefix}#{autotest_prefix}"
|
94
|
+
end
|
95
|
+
|
96
|
+
def autotest_wants_bundler?
|
97
|
+
autotest_prefix =~ /bundle exec/
|
98
|
+
end
|
99
|
+
|
100
|
+
def suffix
|
101
|
+
using_bundler? ? "" : defined?(:Gem) ? " -rrubygems" : ""
|
102
|
+
end
|
103
|
+
|
104
|
+
def rspec_wants_bundler?
|
105
|
+
gemfile? && !skip_bundler?
|
106
|
+
end
|
107
|
+
|
62
108
|
def using_bundler?
|
63
|
-
|
109
|
+
rspec_wants_bundler? || autotest_wants_bundler?
|
110
|
+
end
|
111
|
+
|
112
|
+
def gemfile?
|
113
|
+
File.exist?('./Gemfile')
|
64
114
|
end
|
65
115
|
|
66
116
|
end
|
@@ -31,20 +31,23 @@ module RSpec
|
|
31
31
|
|
32
32
|
def drb_argv
|
33
33
|
argv = []
|
34
|
-
argv << "--color"
|
35
|
-
argv << "--profile"
|
36
|
-
argv << "--backtrace"
|
37
|
-
argv << "--tty"
|
38
|
-
argv << "--fail-fast"
|
34
|
+
argv << "--color" if options[:color_enabled]
|
35
|
+
argv << "--profile" if options[:profile_examples]
|
36
|
+
argv << "--backtrace" if options[:full_backtrace]
|
37
|
+
argv << "--tty" if options[:tty]
|
38
|
+
argv << "--fail-fast" if options[:fail_fast]
|
39
39
|
argv << "--line_number" << options[:line_number] if options[:line_number]
|
40
|
-
argv << "--options" << options[:custom_options_file]
|
40
|
+
argv << "--options" << options[:custom_options_file] if options[:custom_options_file]
|
41
41
|
argv << "--example" << options[:full_description].source if options[:full_description]
|
42
|
+
if options[:filter]
|
43
|
+
options[:filter].each_pair do |k, v|
|
44
|
+
argv << "--tag" << k.to_s
|
45
|
+
end
|
46
|
+
end
|
42
47
|
if options[:formatters]
|
43
48
|
options[:formatters].each do |pair|
|
44
|
-
argv << "--format" << pair
|
45
|
-
|
46
|
-
argv << "--out" << pair.shift
|
47
|
-
end
|
49
|
+
argv << "--format" << pair[0]
|
50
|
+
argv << "--out" << pair[1] if pair[1]
|
48
51
|
end
|
49
52
|
end
|
50
53
|
(options[:libs] || []).each do |path|
|
@@ -65,8 +68,8 @@ module RSpec
|
|
65
68
|
options_to_merge << global_options
|
66
69
|
options_to_merge << local_options
|
67
70
|
end
|
68
|
-
options_to_merge << env_options
|
69
71
|
options_to_merge << command_line_options
|
72
|
+
options_to_merge << env_options
|
70
73
|
|
71
74
|
options_to_merge.inject do |merged, options|
|
72
75
|
merged.merge(options)
|
@@ -109,7 +112,7 @@ module RSpec
|
|
109
112
|
config_string = options_file_as_erb_string(path)
|
110
113
|
config_string.split(/\n+/).map {|l| l.split}.flatten
|
111
114
|
end
|
112
|
-
|
115
|
+
|
113
116
|
def options_file_as_erb_string(path)
|
114
117
|
require 'erb'
|
115
118
|
ERB.new(IO.read(path)).result(binding)
|
data/lib/rspec/core/example.rb
CHANGED
@@ -75,12 +75,20 @@ module RSpec
|
|
75
75
|
finish(reporter)
|
76
76
|
end
|
77
77
|
|
78
|
-
|
78
|
+
def self.procsy(metadata, &block)
|
79
|
+
Proc.new(&block).extend(Procsy).with(metadata)
|
80
|
+
end
|
81
|
+
|
82
|
+
module Procsy
|
79
83
|
attr_reader :metadata
|
80
|
-
|
81
|
-
def
|
84
|
+
|
85
|
+
def self.extended(object)
|
86
|
+
def object.run; call; end
|
87
|
+
end
|
88
|
+
|
89
|
+
def with(metadata)
|
82
90
|
@metadata = metadata
|
83
|
-
|
91
|
+
self
|
84
92
|
end
|
85
93
|
end
|
86
94
|
|
@@ -93,11 +101,11 @@ module RSpec
|
|
93
101
|
end
|
94
102
|
end
|
95
103
|
|
96
|
-
def with_around_hooks
|
104
|
+
def with_around_hooks(&block)
|
97
105
|
if around_hooks.empty?
|
98
106
|
yield
|
99
107
|
else
|
100
|
-
@example_group_class.eval_around_eachs(self,
|
108
|
+
@example_group_class.eval_around_eachs(self, Example.procsy(metadata, &block)).call
|
101
109
|
end
|
102
110
|
end
|
103
111
|
|