rspec-core 2.0.0.beta.11 → 2.0.0.beta.12
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.
- data/Rakefile +0 -4
- data/VERSION +1 -1
- data/features/command_line/example_name_option.feature +6 -2
- data/features/configuration/options_file.feature +3 -4
- data/features/hooks/before_and_after_hooks.feature +30 -0
- data/features/hooks/halt.feature +3 -4
- data/lib/rspec/core/command_line.rb +1 -0
- data/lib/rspec/core/configuration.rb +38 -8
- data/lib/rspec/core/configuration_options.rb +22 -12
- data/lib/rspec/core/drb_command_line.rb +1 -0
- data/lib/rspec/core/example_group.rb +13 -11
- data/lib/rspec/core/hooks.rb +1 -0
- data/lib/rspec/core/option_parser.rb +13 -3
- data/lib/rspec/core/world.rb +1 -1
- data/rspec-core.gemspec +14 -15
- data/spec/rspec/core/configuration_options_spec.rb +77 -26
- data/spec/rspec/core/configuration_spec.rb +76 -0
- data/spec/rspec/core/example_group_spec.rb +3 -25
- data/spec/rspec/core/hooks_spec.rb +13 -0
- data/spec/rspec/core/option_parser_spec.rb +19 -0
- data/spec/rspec/core/runner_spec.rb +1 -0
- data/spec/spec_helper.rb +4 -2
- metadata +13 -14
- data/features/hooks/around_hook.feature +0 -36
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.beta.
|
1
|
+
2.0.0.beta.12
|
@@ -29,7 +29,7 @@ Feature: example name option
|
|
29
29
|
When I run "rspec . --example nothing_like_this"
|
30
30
|
Then I should see "0 examples, 0 failures"
|
31
31
|
|
32
|
-
Scenario:
|
32
|
+
Scenario: match on one word
|
33
33
|
When I run "rspec . --example example"
|
34
34
|
Then I should see "4 examples, 0 failures"
|
35
35
|
|
@@ -37,10 +37,14 @@ Feature: example name option
|
|
37
37
|
When I run "rspec . --example 'first example'"
|
38
38
|
Then I should see "2 examples, 0 failures"
|
39
39
|
|
40
|
-
Scenario: one match in one file
|
40
|
+
Scenario: one match in one file using just the example name
|
41
41
|
When I run "rspec . --example 'first example in first group'"
|
42
42
|
Then I should see "1 example, 0 failures"
|
43
43
|
|
44
|
+
Scenario: one match in one file using the example name and the group name
|
45
|
+
When I run "rspec . --example 'first group first example in first group'"
|
46
|
+
Then I should see "1 example, 0 failures"
|
47
|
+
|
44
48
|
Scenario: one match in one file using regexp
|
45
49
|
When I run "rspec . --example 'first .* first example'"
|
46
50
|
Then I should see "1 example, 0 failures"
|
@@ -41,15 +41,14 @@ Feature: spec/spec.opts
|
|
41
41
|
When I run "rspec ./spec/example_spec.rb"
|
42
42
|
Then I should see "1 example, 0 failures"
|
43
43
|
|
44
|
-
|
45
|
-
Scenario: formatter set in both (.rspec wins)
|
44
|
+
Scenario: formatter set in both (RSpec.configure wins)
|
46
45
|
Given a file named ".rspec" with:
|
47
46
|
"""
|
48
|
-
--format
|
47
|
+
--format progress
|
49
48
|
"""
|
50
49
|
And a file named "spec/spec_helper.rb" with:
|
51
50
|
"""
|
52
|
-
RSpec.configure {|c| c.formatter = '
|
51
|
+
RSpec.configure {|c| c.formatter = 'documentation'}
|
53
52
|
"""
|
54
53
|
And a file named "spec/example_spec.rb" with:
|
55
54
|
"""
|
@@ -197,6 +197,36 @@ Feature: before and after hooks
|
|
197
197
|
Then I should see "1 example, 0 failures"
|
198
198
|
Then I should see matching /outer before all\n.outer after all\n\n\n\nFinished/
|
199
199
|
|
200
|
+
Scenario: nested examples have access to state set in outer before(:all)
|
201
|
+
Given a file named "before_all_spec.rb" with:
|
202
|
+
"""
|
203
|
+
describe "something" do
|
204
|
+
before :all do
|
205
|
+
@value = 123
|
206
|
+
end
|
207
|
+
|
208
|
+
describe "nested" do
|
209
|
+
it "access state set in before(:all)" do
|
210
|
+
@value.should eq(123)
|
211
|
+
end
|
212
|
+
|
213
|
+
describe "nested more deeply" do
|
214
|
+
it "access state set in before(:all)" do
|
215
|
+
@value.should eq(123)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe "nested in parallel" do
|
221
|
+
it "access state set in before(:all)" do
|
222
|
+
@value.should == 123
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
"""
|
227
|
+
When I run "rspec before_all_spec.rb"
|
228
|
+
Then I should see "3 examples, 0 failures"
|
229
|
+
|
200
230
|
Scenario: before/after all blocks have access to state
|
201
231
|
Given a file named "before_and_after_all_spec.rb" with:
|
202
232
|
"""
|
data/features/hooks/halt.feature
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
Feature: halt
|
2
2
|
|
3
|
-
In an example, before
|
4
|
-
|
5
|
-
criteria.
|
3
|
+
In an example, before or after hook, you can halt the current example, group,
|
4
|
+
or suite based on arbitrary criteria.
|
6
5
|
|
7
|
-
|
6
|
+
@wip
|
8
7
|
Scenario: halt group on failure
|
9
8
|
Given a directory named "spec"
|
10
9
|
And a file named "spec/example_spec.rb" with:
|
@@ -120,10 +120,30 @@ module RSpec
|
|
120
120
|
backtrace_clean_patterns.clear
|
121
121
|
end
|
122
122
|
|
123
|
+
def color_enabled=(bool)
|
124
|
+
return unless bool
|
125
|
+
settings[:color_enabled] = true
|
126
|
+
if bool && Config::CONFIG['host_os'] =~ /mswin|mingw/
|
127
|
+
orig_output_stream = settings[:output_stream]
|
128
|
+
begin
|
129
|
+
require 'Win32/Console/ANSI'
|
130
|
+
rescue LoadError
|
131
|
+
warn "You must 'gem install win32console' to use colour on Windows"
|
132
|
+
settings[:color_enabled] = false
|
133
|
+
ensure
|
134
|
+
settings[:output_stream] = orig_output_stream
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
123
139
|
def libs=(libs)
|
124
140
|
libs.map {|lib| $LOAD_PATH.unshift lib}
|
125
141
|
end
|
126
142
|
|
143
|
+
def requires=(paths)
|
144
|
+
paths.map {|path| require path}
|
145
|
+
end
|
146
|
+
|
127
147
|
def debug=(bool)
|
128
148
|
return unless bool
|
129
149
|
begin
|
@@ -151,13 +171,17 @@ EOM
|
|
151
171
|
end
|
152
172
|
|
153
173
|
def formatter=(formatter_to_use)
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
174
|
+
if formatter_to_use.is_a?(Class)
|
175
|
+
formatter_class = formatter_to_use
|
176
|
+
else
|
177
|
+
formatter_class = case formatter_to_use.to_s
|
178
|
+
when 'd', 'doc', 'documentation', 's', 'n', 'spec', 'nested'
|
179
|
+
RSpec::Core::Formatters::DocumentationFormatter
|
180
|
+
when 'progress'
|
181
|
+
RSpec::Core::Formatters::ProgressFormatter
|
182
|
+
else
|
183
|
+
raise ArgumentError, "Formatter '#{formatter_to_use}' unknown - maybe you meant 'documentation' or 'progress'?."
|
184
|
+
end
|
161
185
|
end
|
162
186
|
self.formatter_class = formatter_class
|
163
187
|
end
|
@@ -189,10 +213,16 @@ EOM
|
|
189
213
|
RSpec::Core::ExampleGroup.alias_example_to(new_name, extra_options)
|
190
214
|
end
|
191
215
|
|
192
|
-
def
|
216
|
+
def filter_run_including(options={})
|
193
217
|
self.filter = options unless filter and filter[:line_number] || filter[:full_description]
|
194
218
|
end
|
195
219
|
|
220
|
+
alias_method :filter_run, :filter_run_including
|
221
|
+
|
222
|
+
def filter_run_excluding(options={})
|
223
|
+
self.exclusion_filter = options
|
224
|
+
end
|
225
|
+
|
196
226
|
def include(mod, filters={})
|
197
227
|
include_or_extend_modules << [:include, mod, filters]
|
198
228
|
end
|
@@ -12,37 +12,47 @@ module RSpec
|
|
12
12
|
|
13
13
|
def initialize(args)
|
14
14
|
@args = args
|
15
|
-
@options = parse_options
|
16
15
|
end
|
17
16
|
|
18
17
|
def configure(config)
|
19
|
-
|
20
|
-
config.send("#{key}=",
|
18
|
+
sorted_keys.each do |key|
|
19
|
+
config.send("#{key}=", options[key])
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
23
|
+
def sorted_keys
|
24
|
+
options.keys.sort{|a,b| a.to_s <=> b.to_s}
|
25
|
+
end
|
26
|
+
|
24
27
|
def drb_argv
|
25
28
|
argv = []
|
26
29
|
argv << "--color" if options[:color_enabled]
|
27
30
|
argv << "--profile" if options[:profile_examples]
|
28
31
|
argv << "--backtrace" if options[:full_backtrace]
|
29
|
-
argv << "--
|
32
|
+
argv << "--format" << options[:formatter] if options[:formatter]
|
30
33
|
argv << "--line_number" << options[:line_number] if options[:line_number]
|
31
34
|
argv << "--options_file" << options[:options_file] if options[:options_file]
|
32
35
|
argv << "--example" << options[:full_description].source if options[:full_description]
|
33
36
|
argv + options[:files_or_directories_to_run]
|
34
37
|
end
|
35
38
|
|
36
|
-
private
|
37
|
-
|
38
39
|
def parse_options
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
@options = begin
|
41
|
+
command_line_options = parse_command_line_options
|
42
|
+
local_options = parse_local_options(command_line_options)
|
43
|
+
global_options = parse_global_options
|
44
|
+
env_options = parse_env_options
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
[global_options, local_options, command_line_options, env_options].inject do |merged, options|
|
47
|
+
merged.merge(options)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def parse_env_options
|
55
|
+
ENV["SPEC_OPTS"] ? Parser.parse!(ENV["SPEC_OPTS"].split) : {}
|
46
56
|
end
|
47
57
|
|
48
58
|
def parse_command_line_options
|
@@ -65,13 +65,17 @@ module RSpec
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def self.examples
|
68
|
-
@
|
68
|
+
@examples ||= []
|
69
69
|
end
|
70
70
|
|
71
71
|
def self.filtered_examples
|
72
72
|
world.filtered_examples[self]
|
73
73
|
end
|
74
74
|
|
75
|
+
def self.descendant_filtered_examples
|
76
|
+
filtered_examples + children.collect{|c| c.descendant_filtered_examples}
|
77
|
+
end
|
78
|
+
|
75
79
|
def self.metadata
|
76
80
|
@metadata
|
77
81
|
end
|
@@ -111,8 +115,8 @@ module RSpec
|
|
111
115
|
@children ||= []
|
112
116
|
end
|
113
117
|
|
114
|
-
def self.
|
115
|
-
[self] + children.collect {|c| c.
|
118
|
+
def self.descendants
|
119
|
+
[self] + children.collect {|c| c.descendants}.flatten
|
116
120
|
end
|
117
121
|
|
118
122
|
def self.ancestors
|
@@ -132,14 +136,12 @@ module RSpec
|
|
132
136
|
end
|
133
137
|
|
134
138
|
def self.eval_before_alls(running_example)
|
135
|
-
return if
|
139
|
+
return if descendant_filtered_examples.empty?
|
136
140
|
superclass.before_all_ivars.each { |ivar, val| running_example.instance_variable_set(ivar, val) }
|
137
141
|
world.run_hook(:before, :all, self, running_example)
|
138
142
|
|
139
|
-
|
140
|
-
|
141
|
-
running_example.instance_eval &ancestor.before_alls.shift
|
142
|
-
end
|
143
|
+
until before_alls.empty?
|
144
|
+
running_example.instance_eval &before_alls.shift
|
143
145
|
end
|
144
146
|
running_example.instance_variables.each { |ivar| before_all_ivars[ivar] = running_example.instance_variable_get(ivar) }
|
145
147
|
end
|
@@ -155,7 +157,7 @@ module RSpec
|
|
155
157
|
end
|
156
158
|
|
157
159
|
def self.eval_after_alls(running_example)
|
158
|
-
return if
|
160
|
+
return if descendant_filtered_examples.empty?
|
159
161
|
before_all_ivars.each { |ivar, val| running_example.instance_variable_set(ivar, val) }
|
160
162
|
ancestors.each do |ancestor|
|
161
163
|
until ancestor.after_alls.empty?
|
@@ -171,8 +173,8 @@ module RSpec
|
|
171
173
|
begin
|
172
174
|
eval_before_alls(example_group_instance)
|
173
175
|
result_for_this_group = run_examples(example_group_instance, reporter)
|
174
|
-
|
175
|
-
result_for_this_group && (children.empty? ? true :
|
176
|
+
results_for_descendants = children.map {|child| child.run(reporter)}
|
177
|
+
result_for_this_group && (children.empty? ? true : results_for_descendants)
|
176
178
|
ensure
|
177
179
|
eval_after_alls(example_group_instance)
|
178
180
|
end
|
data/lib/rspec/core/hooks.rb
CHANGED
@@ -9,6 +9,10 @@ module RSpec::Core
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def parse!(args)
|
12
|
+
if args.include?("--formatter")
|
13
|
+
args[args.index("--formatter")] = "--format"
|
14
|
+
RSpec.deprecate("the --formatter option", "-f or --format")
|
15
|
+
end
|
12
16
|
options = {}
|
13
17
|
parser(options).parse!(args)
|
14
18
|
options
|
@@ -37,9 +41,10 @@ module RSpec::Core
|
|
37
41
|
options[:full_description] = /#{o}/
|
38
42
|
end
|
39
43
|
|
40
|
-
parser.on('-f', '--
|
44
|
+
parser.on('-f', '--format FORMATTER', 'Choose a formatter',
|
41
45
|
' [p]rogress (default - dots)',
|
42
|
-
' [d]ocumentation (group and example names)'
|
46
|
+
' [d]ocumentation (group and example names)',
|
47
|
+
' custom formatter class name') do |o|
|
43
48
|
options[:formatter] = o
|
44
49
|
end
|
45
50
|
|
@@ -57,7 +62,7 @@ module RSpec::Core
|
|
57
62
|
options[:line_number] = o
|
58
63
|
end
|
59
64
|
|
60
|
-
parser.on('-o', '--options PATH', 'Read configuration options from a file path. (Defaults to
|
65
|
+
parser.on('-o', '--options PATH', 'Read configuration options from a file path. (Defaults to .rspec)') do |o|
|
61
66
|
options[:options_file] = o || local_options_file
|
62
67
|
end
|
63
68
|
|
@@ -65,6 +70,11 @@ module RSpec::Core
|
|
65
70
|
options[:profile_examples] = o
|
66
71
|
end
|
67
72
|
|
73
|
+
parser.on('-r', '--require PATH', 'Require a file') do |path|
|
74
|
+
options[:requires] ||= []
|
75
|
+
options[:requires] << path
|
76
|
+
end
|
77
|
+
|
68
78
|
parser.on('-v', '--version', 'Show version') do
|
69
79
|
puts RSpec::Core::Version::STRING
|
70
80
|
exit
|
data/lib/rspec/core/world.rb
CHANGED
@@ -37,7 +37,7 @@ module RSpec
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def example_count
|
40
|
-
example_groups.collect {|g| g.
|
40
|
+
example_groups.collect {|g| g.descendants}.flatten.inject(0) { |sum, g| sum += g.filtered_examples.size }
|
41
41
|
end
|
42
42
|
|
43
43
|
def apply_inclusion_filters(examples, conditions={})
|
data/rspec-core.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rspec-core}
|
8
|
-
s.version = "2.0.0.beta.
|
8
|
+
s.version = "2.0.0.beta.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Chad Humphries", "David Chelimsky"]
|
12
|
-
s.date = %q{2010-06-
|
12
|
+
s.date = %q{2010-06-14}
|
13
13
|
s.description = %q{RSpec runner and example group classes}
|
14
14
|
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
|
15
15
|
s.executables = ["rspec", "spec"]
|
@@ -39,7 +39,6 @@ Gem::Specification.new do |s|
|
|
39
39
|
"features/example_groups/nested_groups.feature",
|
40
40
|
"features/filtering/inclusion_filters.feature",
|
41
41
|
"features/formatters/custom_formatter.feature",
|
42
|
-
"features/hooks/around_hook.feature",
|
43
42
|
"features/hooks/before_and_after_hooks.feature",
|
44
43
|
"features/hooks/described_class.feature",
|
45
44
|
"features/hooks/halt.feature",
|
@@ -107,9 +106,11 @@ Gem::Specification.new do |s|
|
|
107
106
|
"spec/rspec/core/formatters/documentation_formatter_spec.rb",
|
108
107
|
"spec/rspec/core/formatters/helpers_spec.rb",
|
109
108
|
"spec/rspec/core/formatters/progress_formatter_spec.rb",
|
109
|
+
"spec/rspec/core/hooks_spec.rb",
|
110
110
|
"spec/rspec/core/kernel_extensions_spec.rb",
|
111
111
|
"spec/rspec/core/let_spec.rb",
|
112
112
|
"spec/rspec/core/metadata_spec.rb",
|
113
|
+
"spec/rspec/core/option_parser_spec.rb",
|
113
114
|
"spec/rspec/core/pending_example_spec.rb",
|
114
115
|
"spec/rspec/core/resources/a_bar.rb",
|
115
116
|
"spec/rspec/core/resources/a_foo.rb",
|
@@ -130,11 +131,7 @@ Gem::Specification.new do |s|
|
|
130
131
|
s.homepage = %q{http://github.com/rspec/core}
|
131
132
|
s.post_install_message = %q{**************************************************
|
132
133
|
|
133
|
-
Thank you for installing rspec-core-2.0.0.beta.
|
134
|
-
|
135
|
-
This is beta software. If you are looking
|
136
|
-
for a supported production release, please
|
137
|
-
"gem install rspec" (without --pre).
|
134
|
+
Thank you for installing rspec-core-2.0.0.beta.12
|
138
135
|
|
139
136
|
**************************************************
|
140
137
|
}
|
@@ -142,7 +139,7 @@ Gem::Specification.new do |s|
|
|
142
139
|
s.require_paths = ["lib"]
|
143
140
|
s.rubyforge_project = %q{rspec}
|
144
141
|
s.rubygems_version = %q{1.3.6}
|
145
|
-
s.summary = %q{rspec-core-2.0.0.beta.
|
142
|
+
s.summary = %q{rspec-core-2.0.0.beta.12}
|
146
143
|
s.test_files = [
|
147
144
|
"spec/autotest/failed_results_re_spec.rb",
|
148
145
|
"spec/autotest/rspec_spec.rb",
|
@@ -157,9 +154,11 @@ Gem::Specification.new do |s|
|
|
157
154
|
"spec/rspec/core/formatters/documentation_formatter_spec.rb",
|
158
155
|
"spec/rspec/core/formatters/helpers_spec.rb",
|
159
156
|
"spec/rspec/core/formatters/progress_formatter_spec.rb",
|
157
|
+
"spec/rspec/core/hooks_spec.rb",
|
160
158
|
"spec/rspec/core/kernel_extensions_spec.rb",
|
161
159
|
"spec/rspec/core/let_spec.rb",
|
162
160
|
"spec/rspec/core/metadata_spec.rb",
|
161
|
+
"spec/rspec/core/option_parser_spec.rb",
|
163
162
|
"spec/rspec/core/pending_example_spec.rb",
|
164
163
|
"spec/rspec/core/resources/a_bar.rb",
|
165
164
|
"spec/rspec/core/resources/a_foo.rb",
|
@@ -182,19 +181,19 @@ Gem::Specification.new do |s|
|
|
182
181
|
s.specification_version = 3
|
183
182
|
|
184
183
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
185
|
-
s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
186
|
-
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
184
|
+
s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.12"])
|
185
|
+
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.12"])
|
187
186
|
s.add_development_dependency(%q<cucumber>, [">= 0.5.3"])
|
188
187
|
s.add_development_dependency(%q<autotest>, [">= 4.2.9"])
|
189
188
|
else
|
190
|
-
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
191
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
189
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.12"])
|
190
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.12"])
|
192
191
|
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
193
192
|
s.add_dependency(%q<autotest>, [">= 4.2.9"])
|
194
193
|
end
|
195
194
|
else
|
196
|
-
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
197
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
195
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.12"])
|
196
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.12"])
|
198
197
|
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
199
198
|
s.add_dependency(%q<autotest>, [">= 4.2.9"])
|
200
199
|
end
|
@@ -5,13 +5,25 @@ require 'ostruct'
|
|
5
5
|
describe RSpec::Core::ConfigurationOptions do
|
6
6
|
|
7
7
|
def config_options_object(*args)
|
8
|
-
RSpec::Core::ConfigurationOptions.new(args)
|
8
|
+
coo = RSpec::Core::ConfigurationOptions.new(args)
|
9
|
+
coo.parse_options
|
10
|
+
coo
|
9
11
|
end
|
10
12
|
|
11
13
|
def options_from_args(*args)
|
12
14
|
config_options_object(*args).options
|
13
15
|
end
|
14
16
|
|
17
|
+
describe "#configure" do
|
18
|
+
it "sends libs before requires" do
|
19
|
+
opts = config_options_object(*%w[--require a/path -I a/lib])
|
20
|
+
config = double("config").as_null_object
|
21
|
+
config.should_receive(:libs=).ordered
|
22
|
+
config.should_receive(:requires=).ordered
|
23
|
+
opts.configure(config)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
15
27
|
describe 'color_enabled' do
|
16
28
|
example "-c, --colour, or --color are parsed as true" do
|
17
29
|
options_from_args('-c').should include(:color_enabled => true)
|
@@ -33,12 +45,25 @@ describe RSpec::Core::ConfigurationOptions do
|
|
33
45
|
end
|
34
46
|
end
|
35
47
|
|
36
|
-
describe
|
37
|
-
example
|
38
|
-
options_from_args('--
|
48
|
+
describe '--require' do
|
49
|
+
example "--requires files" do
|
50
|
+
options_from_args('--require', 'a/path').should include(:requires => ['a/path'])
|
51
|
+
end
|
52
|
+
example "--require can be used more than once" do
|
53
|
+
options_from_args('--require', 'path/1', '--require', 'path/2').should include(:requires => ['path/1','path/2'])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'format' do
|
58
|
+
example '-f or --format with an argument should parse' do
|
59
|
+
options_from_args('--format', 'd').should include(:formatter => 'd')
|
39
60
|
options_from_args('-f', 'd').should include(:formatter => 'd')
|
40
61
|
options_from_args('-fd').should include(:formatter => 'd')
|
41
62
|
end
|
63
|
+
|
64
|
+
example "-f/--format can accept a class name" do
|
65
|
+
options_from_args('-fSome::Formatter::Class').should include(:formatter => 'Some::Formatter::Class')
|
66
|
+
end
|
42
67
|
end
|
43
68
|
|
44
69
|
describe 'profile_examples' do
|
@@ -155,8 +180,8 @@ describe RSpec::Core::ConfigurationOptions do
|
|
155
180
|
|
156
181
|
context "--drb specified in ARGV" do
|
157
182
|
it "renders all the original arguments except --drb" do
|
158
|
-
config_options_object(*%w[ --drb --color --
|
159
|
-
drb_argv.should eq(%w[ --color --profile --backtrace --
|
183
|
+
config_options_object(*%w[ --drb --color --format s --line_number 1 --example pattern --profile --backtrace]).
|
184
|
+
drb_argv.should eq(%w[ --color --profile --backtrace --format s --line_number 1 --example pattern ])
|
160
185
|
end
|
161
186
|
end
|
162
187
|
|
@@ -164,8 +189,8 @@ describe RSpec::Core::ConfigurationOptions do
|
|
164
189
|
it "renders all the original arguments except --drb" do
|
165
190
|
File.stub(:exist?) { true }
|
166
191
|
File.stub(:readlines) { %w[ --drb --color ] }
|
167
|
-
config_options_object(*%w[ --
|
168
|
-
drb_argv.should eq(%w[ --color --profile --backtrace --
|
192
|
+
config_options_object(*%w[ --format s --line_number 1 --example pattern --profile --backtrace ]).
|
193
|
+
drb_argv.should eq(%w[ --color --profile --backtrace --format s --line_number 1 --example pattern ])
|
169
194
|
end
|
170
195
|
end
|
171
196
|
|
@@ -173,8 +198,8 @@ describe RSpec::Core::ConfigurationOptions do
|
|
173
198
|
it "renders all the original arguments except --drb" do
|
174
199
|
File.stub(:exist?) { true }
|
175
200
|
File.stub(:readlines) { %w[ --drb --color ] }
|
176
|
-
config_options_object(*%w[ --drb --
|
177
|
-
drb_argv.should eq(%w[ --color --profile --backtrace --
|
201
|
+
config_options_object(*%w[ --drb --format s --line_number 1 --example pattern --profile --backtrace]).
|
202
|
+
drb_argv.should eq(%w[ --color --profile --backtrace --format s --line_number 1 --example pattern ])
|
178
203
|
end
|
179
204
|
end
|
180
205
|
|
@@ -182,8 +207,8 @@ describe RSpec::Core::ConfigurationOptions do
|
|
182
207
|
it "renders all the original arguments except --drb and --options" do
|
183
208
|
File.stub(:exist?) { true }
|
184
209
|
File.stub(:readlines) { %w[ --drb --color ] }
|
185
|
-
config_options_object(*%w[ --drb --
|
186
|
-
drb_argv.should eq(%w[ --color --profile --backtrace --
|
210
|
+
config_options_object(*%w[ --drb --format s --line_number 1 --example pattern --profile --backtrace]).
|
211
|
+
drb_argv.should eq(%w[ --color --profile --backtrace --format s --line_number 1 --example pattern ])
|
187
212
|
end
|
188
213
|
end
|
189
214
|
end
|
@@ -193,19 +218,21 @@ describe RSpec::Core::ConfigurationOptions do
|
|
193
218
|
|
194
219
|
it "loads automatically" do
|
195
220
|
File.stub(:exist?) { true }
|
196
|
-
File.stub(:readlines) { ["--
|
221
|
+
File.stub(:readlines) { ["--format", "doc"] }
|
197
222
|
|
198
|
-
|
199
|
-
|
223
|
+
config_options = RSpec::Core::ConfigurationOptions.new([])
|
224
|
+
config_options.parse_options
|
225
|
+
config_options.configure(config)
|
200
226
|
config.formatter.should == 'doc'
|
201
227
|
end
|
202
228
|
|
203
229
|
it "allows options on one line" do
|
204
230
|
File.stub(:exist?) { true }
|
205
|
-
File.stub(:readlines) { ["--
|
231
|
+
File.stub(:readlines) { ["--format doc"] }
|
206
232
|
|
207
|
-
|
208
|
-
|
233
|
+
config_options = RSpec::Core::ConfigurationOptions.new([])
|
234
|
+
config_options.parse_options
|
235
|
+
config_options.configure(config)
|
209
236
|
config.formatter.should == 'doc'
|
210
237
|
end
|
211
238
|
|
@@ -214,16 +241,17 @@ describe RSpec::Core::ConfigurationOptions do
|
|
214
241
|
File.stub(:readlines) do |path|
|
215
242
|
case path
|
216
243
|
when ".rspec"
|
217
|
-
["--
|
244
|
+
["--format", "documentation"]
|
218
245
|
when /\.rspec/
|
219
246
|
["--line", "37"]
|
220
247
|
else
|
221
248
|
raise "Unexpected path: #{path}"
|
222
249
|
end
|
223
250
|
end
|
224
|
-
|
251
|
+
config_options = RSpec::Core::ConfigurationOptions.new(["--no-color"])
|
252
|
+
config_options.parse_options
|
225
253
|
|
226
|
-
|
254
|
+
config_options.configure(config)
|
227
255
|
|
228
256
|
config.formatter.should == "documentation"
|
229
257
|
config.line_number.should == "37"
|
@@ -235,28 +263,51 @@ describe RSpec::Core::ConfigurationOptions do
|
|
235
263
|
File.stub(:readlines) do |path|
|
236
264
|
case path
|
237
265
|
when ".rspec"
|
238
|
-
["--
|
266
|
+
["--format", "local"]
|
239
267
|
when /\.rspec/
|
240
|
-
["--
|
268
|
+
["--format", "global"]
|
241
269
|
else
|
242
270
|
raise "Unexpected path: #{path}"
|
243
271
|
end
|
244
272
|
end
|
245
|
-
|
273
|
+
config_options = RSpec::Core::ConfigurationOptions.new([])
|
274
|
+
config_options.parse_options
|
246
275
|
|
247
|
-
|
276
|
+
config_options.configure(config)
|
248
277
|
|
249
278
|
config.formatter.should == "local"
|
250
279
|
end
|
251
280
|
|
252
281
|
it "prefers CLI options over file options" do
|
253
|
-
config_options = RSpec::Core::ConfigurationOptions.new(['--
|
282
|
+
config_options = RSpec::Core::ConfigurationOptions.new(['--format', 'progress'])
|
254
283
|
config_options.stub(:parse_options_file).and_return(:formatter => 'documentation')
|
255
284
|
|
285
|
+
config_options.parse_options
|
256
286
|
config_options.configure(config)
|
257
287
|
|
258
288
|
config.formatter.should == 'progress'
|
259
289
|
end
|
290
|
+
|
291
|
+
context "with SPEC_OPTS" do
|
292
|
+
before do
|
293
|
+
@orig_spec_opts = ENV["SPEC_OPTS"]
|
294
|
+
end
|
295
|
+
|
296
|
+
after do
|
297
|
+
ENV["SPEC_OPTS"] = @orig_spec_opts
|
298
|
+
end
|
299
|
+
|
300
|
+
it "prefers SPEC_OPTS options over file options" do
|
301
|
+
config = OpenStruct.new
|
302
|
+
ENV["SPEC_OPTS"] = "--format documentation"
|
303
|
+
config_options = RSpec::Core::ConfigurationOptions.new(['--format', 'progress'])
|
304
|
+
|
305
|
+
config_options.parse_options
|
306
|
+
config_options.configure(config)
|
307
|
+
|
308
|
+
config.formatter.should == 'documentation'
|
309
|
+
end
|
310
|
+
end
|
260
311
|
end
|
261
312
|
end
|
262
313
|
|
@@ -181,6 +181,55 @@ module RSpec::Core
|
|
181
181
|
config.run_all_when_everything_filtered?.should == true
|
182
182
|
end
|
183
183
|
end
|
184
|
+
|
185
|
+
describe 'color_enabled=' do
|
186
|
+
context "given true" do
|
187
|
+
context "on windows" do
|
188
|
+
before do
|
189
|
+
@original_host = Config::CONFIG['host_os']
|
190
|
+
Config::CONFIG['host_os'] = 'mswin'
|
191
|
+
config.stub(:require)
|
192
|
+
config.stub(:warn)
|
193
|
+
end
|
194
|
+
|
195
|
+
after do
|
196
|
+
Config::CONFIG['host_os'] = @original_host
|
197
|
+
end
|
198
|
+
|
199
|
+
context "with win32console available" do
|
200
|
+
it "requires win32console" do
|
201
|
+
config.should_receive(:require).
|
202
|
+
with("Win32/Console/ANSI")
|
203
|
+
config.color_enabled = true
|
204
|
+
end
|
205
|
+
|
206
|
+
it "leaves output stream intact" do
|
207
|
+
config.output_stream = $stdout
|
208
|
+
config.stub(:require) do |what|
|
209
|
+
config.output_stream = 'foo' if what =~ /Win32/
|
210
|
+
end
|
211
|
+
config.color_enabled = true
|
212
|
+
config.output_stream.should eq($stdout)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context "with win32console NOT available" do
|
217
|
+
it "warns to install win32console" do
|
218
|
+
config.stub(:require) { raise LoadError }
|
219
|
+
config.should_receive(:warn).
|
220
|
+
with /You must 'gem install win32console'/
|
221
|
+
config.color_enabled = true
|
222
|
+
end
|
223
|
+
|
224
|
+
it "sets color_enabled to false" do
|
225
|
+
config.stub(:require) { raise LoadError }
|
226
|
+
config.color_enabled = true
|
227
|
+
config.color_enabled.should be_false
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
184
233
|
|
185
234
|
describe 'formatter=' do
|
186
235
|
|
@@ -190,6 +239,12 @@ module RSpec::Core
|
|
190
239
|
config.formatter = 'documentation'
|
191
240
|
config.formatter.should be_an_instance_of(Formatters::DocumentationFormatter)
|
192
241
|
end
|
242
|
+
|
243
|
+
it "sets a formatter based on its class" do
|
244
|
+
formatter_class = Class.new(Formatters::BaseTextFormatter)
|
245
|
+
config.formatter = formatter_class
|
246
|
+
config.formatter.should be_an_instance_of(formatter_class)
|
247
|
+
end
|
193
248
|
|
194
249
|
it "raises ArgumentError if formatter is unknown" do
|
195
250
|
lambda { config.formatter = :progresss }.should raise_error(ArgumentError)
|
@@ -197,6 +252,20 @@ module RSpec::Core
|
|
197
252
|
|
198
253
|
end
|
199
254
|
|
255
|
+
describe "#filter_run" do
|
256
|
+
it "sets the filter" do
|
257
|
+
config.filter_run :focus => true
|
258
|
+
config.filter.should eq({:focus => true})
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
describe "#filter_run_excluding" do
|
263
|
+
it "sets the filter" do
|
264
|
+
config.filter_run_excluding :slow => true
|
265
|
+
config.exclusion_filter.should eq({:slow => true})
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
200
269
|
describe "line_number=" do
|
201
270
|
it "sets the line number" do
|
202
271
|
config.line_number = '37'
|
@@ -260,6 +329,13 @@ module RSpec::Core
|
|
260
329
|
end
|
261
330
|
end
|
262
331
|
|
332
|
+
describe "requires=" do
|
333
|
+
it "requires paths" do
|
334
|
+
config.should_receive(:require).with("a/path")
|
335
|
+
config.requires = ["a/path"]
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
263
339
|
describe "#add_setting" do
|
264
340
|
describe "with no modifiers" do
|
265
341
|
context "with no additional options" do
|
@@ -29,15 +29,15 @@ module RSpec::Core
|
|
29
29
|
examples_run.should have(1).example
|
30
30
|
end
|
31
31
|
|
32
|
-
describe "
|
33
|
-
it "returns self + all
|
32
|
+
describe "descendants" do
|
33
|
+
it "returns self + all descendants" do
|
34
34
|
group = ExampleGroup.describe("parent") do
|
35
35
|
describe("child") do
|
36
36
|
describe("grandchild 1") {}
|
37
37
|
describe("grandchild 2") {}
|
38
38
|
end
|
39
39
|
end
|
40
|
-
group.
|
40
|
+
group.descendants.size.should == 4
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -249,12 +249,6 @@ module RSpec::Core
|
|
249
249
|
end.to_not raise_error
|
250
250
|
end
|
251
251
|
|
252
|
-
it "exposes the around each blocks at after_alls" do
|
253
|
-
group = ExampleGroup.describe
|
254
|
-
group.around(:each) { 'foo' }
|
255
|
-
group.should have(1).around_eachs
|
256
|
-
end
|
257
|
-
|
258
252
|
it "treats an error in before(:each) as a failure" do
|
259
253
|
group = ExampleGroup.describe
|
260
254
|
group.before(:each) { raise "error in before each" }
|
@@ -426,22 +420,6 @@ module RSpec::Core
|
|
426
420
|
end
|
427
421
|
end
|
428
422
|
|
429
|
-
describe "#around" do
|
430
|
-
around(:each) do |example|
|
431
|
-
SelfObserver.new
|
432
|
-
example.run
|
433
|
-
SelfObserver.cache.clear
|
434
|
-
end
|
435
|
-
|
436
|
-
it "has 1 SelfObserver (1)" do
|
437
|
-
SelfObserver.cache.length.should == 1
|
438
|
-
end
|
439
|
-
|
440
|
-
it "has 1 SelfObserver (2)" do
|
441
|
-
SelfObserver.cache.length.should == 1
|
442
|
-
end
|
443
|
-
end
|
444
|
-
|
445
423
|
describe "#its" do
|
446
424
|
its(:class) { should == RSpec::Core::ExampleGroup }
|
447
425
|
it "does not interfere between examples" do
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module RSpec::Core
|
4
|
+
describe OptionParser do
|
5
|
+
before do
|
6
|
+
RSpec.stub(:deprecate)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "deprecates the --formatter option" do
|
10
|
+
RSpec.should_receive(:deprecate)
|
11
|
+
Parser.parse!(%w[--formatter doc])
|
12
|
+
end
|
13
|
+
|
14
|
+
it "converts --formatter to --format" do
|
15
|
+
options = Parser.parse!(%w[--formatter doc])
|
16
|
+
options.should eq( {:formatter=>"doc"} )
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -24,6 +24,7 @@ module RSpec::Core
|
|
24
24
|
@err = @out = StringIO.new
|
25
25
|
|
26
26
|
@options = RSpec::Core::ConfigurationOptions.new(%w[--drb --drb-port 8181 --color])
|
27
|
+
@options.parse_options
|
27
28
|
RSpec::Core::ConfigurationOptions.stub(:new) { @options }
|
28
29
|
|
29
30
|
@drb_proxy = double(RSpec::Core::DRbCommandLine, :run => true)
|
data/spec/spec_helper.rb
CHANGED
@@ -52,9 +52,11 @@ Spork.prefork do
|
|
52
52
|
|
53
53
|
RSpec.configure do |c|
|
54
54
|
c.color_enabled = !in_editor?
|
55
|
-
c.
|
55
|
+
c.filter_run :focus => true
|
56
|
+
c.run_all_when_everything_filtered = true
|
57
|
+
c.filter_run_excluding :ruby => lambda {|version|
|
56
58
|
!(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
|
57
|
-
}
|
59
|
+
}
|
58
60
|
c.before(:each) do
|
59
61
|
@real_world = RSpec.world
|
60
62
|
RSpec.instance_variable_set(:@world, RSpec::Core::World.new)
|
metadata
CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
|
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- beta
|
10
|
-
-
|
11
|
-
version: 2.0.0.beta.
|
10
|
+
- 12
|
11
|
+
version: 2.0.0.beta.12
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Chad Humphries
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-06-
|
20
|
+
date: 2010-06-14 00:00:00 -05:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -32,8 +32,8 @@ dependencies:
|
|
32
32
|
- 0
|
33
33
|
- 0
|
34
34
|
- beta
|
35
|
-
-
|
36
|
-
version: 2.0.0.beta.
|
35
|
+
- 12
|
36
|
+
version: 2.0.0.beta.12
|
37
37
|
type: :development
|
38
38
|
version_requirements: *id001
|
39
39
|
- !ruby/object:Gem::Dependency
|
@@ -48,8 +48,8 @@ dependencies:
|
|
48
48
|
- 0
|
49
49
|
- 0
|
50
50
|
- beta
|
51
|
-
-
|
52
|
-
version: 2.0.0.beta.
|
51
|
+
- 12
|
52
|
+
version: 2.0.0.beta.12
|
53
53
|
type: :development
|
54
54
|
version_requirements: *id002
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -112,7 +112,6 @@ files:
|
|
112
112
|
- features/example_groups/nested_groups.feature
|
113
113
|
- features/filtering/inclusion_filters.feature
|
114
114
|
- features/formatters/custom_formatter.feature
|
115
|
-
- features/hooks/around_hook.feature
|
116
115
|
- features/hooks/before_and_after_hooks.feature
|
117
116
|
- features/hooks/described_class.feature
|
118
117
|
- features/hooks/halt.feature
|
@@ -180,9 +179,11 @@ files:
|
|
180
179
|
- spec/rspec/core/formatters/documentation_formatter_spec.rb
|
181
180
|
- spec/rspec/core/formatters/helpers_spec.rb
|
182
181
|
- spec/rspec/core/formatters/progress_formatter_spec.rb
|
182
|
+
- spec/rspec/core/hooks_spec.rb
|
183
183
|
- spec/rspec/core/kernel_extensions_spec.rb
|
184
184
|
- spec/rspec/core/let_spec.rb
|
185
185
|
- spec/rspec/core/metadata_spec.rb
|
186
|
+
- spec/rspec/core/option_parser_spec.rb
|
186
187
|
- spec/rspec/core/pending_example_spec.rb
|
187
188
|
- spec/rspec/core/resources/a_bar.rb
|
188
189
|
- spec/rspec/core/resources/a_foo.rb
|
@@ -206,11 +207,7 @@ licenses: []
|
|
206
207
|
post_install_message: |
|
207
208
|
**************************************************
|
208
209
|
|
209
|
-
Thank you for installing rspec-core-2.0.0.beta.
|
210
|
-
|
211
|
-
This is beta software. If you are looking
|
212
|
-
for a supported production release, please
|
213
|
-
"gem install rspec" (without --pre).
|
210
|
+
Thank you for installing rspec-core-2.0.0.beta.12
|
214
211
|
|
215
212
|
**************************************************
|
216
213
|
|
@@ -240,7 +237,7 @@ rubyforge_project: rspec
|
|
240
237
|
rubygems_version: 1.3.6
|
241
238
|
signing_key:
|
242
239
|
specification_version: 3
|
243
|
-
summary: rspec-core-2.0.0.beta.
|
240
|
+
summary: rspec-core-2.0.0.beta.12
|
244
241
|
test_files:
|
245
242
|
- spec/autotest/failed_results_re_spec.rb
|
246
243
|
- spec/autotest/rspec_spec.rb
|
@@ -255,9 +252,11 @@ test_files:
|
|
255
252
|
- spec/rspec/core/formatters/documentation_formatter_spec.rb
|
256
253
|
- spec/rspec/core/formatters/helpers_spec.rb
|
257
254
|
- spec/rspec/core/formatters/progress_formatter_spec.rb
|
255
|
+
- spec/rspec/core/hooks_spec.rb
|
258
256
|
- spec/rspec/core/kernel_extensions_spec.rb
|
259
257
|
- spec/rspec/core/let_spec.rb
|
260
258
|
- spec/rspec/core/metadata_spec.rb
|
259
|
+
- spec/rspec/core/option_parser_spec.rb
|
261
260
|
- spec/rspec/core/pending_example_spec.rb
|
262
261
|
- spec/rspec/core/resources/a_bar.rb
|
263
262
|
- spec/rspec/core/resources/a_foo.rb
|
@@ -1,36 +0,0 @@
|
|
1
|
-
Feature: around hook
|
2
|
-
|
3
|
-
Scenario: define around(:each) block in example group
|
4
|
-
Given a file named "around_each_in_example_group_spec.rb" with:
|
5
|
-
"""
|
6
|
-
require 'rspec/expectations'
|
7
|
-
|
8
|
-
class Thing
|
9
|
-
def self.cache
|
10
|
-
@cache ||= []
|
11
|
-
end
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
self.class.cache << self
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe Thing do
|
19
|
-
around(:each) do |example|
|
20
|
-
Thing.new
|
21
|
-
example.run
|
22
|
-
Thing.cache.clear
|
23
|
-
end
|
24
|
-
|
25
|
-
it "has 1 Thing (1)" do
|
26
|
-
Thing.cache.length.should == 1
|
27
|
-
end
|
28
|
-
|
29
|
-
it "has 1 Thing (2)" do
|
30
|
-
Thing.cache.length.should == 1
|
31
|
-
end
|
32
|
-
end
|
33
|
-
"""
|
34
|
-
When I run "rspec ./around_each_in_example_group_spec.rb"
|
35
|
-
Then the stderr should not contain "NoMethodError"
|
36
|
-
Then I should see "2 examples, 0 failures"
|