rspec-core 2.14.3 → 2.14.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.md +23 -0
- data/features/command_line/pattern_option.feature +18 -0
- data/lib/rspec/core.rb +19 -13
- data/lib/rspec/core/configuration_options.rb +5 -4
- data/lib/rspec/core/deprecation.rb +3 -1
- data/lib/rspec/core/option_parser.rb +8 -1
- data/lib/rspec/core/version.rb +1 -1
- data/spec/rspec/core/configuration_options_spec.rb +8 -0
- data/spec/rspec/core/deprecation_spec.rb +2 -2
- data/spec/rspec/core/option_parser_spec.rb +26 -0
- data/spec/rspec/core_spec.rb +19 -0
- data/spec/support/helper_methods.rb +10 -0
- metadata +5 -5
data/Changelog.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
### 2.14.4 / 2013-07-21
|
2
|
+
[full changelog](http://github.com/rspec/rspec-core/compare/v2.14.3...v2.14.4)
|
3
|
+
|
4
|
+
Bug fixes
|
5
|
+
|
6
|
+
* Fix regression in 2.14: ensure configured requires (via `-r` option)
|
7
|
+
are loaded before spec files are loaded. This allows the spec files
|
8
|
+
to programatically change the file pattern (Jon Rowe).
|
9
|
+
* Autoload `RSpec::Mocks` and `RSpec::Expectations` when referenced if
|
10
|
+
they are not already loaded (`RSpec::Matches` has been autoloaded
|
11
|
+
for a while). In the `rspec` gem, we changed it recently to stop
|
12
|
+
loading `rspec/mocks` and `rspec/expectations` by default, as some
|
13
|
+
users reported problems where they were intending to use mocha,
|
14
|
+
not rspec-mocks, but rspec-mocks was loaded and causing a conflict.
|
15
|
+
rspec-core loads mocks and expectations at the appropriate time, so
|
16
|
+
it seemed like a safe change -- but caused a problem for some authors
|
17
|
+
of libraries that integrate with RSpec. This fixes that problem.
|
18
|
+
(Myron Marston)
|
19
|
+
* Gracefully handle a command like `rspec --profile path/to/spec.rb`:
|
20
|
+
the `path/to/spec.rb` arg was being wrongly treated as the `profile`
|
21
|
+
integer arg, which got cast `0` using `to_i`, causing no profiled
|
22
|
+
examples to be printed. (Jon Rowe)
|
23
|
+
|
1
24
|
### 2.14.3 / 2013-07-13
|
2
25
|
[full changelog](http://github.com/rspec/rspec-core/compare/v2.14.2...v2.14.3)
|
3
26
|
|
@@ -29,3 +29,21 @@ Feature: pattern option
|
|
29
29
|
"""
|
30
30
|
When I run `rspec --pattern "spec/**/*.spec"`
|
31
31
|
Then the output should contain "1 example, 0 failures"
|
32
|
+
|
33
|
+
Scenario: override the default pattern in configuration
|
34
|
+
Given a file named "spec/spec_helper.rb" with:
|
35
|
+
"""ruby
|
36
|
+
RSpec.configure do |config|
|
37
|
+
config.pattern << ',**/*.spec'
|
38
|
+
end
|
39
|
+
"""
|
40
|
+
And a file named "spec/example.spec" with:
|
41
|
+
"""ruby
|
42
|
+
describe "addition" do
|
43
|
+
it "adds things" do
|
44
|
+
(1 + 2).should eq(3)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
"""
|
48
|
+
When I run `rspec -rspec_helper`
|
49
|
+
Then the output should contain "1 example, 0 failures"
|
data/lib/rspec/core.rb
CHANGED
@@ -143,20 +143,26 @@ WARNING
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
+
MODULES_TO_AUTOLOAD = {
|
147
|
+
:Matchers => "rspec/expectations",
|
148
|
+
:Expectations => "rspec/expectations",
|
149
|
+
:Mocks => "rspec/mocks"
|
150
|
+
}
|
151
|
+
|
146
152
|
def self.const_missing(name)
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
153
|
+
# Load rspec-expectations when RSpec::Matchers is referenced. This allows
|
154
|
+
# people to define custom matchers (using `RSpec::Matchers.define`) before
|
155
|
+
# rspec-core has loaded rspec-expectations (since it delays the loading of
|
156
|
+
# it to allow users to configure a different assertion/expectation
|
157
|
+
# framework). `autoload` can't be used since it works with ruby's built-in
|
158
|
+
# require (e.g. for files that are available relative to a load path dir),
|
159
|
+
# but not with rubygems' extended require.
|
160
|
+
#
|
161
|
+
# As of rspec 2.14.1, we no longer require `rspec/mocks` and
|
162
|
+
# `rspec/expectations` when `rspec` is required, so we want
|
163
|
+
# to make them available as an autoload. For more info, see:
|
164
|
+
require MODULES_TO_AUTOLOAD.fetch(name) { return super }
|
165
|
+
::RSpec.const_get(name)
|
160
166
|
end
|
161
167
|
end
|
162
168
|
|
@@ -20,10 +20,11 @@ module RSpec
|
|
20
20
|
|
21
21
|
def configure(config)
|
22
22
|
config.filter_manager = filter_manager
|
23
|
-
process_options_into config
|
24
23
|
|
24
|
+
config.libs = options[:libs] || []
|
25
25
|
config.setup_load_path_and_require(options[:requires] || [])
|
26
26
|
|
27
|
+
process_options_into config
|
27
28
|
load_formatters_into config
|
28
29
|
end
|
29
30
|
|
@@ -46,13 +47,13 @@ module RSpec
|
|
46
47
|
private
|
47
48
|
|
48
49
|
NON_FORCED_OPTIONS = [
|
49
|
-
:debug, :requires, :
|
50
|
+
:debug, :requires, :profile, :drb, :libs, :files_or_directories_to_run,
|
50
51
|
:line_numbers, :full_description, :full_backtrace, :tty
|
51
52
|
].to_set
|
52
53
|
|
53
54
|
MERGED_OPTIONS = [:requires, :libs].to_set
|
54
55
|
|
55
|
-
UNPROCESSABLE_OPTIONS = [:formatters, :requires].to_set
|
56
|
+
UNPROCESSABLE_OPTIONS = [:libs, :formatters, :requires].to_set
|
56
57
|
|
57
58
|
def force?(key)
|
58
59
|
!NON_FORCED_OPTIONS.include?(key)
|
@@ -68,7 +69,7 @@ module RSpec
|
|
68
69
|
def process_options_into(config)
|
69
70
|
opts = options.reject { |k, _| UNPROCESSABLE_OPTIONS.include? k }
|
70
71
|
|
71
|
-
order(opts.keys, :
|
72
|
+
order(opts.keys, :default_path, :pattern).each do |key|
|
72
73
|
force?(key) ? config.force(key => opts[key]) : config.send("#{key}=", opts[key])
|
73
74
|
end
|
74
75
|
end
|
@@ -8,10 +8,12 @@ module RSpec
|
|
8
8
|
# Temporarily support old and new APIs while we transition the other
|
9
9
|
# rspec libs to use a hash for the 2nd arg and no version arg
|
10
10
|
data = Hash === replacement_or_hash ? replacement_or_hash : { :replacement => replacement_or_hash }
|
11
|
+
call_site = caller.find { |line| line !~ %r{/lib/rspec/(core|mocks|expectations|matchers|rails)/} }
|
12
|
+
|
11
13
|
RSpec.configuration.reporter.deprecation(
|
12
14
|
{
|
13
15
|
:deprecated => deprecated,
|
14
|
-
:call_site =>
|
16
|
+
:call_site => call_site
|
15
17
|
}.merge(data)
|
16
18
|
)
|
17
19
|
end
|
@@ -141,7 +141,14 @@ module RSpec::Core
|
|
141
141
|
elsif argument == false
|
142
142
|
false
|
143
143
|
else
|
144
|
-
|
144
|
+
begin
|
145
|
+
Integer(argument)
|
146
|
+
rescue ArgumentError
|
147
|
+
Kernel.warn "Non integer specified as profile count, seperate " +
|
148
|
+
"your path from options with -- e.g. " +
|
149
|
+
"`rspec --profile -- #{argument}`"
|
150
|
+
true
|
151
|
+
end
|
145
152
|
end
|
146
153
|
end
|
147
154
|
|
data/lib/rspec/core/version.rb
CHANGED
@@ -29,6 +29,14 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
|
|
29
29
|
opts.configure(config)
|
30
30
|
end
|
31
31
|
|
32
|
+
it "sends loads requires before loading specs" do
|
33
|
+
opts = config_options_object(*%w[-rspec_helper])
|
34
|
+
config = double("config").as_null_object
|
35
|
+
expect(config).to receive(:setup_load_path_and_require).ordered
|
36
|
+
expect(config).to receive(:files_or_directories_to_run=).ordered
|
37
|
+
opts.configure(config)
|
38
|
+
end
|
39
|
+
|
32
40
|
it "sets up load path and requires before formatter" do
|
33
41
|
opts = config_options_object(*%w[--require a/path -f a/formatter])
|
34
42
|
config = double("config").as_null_object
|
@@ -14,7 +14,7 @@ describe RSpec::Core::Deprecation do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "adds the call site" do
|
17
|
-
|
17
|
+
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
|
18
18
|
RSpec.deprecate("deprecated_method")
|
19
19
|
end
|
20
20
|
|
@@ -31,7 +31,7 @@ describe RSpec::Core::Deprecation do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "adds the call site" do
|
34
|
-
|
34
|
+
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
|
35
35
|
RSpec.deprecate("deprecated_method")
|
36
36
|
end
|
37
37
|
end
|
@@ -205,6 +205,32 @@ module RSpec::Core
|
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
|
+
describe '--profile' do
|
209
|
+
it 'sets profile_examples to true by default' do
|
210
|
+
options = Parser.parse!(%w[--profile])
|
211
|
+
expect(options[:profile_examples]).to eq true
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'sets profile_examples to supplied int' do
|
215
|
+
options = Parser.parse!(%w[--profile 10])
|
216
|
+
expect(options[:profile_examples]).to eq 10
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'sets profile_examples to true when accidentally combined with path' do
|
220
|
+
allow(Kernel).to receive(:warn)
|
221
|
+
options = Parser.parse!(%w[--profile some/path])
|
222
|
+
expect(options[:profile_examples]).to eq true
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'warns when accidentally combined with path' do
|
226
|
+
expect(Kernel).to receive(:warn) do |msg|
|
227
|
+
expect(msg).to match "Non integer specified as profile count"
|
228
|
+
end
|
229
|
+
options = Parser.parse!(%w[--profile some/path])
|
230
|
+
expect(options[:profile_examples]).to eq true
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
208
234
|
describe '--warning' do
|
209
235
|
it 'enables warnings' do
|
210
236
|
options = Parser.parse!(%w[--warnings])
|
data/spec/rspec/core_spec.rb
CHANGED
@@ -52,4 +52,23 @@ describe RSpec do
|
|
52
52
|
expect(RSpec.world).not_to equal(world_before_reset)
|
53
53
|
end
|
54
54
|
end
|
55
|
+
|
56
|
+
# This is hard to test :(. Best way I could come up with was starting
|
57
|
+
# fresh ruby process w/o this stuff already loaded.
|
58
|
+
it "loads mocks and expectations when the constants are referenced" do
|
59
|
+
code = "$LOAD_PATH.replace(#{$LOAD_PATH.inspect}); " +
|
60
|
+
'require "rspec"; ' +
|
61
|
+
"puts RSpec::Mocks.name; " +
|
62
|
+
"puts RSpec::Expectations.name"
|
63
|
+
|
64
|
+
result = `ruby -e '#{code}'`.chomp
|
65
|
+
expect(result.split("\n")).to eq(%w[ RSpec::Mocks RSpec::Expectations ])
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'correctly raises an error when an invalid const is referenced' do
|
69
|
+
expect {
|
70
|
+
RSpec::NotAConst
|
71
|
+
}.to raise_error(NameError, /uninitialized constant RSpec::NotAConst/)
|
72
|
+
end
|
55
73
|
end
|
74
|
+
|
@@ -23,4 +23,14 @@ module RSpecHelpers
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def expect_deprecation_with_call_site(file, line)
|
27
|
+
expect(RSpec.configuration.reporter).to receive(:deprecation) do |options|
|
28
|
+
expect(options[:call_site]).to include([file, line].join(':'))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def allow_deprecation
|
33
|
+
allow(RSpec.configuration.reporter).to receive(:deprecation)
|
34
|
+
end
|
35
|
+
|
26
36
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rspec-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.14.
|
5
|
+
version: 2.14.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Steven Baker
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-07-
|
14
|
+
date: 2013-07-22 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -383,7 +383,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
383
383
|
version: '0'
|
384
384
|
segments:
|
385
385
|
- 0
|
386
|
-
hash:
|
386
|
+
hash: 409767049060748500
|
387
387
|
none: false
|
388
388
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
389
389
|
requirements:
|
@@ -392,14 +392,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
392
392
|
version: '0'
|
393
393
|
segments:
|
394
394
|
- 0
|
395
|
-
hash:
|
395
|
+
hash: 409767049060748500
|
396
396
|
none: false
|
397
397
|
requirements: []
|
398
398
|
rubyforge_project: rspec
|
399
399
|
rubygems_version: 1.8.24
|
400
400
|
signing_key:
|
401
401
|
specification_version: 3
|
402
|
-
summary: rspec-core-2.14.
|
402
|
+
summary: rspec-core-2.14.4
|
403
403
|
test_files:
|
404
404
|
- features/Autotest.md
|
405
405
|
- features/README.md
|