rspec-core 2.7.0.rc1 → 2.7.0
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/README.md +6 -44
- data/features/Upgrade.md +38 -5
- data/features/command_line/exit_status.feature +15 -1
- data/features/example_groups/shared_context.feature +1 -1
- data/lib/autotest/rspec2.rb +8 -2
- data/lib/rspec/core.rb +0 -6
- data/lib/rspec/core/backward_compatibility.rb +5 -0
- data/lib/rspec/core/command_line.rb +1 -1
- data/lib/rspec/core/configuration.rb +2 -1
- data/lib/rspec/core/deprecation.rb +3 -0
- data/lib/rspec/core/errors.rb +4 -5
- data/lib/rspec/core/example.rb +1 -1
- data/lib/rspec/core/extensions/kernel.rb +7 -3
- data/lib/rspec/core/formatters/snippet_extractor.rb +2 -2
- data/lib/rspec/core/let.rb +2 -2
- data/lib/rspec/core/option_parser.rb +4 -0
- data/lib/rspec/core/rake_task.rb +2 -8
- data/lib/rspec/core/ruby_project.rb +5 -5
- data/lib/rspec/core/runner.rb +6 -6
- data/lib/rspec/core/subject.rb +1 -1
- data/lib/rspec/core/version.rb +4 -4
- data/spec/rspec/core/command_line_spec.rb +7 -1
- data/spec/rspec/core/configuration_options_spec.rb +12 -0
- data/spec/rspec/core/rake_task_spec.rb +2 -46
- metadata +10 -14
data/README.md
CHANGED
@@ -1,23 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# rspec-core
|
2
2
|
|
3
3
|
RSpec Core provides the structure for writing executable examples of how your
|
4
4
|
code should behave.
|
5
5
|
|
6
|
-
[](http://travis-ci.org/rspec/rspec-core)
|
7
|
-
|
8
|
-
## Documentation
|
9
|
-
|
10
|
-
The [Cucumber features](http://relishapp.com/rspec/rspec-core) are the
|
11
|
-
most comprehensive and up-to-date docs for end-users.
|
12
|
-
|
13
|
-
The [RDoc](http://rubydoc.info/gems/rspec-core/2.3.0/frames) provides
|
14
|
-
additional information for contributors and/or extenders.
|
15
|
-
|
16
|
-
All of the documentation is open source and a work in progress. If you find it
|
17
|
-
lacking or confusing, you can help improve it by submitting requests and
|
18
|
-
patches to the [rspec-core issue
|
19
|
-
tracker](https://github.com/rspec/rspec-core/issues).
|
20
|
-
|
21
6
|
## Install
|
22
7
|
|
23
8
|
gem install rspec # for rspec-core, rspec-expectations, rspec-mocks
|
@@ -27,18 +12,14 @@ tracker](https://github.com/rspec/rspec-core/issues).
|
|
27
12
|
|
28
13
|
See [features/Upgrade.md](http://github.com/rspec/rspec-core/blob/master/features/Upgrade.md)
|
29
14
|
|
30
|
-
|
31
|
-
This will install the rspec, rspec-core, rspec-expectations and rspec-mocks
|
32
|
-
gems.
|
33
|
-
|
34
15
|
## Get Started
|
35
16
|
|
36
17
|
Start with a simple example of behavior you expect from your system. Do
|
37
18
|
this before you write any implementation code:
|
38
19
|
|
39
20
|
# in spec/calculator_spec.rb
|
40
|
-
describe Calculator
|
41
|
-
it "returns the sum of its arguments" do
|
21
|
+
describe Calculator do
|
22
|
+
it "add(x,y) returns the sum of its arguments" do
|
42
23
|
Calculator.new.add(1, 2).should eq(3)
|
43
24
|
end
|
44
25
|
end
|
@@ -60,8 +41,7 @@ Implement the simplest solution:
|
|
60
41
|
Be sure to require the implementation file in the spec:
|
61
42
|
|
62
43
|
# in spec/calculator_spec.rb
|
63
|
-
# - RSpec adds ./lib to the $LOAD_PATH
|
64
|
-
# just require "calculator" directly
|
44
|
+
# - RSpec adds ./lib to the $LOAD_PATH
|
65
45
|
require "calculator"
|
66
46
|
|
67
47
|
Now run the spec again, and watch it pass:
|
@@ -72,7 +52,7 @@ Now run the spec again, and watch it pass:
|
|
72
52
|
Finished in 0.000315 seconds
|
73
53
|
1 example, 0 failures
|
74
54
|
|
75
|
-
Use the documentation formatter to see the resulting spec:
|
55
|
+
Use the `documentation` formatter to see the resulting spec:
|
76
56
|
|
77
57
|
$ rspec spec/calculator_spec.rb --format doc
|
78
58
|
Calculator add
|
@@ -81,26 +61,8 @@ Use the documentation formatter to see the resulting spec:
|
|
81
61
|
Finished in 0.000379 seconds
|
82
62
|
1 example, 0 failures
|
83
63
|
|
84
|
-
##
|
85
|
-
|
86
|
-
See [http://github.com/rspec/rspec-core/issues](http://github.com/rspec/rspec-core/issues)
|
87
|
-
|
88
|
-
## Learn more
|
89
|
-
|
90
|
-
While not comprehensive yet, you can learn quite a lot from the Cucumber
|
91
|
-
features in the [features
|
92
|
-
directory](http://github.com/rspec/rspec-core/tree/master/features/). If there
|
93
|
-
is a feature that is not documented there, or you find them insufficient to
|
94
|
-
understand how to use a feature, please submit issues to
|
95
|
-
[http://github.com/rspec/rspec-core/issues](http://github.com/rspec/rspec-core/issues).
|
96
|
-
|
97
|
-
## Contribute
|
98
|
-
|
99
|
-
See [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev)
|
100
|
-
|
101
|
-
## Also see
|
64
|
+
## See also
|
102
65
|
|
103
66
|
* [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
|
104
67
|
* [http://github.com/rspec/rspec-expectations](http://github.com/rspec/rspec-expectations)
|
105
68
|
* [http://github.com/rspec/rspec-mocks](http://github.com/rspec/rspec-mocks)
|
106
|
-
|
data/features/Upgrade.md
CHANGED
@@ -1,13 +1,46 @@
|
|
1
|
-
|
1
|
+
The [Changelog](changelog) has a complete list of everything that changed, but
|
2
|
+
here are more detailed explanations for those items that warrant them.
|
2
3
|
|
3
|
-
|
4
|
+
# rspec-core-2.7.0.rc1
|
4
5
|
|
5
|
-
|
6
|
+
## what's new
|
7
|
+
|
8
|
+
### `rspec` command with no arguments
|
9
|
+
|
10
|
+
Now you can just type
|
11
|
+
|
12
|
+
rspec
|
13
|
+
|
14
|
+
to run all the specs in the `spec` directory. If you keep your specs in a
|
15
|
+
different directory, you can override the default with the `--default_path`
|
16
|
+
argument in a config file:
|
6
17
|
|
7
18
|
# in .rspec
|
8
|
-
--default_path
|
19
|
+
--default_path specs
|
20
|
+
|
21
|
+
### `rspec` command supports multiple line numbers
|
22
|
+
|
23
|
+
Use either of the following to run the examples declared on lines
|
24
|
+
37 and 42 of `a_spec.rb`:
|
25
|
+
|
26
|
+
rspec path/to/a_spec.rb --line_number 37 --line_number 42
|
27
|
+
rspec path/to/a_spec.rb:37:42
|
28
|
+
|
29
|
+
## what's changed
|
30
|
+
|
31
|
+
### `skip_bundler` and `gemfile` rake task options are deprecated and have no effect.
|
32
|
+
|
33
|
+
RSpec's rake task invokes the `rspec` command in a subshell. If you invoke
|
34
|
+
`bundle exec rake` or include `Bundler.setup` in your `Rakefile`, then
|
35
|
+
Bundler will be activated in the subshell as well.
|
36
|
+
|
37
|
+
Previously, the rake task managed this for you based on the presence of a
|
38
|
+
`Gemfile`. In 2.7.0.rc1, this is done based on the presence of the
|
39
|
+
`BUNDLE_GEMFILE` environment variable, which is set in the parent shell by Bundler.
|
9
40
|
|
10
|
-
|
41
|
+
In 2.7.0.rc2 (not yet released), the rake task doesn't do anything at all.
|
42
|
+
Turns out Bundler just does the right thing, so rspec doesn't need to do
|
43
|
+
anything.
|
11
44
|
|
12
45
|
# rspec-core-2.6
|
13
46
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
Feature: exit status
|
2
2
|
|
3
3
|
The rspec command exits with an exit status of 0 if all examples pass,
|
4
|
-
and 1 if any examples fail.
|
4
|
+
and 1 if any examples fail. The failure exit code can be overridden
|
5
|
+
using the --failure-exit-code option.
|
5
6
|
|
6
7
|
Scenario: exit with 0 when all examples pass
|
7
8
|
Given a file named "ok_spec.rb" with:
|
@@ -51,6 +52,19 @@ Feature: exit status
|
|
51
52
|
Then the exit status should be 0
|
52
53
|
And the output should contain "0 examples"
|
53
54
|
|
55
|
+
Scenario: exit with 2 when one example fails and --failure-exit-code is 2
|
56
|
+
Given a file named "ko_spec.rb" with:
|
57
|
+
"""
|
58
|
+
describe "KO" do
|
59
|
+
it "fails" do
|
60
|
+
raise "KO"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
"""
|
64
|
+
When I run `rspec --failure-exit-code 2 ko_spec.rb`
|
65
|
+
Then the exit status should be 2
|
66
|
+
And the output should contain "1 example, 1 failure"
|
67
|
+
|
54
68
|
@wip
|
55
69
|
Scenario: exit with rspec's exit code when an at_exit hook is added upstream
|
56
70
|
Given a file named "exit_at_spec.rb" with:
|
@@ -2,7 +2,7 @@ Feature: shared context
|
|
2
2
|
|
3
3
|
Use `shared_context` to define a block that will be evaluated in the context
|
4
4
|
of example groups either explicitly, using `include_context`, or implicitly by
|
5
|
-
matching
|
5
|
+
matching metadata.
|
6
6
|
|
7
7
|
Background:
|
8
8
|
Given a file named "shared_stuff.rb" with:
|
data/lib/autotest/rspec2.rb
CHANGED
@@ -18,6 +18,7 @@ class Autotest::Rspec2 < Autotest
|
|
18
18
|
self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
|
19
19
|
end
|
20
20
|
|
21
|
+
# Adds conventional spec-to-file mappings to Autotest configuation.
|
21
22
|
def setup_rspec_project_mappings
|
22
23
|
add_mapping(%r%^spec/.*_spec\.rb$%) { |filename, _|
|
23
24
|
filename
|
@@ -30,6 +31,7 @@ class Autotest::Rspec2 < Autotest
|
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
34
|
+
# Overrides Autotest's implementation to read rspec output
|
33
35
|
def consolidate_failures(failed)
|
34
36
|
filters = new_hash_of_arrays
|
35
37
|
failed.each do |spec, trace|
|
@@ -40,26 +42,30 @@ class Autotest::Rspec2 < Autotest
|
|
40
42
|
return filters
|
41
43
|
end
|
42
44
|
|
45
|
+
# Overrides Autotest's implementation to generate the rspec command to run
|
43
46
|
def make_test_cmd(files_to_test)
|
44
47
|
files_to_test.empty? ? '' :
|
45
48
|
"#{prefix}#{ruby}#{suffix} -S #{SPEC_PROGRAM} --tty #{normalize(files_to_test).keys.flatten.map { |f| "'#{f}'"}.join(' ')}"
|
46
49
|
end
|
47
50
|
|
51
|
+
# Generates a map of filenames to Arrays for Autotest
|
48
52
|
def normalize(files_to_test)
|
49
53
|
files_to_test.keys.inject({}) do |result, filename|
|
50
|
-
result
|
51
|
-
result
|
54
|
+
result.merge!(File.expand_path(filename) => [])
|
52
55
|
end
|
53
56
|
end
|
54
57
|
|
58
|
+
# @private
|
55
59
|
def suffix
|
56
60
|
using_bundler? ? "" : defined?(:Gem) ? " -rrubygems" : ""
|
57
61
|
end
|
58
62
|
|
63
|
+
# @private
|
59
64
|
def using_bundler?
|
60
65
|
prefix =~ /bundle exec/
|
61
66
|
end
|
62
67
|
|
68
|
+
# @private
|
63
69
|
def gemfile?
|
64
70
|
File.exist?('./Gemfile')
|
65
71
|
end
|
data/lib/rspec/core.rb
CHANGED
@@ -33,12 +33,6 @@ module RSpec
|
|
33
33
|
|
34
34
|
SharedContext = Core::SharedContext
|
35
35
|
|
36
|
-
module Core
|
37
|
-
def self.install_directory
|
38
|
-
@install_directory ||= File.expand_path(File.dirname(__FILE__))
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
36
|
# Used internally to determine what to do when a SIGINT is received
|
43
37
|
def self.wants_to_quit
|
44
38
|
world.wants_to_quit
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Core
|
3
3
|
module ConstMissing
|
4
|
+
# Used to print deprecation warnings for Rspec and Spec constants (use
|
5
|
+
# RSpec instead)
|
4
6
|
def const_missing(name)
|
5
7
|
case name
|
6
8
|
when :Rspec, :Spec
|
@@ -29,6 +31,7 @@ WARNING
|
|
29
31
|
end
|
30
32
|
|
31
33
|
module Runner
|
34
|
+
# @deprecated use RSpec.configure instead.
|
32
35
|
def self.configure(&block)
|
33
36
|
RSpec.deprecate("Spec::Runner.configure", "RSpec.configure")
|
34
37
|
RSpec.configure(&block)
|
@@ -36,6 +39,8 @@ WARNING
|
|
36
39
|
end
|
37
40
|
|
38
41
|
module Rake
|
42
|
+
# Used to print deprecation warnings for Rake::SpecTask constant (use
|
43
|
+
# RSpec::Core::RakeTask instead)
|
39
44
|
def self.const_missing(name)
|
40
45
|
case name
|
41
46
|
when :SpecTask
|
@@ -21,7 +21,7 @@ module RSpec
|
|
21
21
|
@configuration.reporter.report(@world.example_count) do |reporter|
|
22
22
|
begin
|
23
23
|
@configuration.run_hook(:before, :suite)
|
24
|
-
@world.example_groups.map {|g| g.run(reporter)}.all? ? 0 :
|
24
|
+
@world.example_groups.map {|g| g.run(reporter)}.all? ? 0 : @configuration.failure_exit_code
|
25
25
|
ensure
|
26
26
|
@configuration.run_hook(:after, :suite)
|
27
27
|
end
|
@@ -28,6 +28,7 @@ module RSpec
|
|
28
28
|
add_setting :drb_port
|
29
29
|
add_setting :profile_examples
|
30
30
|
add_setting :fail_fast
|
31
|
+
add_setting :failure_exit_code, :default => 1
|
31
32
|
add_setting :run_all_when_everything_filtered
|
32
33
|
add_setting :exclusion_filter
|
33
34
|
add_setting :inclusion_filter
|
@@ -120,7 +121,7 @@ module RSpec
|
|
120
121
|
@settings ||= {}
|
121
122
|
end
|
122
123
|
|
123
|
-
def clear_inclusion_filter
|
124
|
+
def clear_inclusion_filter
|
124
125
|
self.inclusion_filter = nil
|
125
126
|
end
|
126
127
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module RSpec
|
2
2
|
|
3
3
|
class << self
|
4
|
+
# Used internally to print deprecation warnings
|
4
5
|
def deprecate(method, alternate_method=nil, version=nil)
|
5
6
|
version_string = version ? "rspec-#{version}" : "a future version of RSpec"
|
6
7
|
|
@@ -24,11 +25,13 @@ ADDITIONAL
|
|
24
25
|
warn_deprecation(message)
|
25
26
|
end
|
26
27
|
|
28
|
+
# Used internally to print deprecation warnings
|
27
29
|
def warn_deprecation(message)
|
28
30
|
send :warn, message
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
34
|
+
# @private
|
32
35
|
class HashWithDeprecationNotice < Hash
|
33
36
|
|
34
37
|
def initialize(method, alternate_method=nil)
|
data/lib/rspec/core/errors.rb
CHANGED
@@ -2,11 +2,10 @@ module RSpec
|
|
2
2
|
module Core
|
3
3
|
# If Test::Unit is loaed, we'll use its error as baseclass, so that Test::Unit
|
4
4
|
# will report unmet RSpec expectations as failures rather than errors.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
class PendingExampleFixedError < superclass
|
5
|
+
begin
|
6
|
+
class PendingExampleFixedError < Test::Unit::AssertionFailedError; end
|
7
|
+
rescue
|
8
|
+
class PendingExampleFixedError < StandardError; end
|
10
9
|
end
|
11
10
|
end
|
12
11
|
end
|
data/lib/rspec/core/example.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module Kernel
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
unless respond_to?(:debugger)
|
3
|
+
# If not already defined by ruby-debug, this implementation prints helpful
|
4
|
+
# message to STDERR when ruby-debug is not loaded.
|
5
|
+
def debugger(*args)
|
6
|
+
(RSpec.configuration.error_stream || $stderr).puts "\n***** debugger statement ignored, use -d or --debug option to enable debugging\n#{caller(0)[1]}"
|
7
|
+
end
|
8
|
+
end
|
5
9
|
end
|
@@ -2,8 +2,8 @@ module RSpec
|
|
2
2
|
module Core
|
3
3
|
module Formatters
|
4
4
|
# This class extracts code snippets by looking at the backtrace of the passed error
|
5
|
-
class SnippetExtractor
|
6
|
-
class NullConverter; def convert(code, pre); code; end; end
|
5
|
+
class SnippetExtractor
|
6
|
+
class NullConverter; def convert(code, pre); code; end; end
|
7
7
|
|
8
8
|
begin
|
9
9
|
require 'syntax/convertors/html'
|
data/lib/rspec/core/let.rb
CHANGED
@@ -86,12 +86,12 @@ module RSpec
|
|
86
86
|
end
|
87
87
|
|
88
88
|
module InstanceMethods
|
89
|
-
def __memoized
|
89
|
+
def __memoized
|
90
90
|
@__memoized ||= {}
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
def self.included(mod)
|
94
|
+
def self.included(mod)
|
95
95
|
mod.extend ClassMethods
|
96
96
|
mod.__send__ :include, InstanceMethods
|
97
97
|
end
|
@@ -116,6 +116,10 @@ module RSpec::Core
|
|
116
116
|
options[:fail_fast] = true
|
117
117
|
end
|
118
118
|
|
119
|
+
parser.on('--failure-exit-code CODE', 'Override the exit code used when there are failing specs.') do |o|
|
120
|
+
options[:failure_exit_code] = o.to_i
|
121
|
+
end
|
122
|
+
|
119
123
|
parser.on('-t', '--tag TAG[:VALUE]', 'Run examples with the specified tag',
|
120
124
|
'To exclude examples, add ~ before the tag (e.g. ~slow)',
|
121
125
|
'(TAG is always converted to a symbol)') do |tag|
|
data/lib/rspec/core/rake_task.rb
CHANGED
@@ -30,7 +30,7 @@ module RSpec
|
|
30
30
|
# default:
|
31
31
|
# false
|
32
32
|
def skip_bundler=(*)
|
33
|
-
RSpec.deprecate("RSpec::Core::RakeTask#skip_bundler="
|
33
|
+
RSpec.deprecate("RSpec::Core::RakeTask#skip_bundler=")
|
34
34
|
end
|
35
35
|
|
36
36
|
# Deprecated and has no effect. The rake task now checks
|
@@ -154,7 +154,7 @@ module RSpec
|
|
154
154
|
|
155
155
|
private
|
156
156
|
|
157
|
-
def files_to_run
|
157
|
+
def files_to_run
|
158
158
|
if ENV['SPEC']
|
159
159
|
FileList[ ENV['SPEC'] ]
|
160
160
|
else
|
@@ -165,7 +165,6 @@ module RSpec
|
|
165
165
|
def spec_command
|
166
166
|
@spec_command ||= begin
|
167
167
|
cmd_parts = []
|
168
|
-
cmd_parts << "bundle exec" if bundler?
|
169
168
|
cmd_parts << RUBY
|
170
169
|
cmd_parts << ruby_opts
|
171
170
|
cmd_parts << "-w" if warning?
|
@@ -197,11 +196,6 @@ module RSpec
|
|
197
196
|
def blank
|
198
197
|
lambda {|s| s == ""}
|
199
198
|
end
|
200
|
-
|
201
|
-
def bundler?
|
202
|
-
ENV["BUNDLE_GEMFILE"] if ENV["BUNDLE_GEMFILE"] unless ENV["BUNDLE_GEMFILE"] == ""
|
203
|
-
end
|
204
|
-
|
205
199
|
end
|
206
200
|
end
|
207
201
|
end
|
@@ -11,23 +11,23 @@ module RSpec
|
|
11
11
|
dirs.map {|dir| add_dir_to_load_path(File.join(root, dir))}
|
12
12
|
end
|
13
13
|
|
14
|
-
def add_dir_to_load_path(dir)
|
14
|
+
def add_dir_to_load_path(dir)
|
15
15
|
$LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
|
16
16
|
end
|
17
17
|
|
18
|
-
def root
|
18
|
+
def root
|
19
19
|
@project_root ||= determine_root
|
20
20
|
end
|
21
21
|
|
22
|
-
def determine_root
|
22
|
+
def determine_root
|
23
23
|
find_first_parent_containing('spec') || '.'
|
24
24
|
end
|
25
25
|
|
26
|
-
def find_first_parent_containing(dir)
|
26
|
+
def find_first_parent_containing(dir)
|
27
27
|
ascend_until {|path| File.exists?(File.join(path, dir))}
|
28
28
|
end
|
29
29
|
|
30
|
-
def ascend_until
|
30
|
+
def ascend_until
|
31
31
|
Pathname(File.expand_path('.')).ascend do |path|
|
32
32
|
return path if yield(path)
|
33
33
|
end
|
data/lib/rspec/core/runner.rb
CHANGED
@@ -16,20 +16,20 @@ module RSpec
|
|
16
16
|
@autorun_disabled = true
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.autorun_disabled?
|
19
|
+
def self.autorun_disabled?
|
20
20
|
@autorun_disabled ||= false
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.installed_at_exit?
|
23
|
+
def self.installed_at_exit?
|
24
24
|
@installed_at_exit ||= false
|
25
25
|
end
|
26
26
|
|
27
|
-
def self.running_in_drb?
|
27
|
+
def self.running_in_drb?
|
28
28
|
(DRb.current_server rescue false) &&
|
29
29
|
DRb.current_server.uri =~ /druby\:\/\/127.0.0.1\:/
|
30
30
|
end
|
31
31
|
|
32
|
-
def self.trap_interrupt
|
32
|
+
def self.trap_interrupt
|
33
33
|
trap('INT') do
|
34
34
|
exit!(1) if RSpec.wants_to_quit
|
35
35
|
RSpec.wants_to_quit = true
|
@@ -72,11 +72,11 @@ module RSpec
|
|
72
72
|
RSpec.reset
|
73
73
|
end
|
74
74
|
|
75
|
-
def self.run_over_drb(options, err, out)
|
75
|
+
def self.run_over_drb(options, err, out)
|
76
76
|
DRbCommandLine.new(options).run(err, out)
|
77
77
|
end
|
78
78
|
|
79
|
-
def self.run_in_process(options, err, out)
|
79
|
+
def self.run_in_process(options, err, out)
|
80
80
|
CommandLine.new(options, RSpec::configuration, RSpec::world).run(err, out)
|
81
81
|
end
|
82
82
|
|
data/lib/rspec/core/subject.rb
CHANGED
data/lib/rspec/core/version.rb
CHANGED
@@ -27,11 +27,17 @@ module RSpec::Core
|
|
27
27
|
result.should be(0)
|
28
28
|
end
|
29
29
|
|
30
|
-
it "returns 1 if spec
|
30
|
+
it "returns 1 if spec fails" do
|
31
31
|
err, out = StringIO.new, StringIO.new
|
32
32
|
result = command_line([failing_spec_filename]).run(err, out)
|
33
33
|
result.should be(1)
|
34
34
|
end
|
35
|
+
|
36
|
+
it "returns 2 if spec fails and --failure-exit-code is 2" do
|
37
|
+
err, out = StringIO.new, StringIO.new
|
38
|
+
result = command_line([failing_spec_filename, "--failure-exit-code", "2"]).run(err, out)
|
39
|
+
result.should be(2)
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
context "given an Array of options" do
|
@@ -168,6 +168,18 @@ describe RSpec::Core::ConfigurationOptions do
|
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
|
+
describe "--failure-exit-code" do
|
172
|
+
it "sets :failure_exit_code" do
|
173
|
+
parse_options('--failure-exit-code', '0').should include(:failure_exit_code => 0)
|
174
|
+
parse_options('--failure-exit-code', '1').should include(:failure_exit_code => 1)
|
175
|
+
parse_options('--failure-exit-code', '2').should include(:failure_exit_code => 2)
|
176
|
+
end
|
177
|
+
|
178
|
+
it "overrides previous :failure_exit_code" do
|
179
|
+
parse_options('--failure-exit-code', '2', '--failure-exit-code', '3').should include(:failure_exit_code => 3)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
171
183
|
describe "--options" do
|
172
184
|
it "sets :custom_options_file" do
|
173
185
|
parse_options(*%w[-O my.opts]).should include(:custom_options_file => "my.opts")
|
@@ -10,22 +10,6 @@ module RSpec::Core
|
|
10
10
|
FileUtils::RUBY
|
11
11
|
end
|
12
12
|
|
13
|
-
def with_bundle_gemfile(val)
|
14
|
-
begin
|
15
|
-
orig = ENV['BUNDLE_GEMFILE']
|
16
|
-
ENV['BUNDLE_GEMFILE'] = val
|
17
|
-
yield
|
18
|
-
ensure
|
19
|
-
ENV['BUNDLE_GEMFILE'] = orig
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def without_bundler
|
24
|
-
with_bundle_gemfile nil do
|
25
|
-
yield
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
13
|
def with_rcov
|
30
14
|
task.rcov = true
|
31
15
|
yield
|
@@ -35,52 +19,24 @@ module RSpec::Core
|
|
35
19
|
task.__send__(:spec_command)
|
36
20
|
end
|
37
21
|
|
38
|
-
context "default
|
39
|
-
it "renders rspec" do
|
40
|
-
with_bundle_gemfile nil do
|
41
|
-
spec_command.should =~ /^#{ruby} -S rspec/
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "default (BUNDLE_GEMFILE '')" do
|
22
|
+
context "default" do
|
47
23
|
it "renders rspec" do
|
48
|
-
|
49
|
-
spec_command.should =~ /^#{ruby} -S rspec/
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "with bundler (BUNDLE_GEMFILE non-blank)" do
|
55
|
-
it "renders bundle exec rspec" do
|
56
|
-
spec_command.should match(/bundle exec/)
|
24
|
+
spec_command.should =~ /^#{ruby} -S rspec/
|
57
25
|
end
|
58
26
|
end
|
59
27
|
|
60
28
|
context "with rcov" do
|
61
29
|
it "renders rcov" do
|
62
|
-
without_bundler do
|
63
30
|
with_rcov do
|
64
31
|
spec_command.should =~ /^#{ruby} -S rcov/
|
65
32
|
end
|
66
33
|
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "with bundler" do
|
70
|
-
it "renders bundle exec rcov" do
|
71
|
-
with_rcov do
|
72
|
-
spec_command.should =~ /^bundle exec #{ruby} -S rcov/
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
34
|
end
|
77
35
|
|
78
36
|
context "with ruby options" do
|
79
37
|
it "renders them before -S" do
|
80
|
-
without_bundler do
|
81
38
|
task.ruby_opts = "-w"
|
82
39
|
spec_command.should =~ /^#{ruby} -w -S rspec/
|
83
|
-
end
|
84
40
|
end
|
85
41
|
end
|
86
42
|
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 7
|
9
9
|
- 0
|
10
|
-
|
11
|
-
- 1
|
12
|
-
version: 2.7.0.rc1
|
10
|
+
version: 2.7.0
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Chad Humphries
|
@@ -18,7 +16,7 @@ autorequire:
|
|
18
16
|
bindir: exe
|
19
17
|
cert_chain: []
|
20
18
|
|
21
|
-
date: 2011-10-
|
19
|
+
date: 2011-10-16 00:00:00 Z
|
22
20
|
dependencies: []
|
23
21
|
|
24
22
|
description: BDD for Ruby. RSpec runner and example groups.
|
@@ -212,21 +210,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
211
|
none: false
|
214
212
|
requirements:
|
215
|
-
- - "
|
213
|
+
- - ">="
|
216
214
|
- !ruby/object:Gem::Version
|
217
|
-
hash:
|
215
|
+
hash: 3
|
218
216
|
segments:
|
219
|
-
-
|
220
|
-
|
221
|
-
- 1
|
222
|
-
version: 1.3.1
|
217
|
+
- 0
|
218
|
+
version: "0"
|
223
219
|
requirements: []
|
224
220
|
|
225
221
|
rubyforge_project: rspec
|
226
|
-
rubygems_version: 1.8.
|
222
|
+
rubygems_version: 1.8.11
|
227
223
|
signing_key:
|
228
224
|
specification_version: 3
|
229
|
-
summary: rspec-core-2.7.0
|
225
|
+
summary: rspec-core-2.7.0
|
230
226
|
test_files:
|
231
227
|
- features/Autotest.md
|
232
228
|
- features/README.md
|