Skip to content
This repository
  • 3 commits
  • 3 files changed
  • 0 comments
  • 2 contributors
Jul 13, 2013
Myron Marston Merge pull request #984 from rspec/fixup_rake_deprecate
Fixup Rakefile deprecations
af2d422
Myron Marston 2.14.3 release. 1d89971
Jul 14, 2013
Jon Rowe Fixup Rakefile deprecations
If RSpec is already loaded (it's common to do:
```
require 'rspec' # or 'rspec/core'
require 'rspec/core/rake_task'
```
in a `Rakefile`), we can safely use the built in deprecation support
however otherwise it's become to complicated to load the deprecation
file alone so we drop back to a simplier warn.
3e21001
9  Changelog.md
Source Rendered
... ...
@@ -1,3 +1,12 @@
  1
+### 2.14.3 / 2013-07-13
  2
+[full changelog](http://github.com/rspec/rspec-core/compare/v2.14.2...v2.14.3)
  3
+
  4
+Bug fixes
  5
+
  6
+* Fix deprecation notices issued from `RSpec::Core::RakeTask` so
  7
+  that they work properly when all of rspec-core is not loaded.
  8
+  (This was a regression in 2.14) (Jon Rowe)
  9
+
1 10
 ### 2.14.2 / 2013-07-09
2 11
 [full changelog](http://github.com/rspec/rspec-core/compare/v2.14.1...v2.14.2)
3 12
 
22  lib/rspec/core/rake_task.rb
... ...
@@ -1,5 +1,4 @@
1 1
 require 'rspec/core/backward_compatibility'
2  
-require 'rspec/core/deprecation'
3 2
 require 'rake'
4 3
 require 'rake/tasklib'
5 4
 require 'shellwords'
@@ -24,13 +23,13 @@ class RakeTask < ::Rake::TaskLib
24 23
       # @deprecated
25 24
       # Has no effect. The rake task now checks ENV['BUNDLE_GEMFILE'] instead.
26 25
       def skip_bundler=(*)
27  
-        RSpec.deprecate("RSpec::Core::RakeTask#skip_bundler=")
  26
+        deprecate("RSpec::Core::RakeTask#skip_bundler=")
28 27
       end
29 28
 
30 29
       # @deprecated
31 30
       # Has no effect. The rake task now checks ENV['BUNDLE_GEMFILE'] instead.
32 31
       def gemfile=(*)
33  
-        RSpec.deprecate("RSpec::Core::RakeTask#gemfile=", :replacement => 'ENV["BUNDLE_GEMFILE"]')
  32
+        deprecate("RSpec::Core::RakeTask#gemfile=", :replacement => 'ENV["BUNDLE_GEMFILE"]')
34 33
       end
35 34
 
36 35
       # @deprecated
@@ -42,7 +41,7 @@ def gemfile=(*)
42 41
       # default:
43 42
       #   false
44 43
       def warning=(true_or_false)
45  
-        RSpec.deprecate("RSpec::Core::RakeTask#warning=", :replacement => 'ruby_opts="-w"')
  44
+        deprecate("RSpec::Core::RakeTask#warning=", :replacement => 'ruby_opts="-w"')
46 45
         @warning = true_or_false
47 46
       end
48 47
 
@@ -109,7 +108,7 @@ def warning=(true_or_false)
109 108
       # default:
110 109
       #   nil
111 110
       def spec_opts=(opts)
112  
-        RSpec.deprecate('RSpec::Core::RakeTask#spec_opts=', :replacement => 'rspec_opts=')
  111
+        deprecate('RSpec::Core::RakeTask#spec_opts=', :replacement => 'rspec_opts=')
113 112
         @rspec_opts = opts
114 113
       end
115 114
 
@@ -189,6 +188,19 @@ def runner
189 188
       def blank
190 189
         lambda {|s| s.nil? || s == ""}
191 190
       end
  191
+
  192
+      def deprecate deprecated, opts = {}
  193
+        # unless RSpec is loaded, deprecate won't work (simply requiring the
  194
+        # deprecate file isn't enough) so this is a check for "is rspec already
  195
+        # loaded?" "ok use the main deprecate hook" otherwise "simple fallback"
  196
+        # Note that we don't need rspec to be loaded for the rake task to work
  197
+        if RSpec.respond_to?(:deprecate)
  198
+          RSpec.deprecate deprecated, opts
  199
+        else
  200
+          warn "DEPRECATION: #{deprecated} is deprecated."
  201
+        end
  202
+      end
  203
+
192 204
     end
193 205
   end
194 206
 end
3  lib/rspec/core/version.rb
... ...
@@ -1,7 +1,8 @@
1 1
 module RSpec
2 2
   module Core
3 3
     module Version
4  
-      STRING = '2.14.2'
  4
+      STRING = '2.14.3'
5 5
     end
6 6
   end
7 7
 end
  8
+

No commit comments for this range

Something went wrong with that request. Please try again.