rspec-core 2.0.0.beta.5 → 2.0.0.beta.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/README.markdown +12 -0
- data/VERSION +1 -1
- data/features/command_line/example_name_option.feature +3 -3
- data/features/command_line/line_number_appended_to_path.feature +31 -11
- data/features/configuration/{spec_opts.feature → options_file.feature} +9 -19
- data/features/support/env.rb +1 -1
- data/lib/rspec/core.rb +8 -4
- data/lib/rspec/core/configuration.rb +9 -6
- data/lib/rspec/core/configuration_options.rb +137 -0
- data/lib/rspec/core/example_group.rb +5 -10
- data/lib/rspec/core/formatters/base_formatter.rb +54 -19
- data/lib/rspec/core/metadata.rb +6 -6
- data/lib/rspec/core/runner.rb +25 -31
- data/lib/rspec/core/shared_example_group.rb +1 -1
- data/lib/rspec/core/{example_group_subject.rb → subject.rb} +1 -1
- data/rspec-core.gemspec +18 -18
- data/spec/rspec/core/{command_line_options_spec.rb → configuration_options_spec.rb} +86 -50
- data/spec/rspec/core/configuration_spec.rb +10 -3
- data/spec/rspec/core/{example_group_subject_spec.rb → subject_spec.rb} +1 -1
- data/spec/ruby_forker.rb +2 -2
- metadata +17 -17
- data/lib/rspec/core/command_line_options.rb +0 -93
- data/lib/rspec/core/shared_example_group_kernel_extensions.rb +0 -31
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-Ispec
|
data/README.markdown
CHANGED
@@ -63,6 +63,18 @@ Use the documentation formatter to see the resulting spec:
|
|
63
63
|
Finished in 0.000379 seconds
|
64
64
|
1 example, 0 failures
|
65
65
|
|
66
|
+
## Configuration
|
67
|
+
|
68
|
+
You can define runtime configuration options in four places. They
|
69
|
+
are loaded and processed in this order:
|
70
|
+
|
71
|
+
* ~/.rspec
|
72
|
+
* .rspec
|
73
|
+
* RSpec.configure
|
74
|
+
* command line
|
75
|
+
|
76
|
+
Run `rspec --help` to see supported configuration options.
|
77
|
+
|
66
78
|
#### Also see
|
67
79
|
|
68
80
|
* [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.beta.
|
1
|
+
2.0.0.beta.6
|
@@ -2,9 +2,9 @@ Feature: example name option
|
|
2
2
|
|
3
3
|
Use the --example (or -e) option to filter the examples to be run by name.
|
4
4
|
|
5
|
-
The
|
6
|
-
|
7
|
-
|
5
|
+
The argument is compiled to a Ruby Regexp, and matched against the full
|
6
|
+
description of the example, which is the concatenation of descriptions of the
|
7
|
+
group (including any nested groups) and the example.
|
8
8
|
|
9
9
|
This allows you to run a single uniquely named example, all examples with
|
10
10
|
similar names, all the example in a uniquely named group, etc, etc.
|
@@ -7,33 +7,53 @@ Feature: line number appended to file path
|
|
7
7
|
Background:
|
8
8
|
Given a file named "example_spec.rb" with:
|
9
9
|
"""
|
10
|
-
describe "
|
10
|
+
describe "outer group" do
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "first example in outer group" do
|
13
13
|
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "second example in outer group" do
|
17
17
|
|
18
18
|
end
|
19
|
+
|
20
|
+
describe "nested group" do
|
21
|
+
|
22
|
+
it "example in nested group" do
|
23
|
+
|
24
|
+
end
|
19
25
|
|
26
|
+
end
|
27
|
+
|
20
28
|
end
|
21
29
|
"""
|
22
30
|
|
23
|
-
|
31
|
+
@wip
|
32
|
+
Scenario: nested groups - outer group on declaration line
|
24
33
|
When I run "rspec example_spec.rb:1 --format doc"
|
25
|
-
Then I should see "
|
26
|
-
And I should see "
|
27
|
-
And I should see "
|
34
|
+
Then I should see "3 examples, 0 failures"
|
35
|
+
And I should see "second example in outer group"
|
36
|
+
And I should see "first example in outer group"
|
37
|
+
And I should see "example in nested group"
|
38
|
+
|
39
|
+
@wip
|
40
|
+
Scenario: nested groups - inner group on declaration line
|
41
|
+
When I run "rspec example_spec.rb:11 --format doc"
|
42
|
+
Then I should see "3 examples, 0 failures"
|
43
|
+
And I should see "example in nested group"
|
44
|
+
And I should not see "second example in outer group"
|
45
|
+
And I should not see "first example in outer group"
|
28
46
|
|
29
47
|
Scenario: two examples - first example on declaration line
|
30
48
|
When I run "rspec example_spec.rb:3 --format doc"
|
31
49
|
Then I should see "1 example, 0 failures"
|
32
|
-
And I should see "
|
33
|
-
But
|
50
|
+
And I should see "first example in outer group"
|
51
|
+
But I should not see "second example in outer group"
|
52
|
+
And I should not see "example in nested group"
|
34
53
|
|
35
54
|
Scenario: two examples - second example on declaration line
|
36
55
|
When I run "rspec example_spec.rb:7 --format doc"
|
37
56
|
Then I should see "1 example, 0 failures"
|
38
|
-
And I should see "
|
39
|
-
But
|
57
|
+
And I should see "second example in outer group"
|
58
|
+
But I should not see "first example in outer group"
|
59
|
+
And I should not see "example in nested group"
|
@@ -7,18 +7,11 @@ Feature: spec/spec.opts
|
|
7
7
|
Options declared in spec/spec.opts will override configuration
|
8
8
|
set up in Rspec.configure blocks.
|
9
9
|
|
10
|
-
Background:
|
11
|
-
Given a directory named "spec"
|
12
|
-
|
13
10
|
Scenario: color set in Rspec.configure
|
14
|
-
Given a file named "spec/
|
11
|
+
Given a file named "spec/example_spec.rb" with:
|
15
12
|
"""
|
16
|
-
require "rspec/expectations"
|
17
13
|
Rspec.configure {|c| c.color_enabled = true }
|
18
|
-
|
19
|
-
And a file named "spec/example_spec.rb" with:
|
20
|
-
"""
|
21
|
-
require "spec_helper"
|
14
|
+
|
22
15
|
describe "color_enabled" do
|
23
16
|
context "when set with Rspec.configure" do
|
24
17
|
it "is true" do
|
@@ -30,15 +23,13 @@ Feature: spec/spec.opts
|
|
30
23
|
When I run "rspec spec/example_spec.rb"
|
31
24
|
Then I should see "1 example, 0 failures"
|
32
25
|
|
33
|
-
Scenario: color set in
|
34
|
-
Given a file named "
|
26
|
+
Scenario: color set in .rspec
|
27
|
+
Given a file named ".rspec" with:
|
35
28
|
"""
|
36
29
|
--color
|
37
30
|
"""
|
38
31
|
And a file named "spec/example_spec.rb" with:
|
39
32
|
"""
|
40
|
-
require "rspec/expectations"
|
41
|
-
|
42
33
|
describe "color_enabled" do
|
43
34
|
context "when set with Rspec.configure" do
|
44
35
|
it "is true" do
|
@@ -49,16 +40,15 @@ Feature: spec/spec.opts
|
|
49
40
|
"""
|
50
41
|
When I run "rspec spec/example_spec.rb"
|
51
42
|
Then I should see "1 example, 0 failures"
|
52
|
-
|
53
|
-
|
54
|
-
Scenario: formatter set in both (
|
55
|
-
Given a file named "
|
43
|
+
|
44
|
+
@wip
|
45
|
+
Scenario: formatter set in both (.rspec wins)
|
46
|
+
Given a file named ".rspec" with:
|
56
47
|
"""
|
57
|
-
--
|
48
|
+
--format documentation
|
58
49
|
"""
|
59
50
|
And a file named "spec/spec_helper.rb" with:
|
60
51
|
"""
|
61
|
-
require "rspec/expectations"
|
62
52
|
Rspec.configure {|c| c.formatter = 'progress'}
|
63
53
|
"""
|
64
54
|
And a file named "spec/example_spec.rb" with:
|
data/features/support/env.rb
CHANGED
data/lib/rspec/core.rb
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
require 'rspec/core/load_path'
|
2
2
|
require 'rspec/core/deprecation'
|
3
|
-
|
3
|
+
|
4
|
+
require 'rspec/core/hooks'
|
5
|
+
require 'rspec/core/subject'
|
6
|
+
require 'rspec/core/let'
|
7
|
+
require 'rspec/core/metadata'
|
8
|
+
|
4
9
|
require 'rspec/core/around_proxy'
|
5
10
|
require 'rspec/core/world'
|
6
11
|
require 'rspec/core/configuration'
|
7
|
-
require 'rspec/core/
|
12
|
+
require 'rspec/core/configuration_options'
|
8
13
|
require 'rspec/core/runner'
|
9
14
|
require 'rspec/core/example'
|
10
15
|
require 'rspec/core/kernel_extensions'
|
11
16
|
require 'rspec/core/shared_example_group'
|
12
|
-
require 'rspec/core/example_group_subject'
|
13
17
|
require 'rspec/core/example_group'
|
14
18
|
require 'rspec/core/formatters'
|
15
19
|
require 'rspec/core/backward_compatibility'
|
@@ -29,7 +33,7 @@ module Rspec
|
|
29
33
|
|
30
34
|
def self.configure
|
31
35
|
Rspec.deprecate('Rspec::Core.configure', 'Rspec.configure', '2.0.0')
|
32
|
-
yield configuration if block_given?
|
36
|
+
yield Rspec.configuration if block_given?
|
33
37
|
end
|
34
38
|
|
35
39
|
def self.world
|
@@ -92,6 +92,10 @@ module Rspec
|
|
92
92
|
@options[:backtrace_clean_patterns].clear
|
93
93
|
end
|
94
94
|
|
95
|
+
def libs=(libs)
|
96
|
+
libs.map {|lib| $LOAD_PATH.unshift lib}
|
97
|
+
end
|
98
|
+
|
95
99
|
def debug=(bool)
|
96
100
|
return unless bool
|
97
101
|
begin
|
@@ -184,19 +188,14 @@ EOM
|
|
184
188
|
@run_all_when_everything_filtered
|
185
189
|
end
|
186
190
|
|
187
|
-
# Where does output go? For now $stdout
|
188
191
|
def output
|
189
192
|
$stdout
|
190
193
|
end
|
191
194
|
|
192
|
-
def puts(msg=
|
195
|
+
def puts(msg="")
|
193
196
|
output.puts(msg)
|
194
197
|
end
|
195
198
|
|
196
|
-
def parse_command_line_args(args)
|
197
|
-
@command_line_options = Rspec::Core::CommandLineOptions.parse(args)
|
198
|
-
end
|
199
|
-
|
200
199
|
def include(mod, options={})
|
201
200
|
@include_or_extend_modules << [:include, mod, options]
|
202
201
|
end
|
@@ -230,6 +229,10 @@ EOM
|
|
230
229
|
Rspec::Core::ExampleGroup.send(:include, Rspec::Core::MockFrameworkAdapter)
|
231
230
|
end
|
232
231
|
|
232
|
+
def require_files_to_run
|
233
|
+
files_to_run.map {|f| require f }
|
234
|
+
end
|
235
|
+
|
233
236
|
end
|
234
237
|
end
|
235
238
|
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
# http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html
|
3
|
+
|
4
|
+
module Rspec
|
5
|
+
module Core
|
6
|
+
|
7
|
+
class ConfigurationOptions
|
8
|
+
LOCAL_OPTIONS_FILE = ".rspec"
|
9
|
+
GLOBAL_OPTIONS_FILE = File.join(File.expand_path("~"), ".rspec")
|
10
|
+
|
11
|
+
attr_reader :args, :options
|
12
|
+
|
13
|
+
def initialize(args)
|
14
|
+
@args = args
|
15
|
+
@options = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def apply_to(config)
|
19
|
+
merged_options.each do |key, value|
|
20
|
+
config.send("#{key}=", value)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse_command_line_options
|
25
|
+
@options = Parser.parse!(@args)
|
26
|
+
@options[:files_or_directories_to_run] = @args
|
27
|
+
@options
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def merged_options
|
33
|
+
[global_options, local_options, command_line_options].inject({}) do |merged, options|
|
34
|
+
merged.merge(options)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def command_line_options
|
39
|
+
parse_command_line_options
|
40
|
+
end
|
41
|
+
|
42
|
+
class Parser
|
43
|
+
def self.parse!(args)
|
44
|
+
new.parse!(args)
|
45
|
+
end
|
46
|
+
|
47
|
+
class << self
|
48
|
+
alias_method :parse, :parse!
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse!(args)
|
52
|
+
options = {}
|
53
|
+
parser(options).parse!(args)
|
54
|
+
options
|
55
|
+
end
|
56
|
+
|
57
|
+
alias_method :parse, :parse!
|
58
|
+
|
59
|
+
def parser(options)
|
60
|
+
OptionParser.new do |parser|
|
61
|
+
parser.banner = "Usage: rspec [options] [files or directories]"
|
62
|
+
|
63
|
+
parser.on('-b', '--backtrace', 'Enable full backtrace') do |o|
|
64
|
+
options[:full_backtrace] = true
|
65
|
+
end
|
66
|
+
|
67
|
+
parser.on('-c', '--[no-]color', '--[no-]colour', 'Enable color in the output') do |o|
|
68
|
+
options[:color_enabled] = o
|
69
|
+
end
|
70
|
+
|
71
|
+
parser.on('-d', '--debug', 'Enable debugging') do |o|
|
72
|
+
options[:debug] = true
|
73
|
+
end
|
74
|
+
|
75
|
+
parser.on('-e', '--example PATTERN', "Run examples whose full descriptions match this pattern",
|
76
|
+
"(PATTERN is compiled into a Ruby regular expression)") do |o|
|
77
|
+
options[:full_description] = /#{o}/
|
78
|
+
end
|
79
|
+
|
80
|
+
parser.on('-f', '--formatter FORMATTER', 'Choose a formatter',
|
81
|
+
' [p]rogress (default - dots)',
|
82
|
+
' [d]ocumentation (group and example names)') do |o|
|
83
|
+
options[:formatter] = o
|
84
|
+
end
|
85
|
+
|
86
|
+
parser.on_tail('-h', '--help', "You're looking at it.") do
|
87
|
+
puts parser
|
88
|
+
exit
|
89
|
+
end
|
90
|
+
|
91
|
+
parser.on('-I DIRECTORY', 'specify $LOAD_PATH directory (may be used more than once)') do |dir|
|
92
|
+
options[:libs] ||= []
|
93
|
+
options[:libs] << dir
|
94
|
+
end
|
95
|
+
|
96
|
+
parser.on('-l', '--line_number LINE', 'Specify the line number of a single example to run') do |o|
|
97
|
+
options[:line_number] = o
|
98
|
+
end
|
99
|
+
|
100
|
+
parser.on('-o', '--options PATH', 'Read configuration options from a file path. (Defaults to spec/spec.parser)') do |o|
|
101
|
+
options[:options_file] = o || local_options_file
|
102
|
+
end
|
103
|
+
|
104
|
+
parser.on('-p', '--profile', 'Enable profiling of examples with output of the top 10 slowest examples') do |o|
|
105
|
+
options[:profile_examples] = o
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def global_options
|
112
|
+
parse_options_file(GLOBAL_OPTIONS_FILE)
|
113
|
+
end
|
114
|
+
|
115
|
+
def local_options
|
116
|
+
parse_options_file(local_options_file)
|
117
|
+
end
|
118
|
+
|
119
|
+
def parse_options_file(path)
|
120
|
+
Parser.parse(args_from_options_file(path))
|
121
|
+
end
|
122
|
+
|
123
|
+
def args_from_options_file(path)
|
124
|
+
return [] unless File.exist?(path)
|
125
|
+
File.readlines(path).map {|l| l.split}.flatten
|
126
|
+
end
|
127
|
+
|
128
|
+
def local_options_file
|
129
|
+
return @options.delete(:options_file) if @options[:options_file]
|
130
|
+
return LOCAL_OPTIONS_FILE if File.exist?(LOCAL_OPTIONS_FILE)
|
131
|
+
Rspec.deprecate("spec/spec.opts", ".rspec or ~/.rspec", "2.0.0") if File.exist?("spec/spec.opts")
|
132
|
+
"spec/spec.opts"
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -1,13 +1,8 @@
|
|
1
|
-
require 'rspec/core/hooks'
|
2
|
-
require 'rspec/core/example_group_subject'
|
3
|
-
require 'rspec/core/let'
|
4
|
-
require 'rspec/core/metadata'
|
5
|
-
|
6
1
|
module Rspec
|
7
2
|
module Core
|
8
3
|
class ExampleGroup
|
9
4
|
extend Hooks
|
10
|
-
include
|
5
|
+
include Subject
|
11
6
|
include Let
|
12
7
|
|
13
8
|
attr_accessor :running_example
|
@@ -31,10 +26,10 @@ module Rspec
|
|
31
26
|
def self.alias_example_to(new_alias, extra_options={})
|
32
27
|
new_alias = <<-END_RUBY
|
33
28
|
def self.#{new_alias}(desc=nil, options={}, &block)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
examples << Rspec::Core::Example.new(self, desc,
|
29
|
+
options.update(:pending => true) unless block
|
30
|
+
options.update(:caller => caller)
|
31
|
+
options.update(#{extra_options.inspect})
|
32
|
+
examples << Rspec::Core::Example.new(self, desc, options, block)
|
38
33
|
end
|
39
34
|
END_RUBY
|
40
35
|
module_eval(new_alias, __FILE__, __LINE__)
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module Rspec
|
2
|
-
|
3
2
|
module Core
|
4
|
-
|
5
3
|
module Formatters
|
6
4
|
|
7
5
|
class BaseFormatter
|
@@ -15,20 +13,8 @@ module Rspec
|
|
15
13
|
@example_group = nil
|
16
14
|
end
|
17
15
|
|
18
|
-
def configuration
|
19
|
-
Rspec.configuration
|
20
|
-
end
|
21
|
-
|
22
16
|
def output
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
def profile_examples?
|
27
|
-
Rspec.configuration.profile_examples
|
28
|
-
end
|
29
|
-
|
30
|
-
def color_enabled?
|
31
|
-
configuration.color_enabled?
|
17
|
+
configuration.output
|
32
18
|
end
|
33
19
|
|
34
20
|
def pending_examples
|
@@ -39,6 +25,21 @@ module Rspec
|
|
39
25
|
@failed_examples ||= ::Rspec::Core.world.find(examples, :positive, :execution_result => { :status => 'failed' })
|
40
26
|
end
|
41
27
|
|
28
|
+
def report(count)
|
29
|
+
sync_output do
|
30
|
+
start(count)
|
31
|
+
# TODO - spec that we still dump even when there's
|
32
|
+
# an exception
|
33
|
+
begin
|
34
|
+
yield self
|
35
|
+
ensure
|
36
|
+
stop
|
37
|
+
dump(@duration)
|
38
|
+
close
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
42
43
|
# This method is invoked before any examples are run, right after
|
43
44
|
# they have all been collected. This can be useful for special
|
44
45
|
# formatters that need to provide progress on feedback (graphical ones)
|
@@ -46,9 +47,14 @@ module Rspec
|
|
46
47
|
# This method will only be invoked once, and the next one to be invoked
|
47
48
|
# is #add_example_group
|
48
49
|
def start(example_count)
|
50
|
+
@start = Time.now
|
49
51
|
@example_count = example_count
|
50
52
|
end
|
51
53
|
|
54
|
+
def stop
|
55
|
+
@duration = Time.now - @start
|
56
|
+
end
|
57
|
+
|
52
58
|
def example_finished(example)
|
53
59
|
examples << example
|
54
60
|
end
|
@@ -60,8 +66,13 @@ module Rspec
|
|
60
66
|
def add_example_group(example_group)
|
61
67
|
@example_group = example_group
|
62
68
|
end
|
63
|
-
|
64
|
-
|
69
|
+
|
70
|
+
def dump(duration)
|
71
|
+
start_dump(duration)
|
72
|
+
dump_failures
|
73
|
+
dump_summary
|
74
|
+
dump_pending
|
75
|
+
end
|
65
76
|
|
66
77
|
# This method is invoked after all of the examples have executed. The next method
|
67
78
|
# to be invoked after this one is #dump_failure (once for each failed example),
|
@@ -95,7 +106,11 @@ module Rspec
|
|
95
106
|
cleansed.empty? ? backtrace : cleansed
|
96
107
|
end
|
97
108
|
|
98
|
-
|
109
|
+
protected
|
110
|
+
|
111
|
+
def configuration
|
112
|
+
Rspec.configuration
|
113
|
+
end
|
99
114
|
|
100
115
|
def backtrace_line(line)
|
101
116
|
return nil if configuration.cleaned_from_backtrace?(line)
|
@@ -119,9 +134,29 @@ module Rspec
|
|
119
134
|
end
|
120
135
|
end
|
121
136
|
|
137
|
+
def sync_output
|
138
|
+
begin
|
139
|
+
old_sync, output.sync = output.sync, true if output_supports_sync
|
140
|
+
yield
|
141
|
+
ensure
|
142
|
+
output.sync = old_sync if output_supports_sync
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def output_supports_sync
|
147
|
+
output.respond_to?(:sync=)
|
148
|
+
end
|
149
|
+
|
150
|
+
def profile_examples?
|
151
|
+
configuration.profile_examples
|
152
|
+
end
|
153
|
+
|
154
|
+
def color_enabled?
|
155
|
+
configuration.color_enabled?
|
156
|
+
end
|
157
|
+
|
122
158
|
end
|
123
159
|
|
124
160
|
end
|
125
161
|
end
|
126
|
-
|
127
162
|
end
|
data/lib/rspec/core/metadata.rb
CHANGED
@@ -77,6 +77,12 @@ EOM
|
|
77
77
|
update(options)
|
78
78
|
end
|
79
79
|
|
80
|
+
def all_apply?(filters)
|
81
|
+
filters.all? do |filter_on, filter|
|
82
|
+
apply_condition(filter_on, filter)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
80
86
|
def apply_condition(filter_on, filter, metadata=nil)
|
81
87
|
metadata ||= self
|
82
88
|
case filter
|
@@ -97,12 +103,6 @@ EOM
|
|
97
103
|
end
|
98
104
|
end
|
99
105
|
|
100
|
-
def all_apply?(filters)
|
101
|
-
filters.all? do |filter_on, filter|
|
102
|
-
apply_condition(filter_on, filter)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
106
|
private
|
107
107
|
|
108
108
|
def superclass_metadata
|
data/lib/rspec/core/runner.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Rspec
|
2
2
|
module Core
|
3
|
-
|
4
3
|
class Runner
|
5
4
|
|
6
5
|
def self.installed_at_exit?
|
@@ -21,47 +20,42 @@ module Rspec
|
|
21
20
|
configuration.formatter
|
22
21
|
end
|
23
22
|
|
24
|
-
def
|
25
|
-
|
23
|
+
def run(args = [])
|
24
|
+
configure(args)
|
25
|
+
|
26
|
+
reporter.report(example_count) do |reporter|
|
27
|
+
example_groups.run_all(reporter)
|
28
|
+
end
|
29
|
+
|
30
|
+
example_groups.success?
|
26
31
|
end
|
27
32
|
|
28
|
-
|
29
|
-
Rspec::Core::CommandLineOptions.parse(args).apply(configuration)
|
30
|
-
|
31
|
-
require_all_files(configuration)
|
33
|
+
private
|
32
34
|
|
35
|
+
def configure(args)
|
36
|
+
Rspec::Core::ConfigurationOptions.new(args).apply_to(configuration)
|
37
|
+
configuration.require_files_to_run
|
33
38
|
configuration.configure_mock_framework
|
34
|
-
|
35
|
-
total_examples_to_run = Rspec::Core.world.total_examples_to_run
|
36
|
-
|
37
|
-
old_sync, reporter.output.sync = reporter.output.sync, true if reporter.output.respond_to?(:sync=)
|
38
|
-
|
39
|
-
suite_success = true
|
39
|
+
end
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
def example_count
|
42
|
+
Rspec::Core.world.total_examples_to_run
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
def example_groups
|
46
|
+
Rspec::Core.world.example_groups_to_run.extend(ExampleGroups)
|
47
|
+
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
+
module ExampleGroups
|
50
|
+
def run_all(reporter)
|
51
|
+
@success = self.inject(true) {|success, group| success &= group.run(reporter)}
|
49
52
|
end
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
reporter.dump_summary
|
55
|
-
reporter.dump_pending
|
56
|
-
reporter.close
|
57
|
-
|
58
|
-
reporter.output.sync = old_sync if reporter_supports_sync
|
59
|
-
|
60
|
-
suite_success
|
54
|
+
def success?
|
55
|
+
@success ||= false
|
56
|
+
end
|
61
57
|
end
|
62
58
|
|
63
|
-
|
64
59
|
end
|
65
|
-
|
66
60
|
end
|
67
61
|
end
|
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.6"
|
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-04-
|
12
|
+
s.date = %q{2010-04-12}
|
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"]
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".gitignore",
|
22
|
+
".rspec",
|
22
23
|
".treasure_map.rb",
|
23
24
|
"License.txt",
|
24
25
|
"README.markdown",
|
@@ -80,7 +81,7 @@ Gem::Specification.new do |s|
|
|
80
81
|
"features/command_line/example_name_option.feature",
|
81
82
|
"features/command_line/line_number_appended_to_path.feature",
|
82
83
|
"features/command_line/line_number_option.feature",
|
83
|
-
"features/configuration/
|
84
|
+
"features/configuration/options_file.feature",
|
84
85
|
"features/example_groups/describe_aliases.feature",
|
85
86
|
"features/example_groups/nested_groups.feature",
|
86
87
|
"features/formatters/custom_formatter.feature",
|
@@ -101,12 +102,11 @@ Gem::Specification.new do |s|
|
|
101
102
|
"lib/rspec/core.rb",
|
102
103
|
"lib/rspec/core/around_proxy.rb",
|
103
104
|
"lib/rspec/core/backward_compatibility.rb",
|
104
|
-
"lib/rspec/core/command_line_options.rb",
|
105
105
|
"lib/rspec/core/configuration.rb",
|
106
|
+
"lib/rspec/core/configuration_options.rb",
|
106
107
|
"lib/rspec/core/deprecation.rb",
|
107
108
|
"lib/rspec/core/example.rb",
|
108
109
|
"lib/rspec/core/example_group.rb",
|
109
|
-
"lib/rspec/core/example_group_subject.rb",
|
110
110
|
"lib/rspec/core/formatters.rb",
|
111
111
|
"lib/rspec/core/formatters/base_formatter.rb",
|
112
112
|
"lib/rspec/core/formatters/base_text_formatter.rb",
|
@@ -127,17 +127,16 @@ Gem::Specification.new do |s|
|
|
127
127
|
"lib/rspec/core/ruby_project.rb",
|
128
128
|
"lib/rspec/core/runner.rb",
|
129
129
|
"lib/rspec/core/shared_example_group.rb",
|
130
|
-
"lib/rspec/core/
|
130
|
+
"lib/rspec/core/subject.rb",
|
131
131
|
"lib/rspec/core/version.rb",
|
132
132
|
"lib/rspec/core/world.rb",
|
133
133
|
"rspec-core.gemspec",
|
134
134
|
"script/console",
|
135
135
|
"spec/autotest/failed_results_re_spec.rb",
|
136
136
|
"spec/autotest/rspec_spec.rb",
|
137
|
-
"spec/rspec/core/
|
137
|
+
"spec/rspec/core/configuration_options_spec.rb",
|
138
138
|
"spec/rspec/core/configuration_spec.rb",
|
139
139
|
"spec/rspec/core/example_group_spec.rb",
|
140
|
-
"spec/rspec/core/example_group_subject_spec.rb",
|
141
140
|
"spec/rspec/core/example_spec.rb",
|
142
141
|
"spec/rspec/core/formatters/base_formatter_spec.rb",
|
143
142
|
"spec/rspec/core/formatters/base_text_formatter_spec.rb",
|
@@ -156,6 +155,7 @@ Gem::Specification.new do |s|
|
|
156
155
|
"spec/rspec/core/ruby_project_spec.rb",
|
157
156
|
"spec/rspec/core/runner_spec.rb",
|
158
157
|
"spec/rspec/core/shared_example_group_spec.rb",
|
158
|
+
"spec/rspec/core/subject_spec.rb",
|
159
159
|
"spec/rspec/core/world_spec.rb",
|
160
160
|
"spec/rspec/core_spec.rb",
|
161
161
|
"spec/ruby_forker.rb",
|
@@ -166,7 +166,7 @@ Gem::Specification.new do |s|
|
|
166
166
|
s.homepage = %q{http://github.com/rspec/core}
|
167
167
|
s.post_install_message = %q{**************************************************
|
168
168
|
|
169
|
-
Thank you for installing rspec-core-2.0.0.beta.
|
169
|
+
Thank you for installing rspec-core-2.0.0.beta.6
|
170
170
|
|
171
171
|
This is beta software. If you are looking
|
172
172
|
for a supported production release, please
|
@@ -178,14 +178,13 @@ Gem::Specification.new do |s|
|
|
178
178
|
s.require_paths = ["lib"]
|
179
179
|
s.rubyforge_project = %q{rspec}
|
180
180
|
s.rubygems_version = %q{1.3.6}
|
181
|
-
s.summary = %q{rspec-core-2.0.0.beta.
|
181
|
+
s.summary = %q{rspec-core-2.0.0.beta.6}
|
182
182
|
s.test_files = [
|
183
183
|
"spec/autotest/failed_results_re_spec.rb",
|
184
184
|
"spec/autotest/rspec_spec.rb",
|
185
|
-
"spec/rspec/core/
|
185
|
+
"spec/rspec/core/configuration_options_spec.rb",
|
186
186
|
"spec/rspec/core/configuration_spec.rb",
|
187
187
|
"spec/rspec/core/example_group_spec.rb",
|
188
|
-
"spec/rspec/core/example_group_subject_spec.rb",
|
189
188
|
"spec/rspec/core/example_spec.rb",
|
190
189
|
"spec/rspec/core/formatters/base_formatter_spec.rb",
|
191
190
|
"spec/rspec/core/formatters/base_text_formatter_spec.rb",
|
@@ -204,6 +203,7 @@ Gem::Specification.new do |s|
|
|
204
203
|
"spec/rspec/core/ruby_project_spec.rb",
|
205
204
|
"spec/rspec/core/runner_spec.rb",
|
206
205
|
"spec/rspec/core/shared_example_group_spec.rb",
|
206
|
+
"spec/rspec/core/subject_spec.rb",
|
207
207
|
"spec/rspec/core/world_spec.rb",
|
208
208
|
"spec/rspec/core_spec.rb",
|
209
209
|
"spec/ruby_forker.rb",
|
@@ -216,19 +216,19 @@ Gem::Specification.new do |s|
|
|
216
216
|
s.specification_version = 3
|
217
217
|
|
218
218
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
219
|
-
s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
220
|
-
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
219
|
+
s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.6"])
|
220
|
+
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.6"])
|
221
221
|
s.add_development_dependency(%q<cucumber>, [">= 0.5.3"])
|
222
222
|
s.add_development_dependency(%q<autotest>, [">= 4.2.9"])
|
223
223
|
else
|
224
|
-
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
225
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
224
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.6"])
|
225
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.6"])
|
226
226
|
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
227
227
|
s.add_dependency(%q<autotest>, [">= 4.2.9"])
|
228
228
|
end
|
229
229
|
else
|
230
|
-
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.
|
231
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.
|
230
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.6"])
|
231
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.6"])
|
232
232
|
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
233
233
|
s.add_dependency(%q<autotest>, [">= 4.2.9"])
|
234
234
|
end
|
@@ -1,29 +1,34 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
|
-
describe Rspec::Core::
|
4
|
+
describe Rspec::Core::ConfigurationOptions do
|
5
5
|
|
6
6
|
def options_from_args(*args)
|
7
|
-
Rspec::Core::
|
7
|
+
Rspec::Core::ConfigurationOptions.new(args).parse_command_line_options
|
8
8
|
end
|
9
9
|
|
10
10
|
describe 'color_enabled' do
|
11
|
-
example "-c, --colour, or --color
|
11
|
+
example "-c, --colour, or --color are parsed as true" do
|
12
12
|
options_from_args('-c').should include(:color_enabled => true)
|
13
13
|
options_from_args('--color').should include(:color_enabled => true)
|
14
14
|
options_from_args('--colour').should include(:color_enabled => true)
|
15
15
|
end
|
16
16
|
|
17
|
-
example "--no-color
|
17
|
+
example "--no-color is parsed as false" do
|
18
18
|
options_from_args('--no-color').should include(:color_enabled => false)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
describe
|
23
|
-
example
|
24
|
-
options_from_args('
|
22
|
+
describe 'load path additions' do
|
23
|
+
example "-I parses like it does w/ ruby command" do
|
24
|
+
options_from_args('-I', 'a_dir').should include(:libs => ['a_dir'])
|
25
|
+
end
|
26
|
+
example "-I can be used more than once" do
|
27
|
+
options_from_args('-I', 'dir_1', '-I', 'dir_2').should include(:libs => ['dir_1','dir_2'])
|
25
28
|
end
|
29
|
+
end
|
26
30
|
|
31
|
+
describe 'formatter' do
|
27
32
|
example '-f or --formatter with an argument should parse' do
|
28
33
|
options_from_args('--formatter', 'd').should include(:formatter => 'd')
|
29
34
|
options_from_args('-f', 'd').should include(:formatter => 'd')
|
@@ -52,50 +57,10 @@ describe Rspec::Core::CommandLineOptions do
|
|
52
57
|
end
|
53
58
|
end
|
54
59
|
|
55
|
-
describe "options" do
|
60
|
+
describe "options file" do
|
56
61
|
it "is parsed from --options or -o" do
|
57
|
-
options_from_args(
|
58
|
-
options_from_args(
|
59
|
-
end
|
60
|
-
|
61
|
-
it "defaults to spec/spec.opts when you don't give it a file path" do
|
62
|
-
options_from_args('-o').should include(:options_file => "spec/spec.opts")
|
63
|
-
options_from_args('--options').should include(:options_file => "spec/spec.opts")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "loads automatically" do
|
67
|
-
cli_options = Rspec::Core::CommandLineOptions.new([]).parse
|
68
|
-
File.stub(:exist?) { true }
|
69
|
-
File.stub(:readlines) { ["--formatter", "doc"] }
|
70
|
-
config = OpenStruct.new
|
71
|
-
cli_options.apply(config)
|
72
|
-
config.formatter.should == 'doc'
|
73
|
-
end
|
74
|
-
|
75
|
-
it "allows options on one line" do
|
76
|
-
cli_options = Rspec::Core::CommandLineOptions.new([]).parse
|
77
|
-
File.stub(:exist?) { true }
|
78
|
-
File.stub(:readlines) { ["--formatter doc"] }
|
79
|
-
config = OpenStruct.new
|
80
|
-
cli_options.apply(config)
|
81
|
-
config.formatter.should == 'doc'
|
82
|
-
end
|
83
|
-
|
84
|
-
it "merges options from the CLI and file options gracefully" do
|
85
|
-
cli_options = Rspec::Core::CommandLineOptions.new(['--formatter', 'progress', '--options', 'spec/spec.opts']).parse
|
86
|
-
cli_options.stub!(:parse_spec_file_contents).and_return(:full_backtrace => true)
|
87
|
-
config = OpenStruct.new
|
88
|
-
cli_options.apply(config)
|
89
|
-
config.full_backtrace.should == true
|
90
|
-
config.formatter.should == 'progress'
|
91
|
-
end
|
92
|
-
|
93
|
-
it "CLI options trump file options" do
|
94
|
-
cli_options = Rspec::Core::CommandLineOptions.new(['--formatter', 'progress', '--options', 'spec/spec.opts']).parse
|
95
|
-
cli_options.stub!(:parse_spec_file_contents).and_return(:formatter => 'documentation')
|
96
|
-
config = OpenStruct.new
|
97
|
-
cli_options.apply(config)
|
98
|
-
config.formatter.should == 'progress'
|
62
|
+
options_from_args("--options", "custom/path").should include(:options_file => "custom/path")
|
63
|
+
options_from_args("-o", "custom/path").should include(:options_file => "custom/path")
|
99
64
|
end
|
100
65
|
end
|
101
66
|
|
@@ -128,5 +93,76 @@ describe Rspec::Core::CommandLineOptions do
|
|
128
93
|
end
|
129
94
|
end
|
130
95
|
|
96
|
+
describe "options file (override)" do
|
97
|
+
let(:config) { OpenStruct.new }
|
98
|
+
|
99
|
+
it "loads automatically" do
|
100
|
+
File.stub(:exist?) { true }
|
101
|
+
File.stub(:readlines) { ["--formatter", "doc"] }
|
102
|
+
|
103
|
+
cli_options = Rspec::Core::ConfigurationOptions.new([])
|
104
|
+
cli_options.apply_to(config)
|
105
|
+
config.formatter.should == 'doc'
|
106
|
+
end
|
107
|
+
|
108
|
+
it "allows options on one line" do
|
109
|
+
File.stub(:exist?) { true }
|
110
|
+
File.stub(:readlines) { ["--formatter doc"] }
|
111
|
+
|
112
|
+
cli_options = Rspec::Core::ConfigurationOptions.new([])
|
113
|
+
cli_options.apply_to(config)
|
114
|
+
config.formatter.should == 'doc'
|
115
|
+
end
|
116
|
+
|
117
|
+
it "merges options from the global and local .rspec and the command line" do
|
118
|
+
File.stub(:exist?){ true }
|
119
|
+
File.stub(:readlines) do |path|
|
120
|
+
case path
|
121
|
+
when ".rspec"
|
122
|
+
["--formatter", "documentation"]
|
123
|
+
when /\.rspec/
|
124
|
+
["--line", "37"]
|
125
|
+
else
|
126
|
+
raise "Unexpected path: #{path}"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
cli_options = Rspec::Core::ConfigurationOptions.new(["--no-color"])
|
130
|
+
|
131
|
+
cli_options.apply_to(config)
|
132
|
+
|
133
|
+
config.formatter.should == "documentation"
|
134
|
+
config.line_number.should == "37"
|
135
|
+
config.color_enabled.should be_false
|
136
|
+
end
|
137
|
+
|
138
|
+
it "prefers local options over global" do
|
139
|
+
File.stub(:exist?){ true }
|
140
|
+
File.stub(:readlines) do |path|
|
141
|
+
case path
|
142
|
+
when ".rspec"
|
143
|
+
["--formatter", "local"]
|
144
|
+
when /\.rspec/
|
145
|
+
["--formatter", "global"]
|
146
|
+
else
|
147
|
+
raise "Unexpected path: #{path}"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
cli_options = Rspec::Core::ConfigurationOptions.new([])
|
151
|
+
|
152
|
+
cli_options.apply_to(config)
|
153
|
+
|
154
|
+
config.formatter.should == "local"
|
155
|
+
end
|
156
|
+
|
157
|
+
it "prefers CLI options over file options" do
|
158
|
+
config_options = Rspec::Core::ConfigurationOptions.new(['--formatter', 'progress'])
|
159
|
+
config_options.stub(:parse_options_file).and_return(:formatter => 'documentation')
|
160
|
+
|
161
|
+
config_options.apply_to(config)
|
162
|
+
|
163
|
+
config.formatter.should == 'progress'
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
131
167
|
end
|
132
168
|
|
@@ -4,7 +4,7 @@ module Rspec::Core
|
|
4
4
|
|
5
5
|
describe Configuration do
|
6
6
|
|
7
|
-
let(:config) {
|
7
|
+
let(:config) { subject }
|
8
8
|
|
9
9
|
describe "#mock_framework_class" do
|
10
10
|
before(:each) do
|
@@ -237,11 +237,11 @@ module Rspec::Core
|
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
240
|
-
|
241
240
|
context "transactional examples" do
|
242
241
|
it "defaults to use transactional examples" do
|
243
|
-
|
242
|
+
config.use_transactional_examples?.should be_true
|
244
243
|
end
|
244
|
+
|
245
245
|
describe "#use_transactional_examples=" do
|
246
246
|
it "remembers that I don't want transactional exmaples" do
|
247
247
|
config.use_transactional_examples = false
|
@@ -250,6 +250,13 @@ module Rspec::Core
|
|
250
250
|
end
|
251
251
|
end
|
252
252
|
|
253
|
+
describe "libs=" do
|
254
|
+
it "adds directories to the LOAD_PATH" do
|
255
|
+
$LOAD_PATH.should_receive(:unshift).with("a/dir")
|
256
|
+
config.libs = ["a/dir"]
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
253
260
|
end
|
254
261
|
|
255
262
|
end
|
data/spec/ruby_forker.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rbconfig'
|
|
2
2
|
|
3
3
|
module RubyForker
|
4
4
|
# Forks a ruby interpreter with same type as ourself.
|
5
|
-
#
|
5
|
+
# jruby will fork jruby, ruby will fork ruby etc.
|
6
6
|
def ruby(args, stderr=nil)
|
7
7
|
config = ::Config::CONFIG
|
8
8
|
interpreter = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
|
@@ -10,4 +10,4 @@ module RubyForker
|
|
10
10
|
cmd << " 2> #{stderr}" unless stderr.nil?
|
11
11
|
`#{cmd}`
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
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
|
+
- 6
|
11
|
+
version: 2.0.0.beta.6
|
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-04-
|
20
|
+
date: 2010-04-12 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
|
+
- 6
|
36
|
+
version: 2.0.0.beta.6
|
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
|
+
- 6
|
52
|
+
version: 2.0.0.beta.6
|
53
53
|
type: :development
|
54
54
|
version_requirements: *id002
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -92,6 +92,7 @@ extra_rdoc_files:
|
|
92
92
|
files:
|
93
93
|
- .document
|
94
94
|
- .gitignore
|
95
|
+
- .rspec
|
95
96
|
- .treasure_map.rb
|
96
97
|
- License.txt
|
97
98
|
- README.markdown
|
@@ -153,7 +154,7 @@ files:
|
|
153
154
|
- features/command_line/example_name_option.feature
|
154
155
|
- features/command_line/line_number_appended_to_path.feature
|
155
156
|
- features/command_line/line_number_option.feature
|
156
|
-
- features/configuration/
|
157
|
+
- features/configuration/options_file.feature
|
157
158
|
- features/example_groups/describe_aliases.feature
|
158
159
|
- features/example_groups/nested_groups.feature
|
159
160
|
- features/formatters/custom_formatter.feature
|
@@ -174,12 +175,11 @@ files:
|
|
174
175
|
- lib/rspec/core.rb
|
175
176
|
- lib/rspec/core/around_proxy.rb
|
176
177
|
- lib/rspec/core/backward_compatibility.rb
|
177
|
-
- lib/rspec/core/command_line_options.rb
|
178
178
|
- lib/rspec/core/configuration.rb
|
179
|
+
- lib/rspec/core/configuration_options.rb
|
179
180
|
- lib/rspec/core/deprecation.rb
|
180
181
|
- lib/rspec/core/example.rb
|
181
182
|
- lib/rspec/core/example_group.rb
|
182
|
-
- lib/rspec/core/example_group_subject.rb
|
183
183
|
- lib/rspec/core/formatters.rb
|
184
184
|
- lib/rspec/core/formatters/base_formatter.rb
|
185
185
|
- lib/rspec/core/formatters/base_text_formatter.rb
|
@@ -200,17 +200,16 @@ files:
|
|
200
200
|
- lib/rspec/core/ruby_project.rb
|
201
201
|
- lib/rspec/core/runner.rb
|
202
202
|
- lib/rspec/core/shared_example_group.rb
|
203
|
-
- lib/rspec/core/
|
203
|
+
- lib/rspec/core/subject.rb
|
204
204
|
- lib/rspec/core/version.rb
|
205
205
|
- lib/rspec/core/world.rb
|
206
206
|
- rspec-core.gemspec
|
207
207
|
- script/console
|
208
208
|
- spec/autotest/failed_results_re_spec.rb
|
209
209
|
- spec/autotest/rspec_spec.rb
|
210
|
-
- spec/rspec/core/
|
210
|
+
- spec/rspec/core/configuration_options_spec.rb
|
211
211
|
- spec/rspec/core/configuration_spec.rb
|
212
212
|
- spec/rspec/core/example_group_spec.rb
|
213
|
-
- spec/rspec/core/example_group_subject_spec.rb
|
214
213
|
- spec/rspec/core/example_spec.rb
|
215
214
|
- spec/rspec/core/formatters/base_formatter_spec.rb
|
216
215
|
- spec/rspec/core/formatters/base_text_formatter_spec.rb
|
@@ -229,6 +228,7 @@ files:
|
|
229
228
|
- spec/rspec/core/ruby_project_spec.rb
|
230
229
|
- spec/rspec/core/runner_spec.rb
|
231
230
|
- spec/rspec/core/shared_example_group_spec.rb
|
231
|
+
- spec/rspec/core/subject_spec.rb
|
232
232
|
- spec/rspec/core/world_spec.rb
|
233
233
|
- spec/rspec/core_spec.rb
|
234
234
|
- spec/ruby_forker.rb
|
@@ -242,7 +242,7 @@ licenses: []
|
|
242
242
|
post_install_message: |
|
243
243
|
**************************************************
|
244
244
|
|
245
|
-
Thank you for installing rspec-core-2.0.0.beta.
|
245
|
+
Thank you for installing rspec-core-2.0.0.beta.6
|
246
246
|
|
247
247
|
This is beta software. If you are looking
|
248
248
|
for a supported production release, please
|
@@ -276,14 +276,13 @@ rubyforge_project: rspec
|
|
276
276
|
rubygems_version: 1.3.6
|
277
277
|
signing_key:
|
278
278
|
specification_version: 3
|
279
|
-
summary: rspec-core-2.0.0.beta.
|
279
|
+
summary: rspec-core-2.0.0.beta.6
|
280
280
|
test_files:
|
281
281
|
- spec/autotest/failed_results_re_spec.rb
|
282
282
|
- spec/autotest/rspec_spec.rb
|
283
|
-
- spec/rspec/core/
|
283
|
+
- spec/rspec/core/configuration_options_spec.rb
|
284
284
|
- spec/rspec/core/configuration_spec.rb
|
285
285
|
- spec/rspec/core/example_group_spec.rb
|
286
|
-
- spec/rspec/core/example_group_subject_spec.rb
|
287
286
|
- spec/rspec/core/example_spec.rb
|
288
287
|
- spec/rspec/core/formatters/base_formatter_spec.rb
|
289
288
|
- spec/rspec/core/formatters/base_text_formatter_spec.rb
|
@@ -302,6 +301,7 @@ test_files:
|
|
302
301
|
- spec/rspec/core/ruby_project_spec.rb
|
303
302
|
- spec/rspec/core/runner_spec.rb
|
304
303
|
- spec/rspec/core/shared_example_group_spec.rb
|
304
|
+
- spec/rspec/core/subject_spec.rb
|
305
305
|
- spec/rspec/core/world_spec.rb
|
306
306
|
- spec/rspec/core_spec.rb
|
307
307
|
- spec/ruby_forker.rb
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
# http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html
|
3
|
-
|
4
|
-
module Rspec
|
5
|
-
module Core
|
6
|
-
|
7
|
-
class CommandLineOptions
|
8
|
-
DEFAULT_OPTIONS_FILE = 'spec/spec.opts'
|
9
|
-
|
10
|
-
attr_reader :args, :options
|
11
|
-
|
12
|
-
def self.parse(args)
|
13
|
-
new(args).parse
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(args)
|
17
|
-
@args = args
|
18
|
-
@options = {}
|
19
|
-
end
|
20
|
-
|
21
|
-
def parse
|
22
|
-
options[:files_or_directories_to_run] = OptionParser.new do |opts|
|
23
|
-
opts.banner = "Usage: rspec [options] [files or directories]"
|
24
|
-
|
25
|
-
opts.on('-c', '--[no-]color', '--[no-]colour', 'Enable color in the output') do |o|
|
26
|
-
options[:color_enabled] = o
|
27
|
-
end
|
28
|
-
|
29
|
-
opts.on('-f', '--formatter [FORMATTER]', 'Choose a formatter',
|
30
|
-
' [p]rogress (default - dots)',
|
31
|
-
' [d]ocumentation (group and example names)') do |o|
|
32
|
-
options[:formatter] = o
|
33
|
-
end
|
34
|
-
|
35
|
-
opts.on('-l', '--line_number [LINE]', 'Specify the line number of a single example to run') do |o|
|
36
|
-
options[:line_number] = o
|
37
|
-
end
|
38
|
-
|
39
|
-
opts.on('-e', '--example [PATTERN]', "Run examples whose full descriptions match this pattern",
|
40
|
-
"(PATTERN is compiled into a Ruby regular expression)") do |o|
|
41
|
-
options[:full_description] = /#{o}/
|
42
|
-
end
|
43
|
-
|
44
|
-
opts.on('-o', '--options [PATH]', 'Read configuration options from a file path. (Defaults to spec/spec.opts)') do |o|
|
45
|
-
options[:options_file] = o || DEFAULT_OPTIONS_FILE
|
46
|
-
end
|
47
|
-
|
48
|
-
opts.on('-p', '--profile', 'Enable profiling of examples with output of the top 10 slowest examples') do |o|
|
49
|
-
options[:profile_examples] = o
|
50
|
-
end
|
51
|
-
|
52
|
-
opts.on('-b', '--backtrace', 'Enable full backtrace') do |o|
|
53
|
-
options[:full_backtrace] = true
|
54
|
-
end
|
55
|
-
|
56
|
-
opts.on('-d', '--debug', 'Enable debugging') do |o|
|
57
|
-
options[:debug] = true
|
58
|
-
end
|
59
|
-
|
60
|
-
opts.on_tail('-h', '--help', "You're looking at it.") do
|
61
|
-
puts opts
|
62
|
-
exit
|
63
|
-
end
|
64
|
-
end.parse!(@args)
|
65
|
-
|
66
|
-
self
|
67
|
-
end
|
68
|
-
|
69
|
-
def apply(config)
|
70
|
-
# 1) option file, cli options, rspec core configure
|
71
|
-
# TODO: Add options_file to configuration
|
72
|
-
# TODO: Store command line options for reference
|
73
|
-
options_file = options.delete(:options_file) || DEFAULT_OPTIONS_FILE
|
74
|
-
merged_options = parse_spec_file_contents(options_file).merge!(options)
|
75
|
-
options.replace merged_options
|
76
|
-
|
77
|
-
options.each do |key, value|
|
78
|
-
config.send("#{key}=", value)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
private
|
83
|
-
|
84
|
-
def parse_spec_file_contents(options_file)
|
85
|
-
return {} unless File.exist?(options_file)
|
86
|
-
spec_file_contents = File.readlines(options_file).map {|l| l.split}.flatten
|
87
|
-
self.class.new(spec_file_contents).parse.options
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Rspec
|
2
|
-
module Core
|
3
|
-
module SharedExampleGroupKernelExtensions
|
4
|
-
|
5
|
-
def share_examples_for(name, &block)
|
6
|
-
Rspec::Core.world.shared_example_groups[name] = block
|
7
|
-
end
|
8
|
-
|
9
|
-
def share_as(name, &block)
|
10
|
-
if Object.const_defined?(name)
|
11
|
-
puts "name was defined as #{name.inspect}"
|
12
|
-
raise NameError, "The first argument (#{name}) to share_as must be a legal name for a constant not already in use."
|
13
|
-
end
|
14
|
-
|
15
|
-
mod = Module.new do
|
16
|
-
@shared_block = block
|
17
|
-
|
18
|
-
def self.included(kls)
|
19
|
-
kls.module_eval(&@shared_block)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
shared_const = Object.const_set(name, mod)
|
24
|
-
Rspec::Core.world.shared_example_groups[shared_const] = block
|
25
|
-
end
|
26
|
-
|
27
|
-
alias :shared_examples_for :share_examples_for
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|