Skip to content

Commit

Permalink
refactoring: extract method for warning
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Nov 11, 2011
1 parent fe4d40c commit 13586e0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/rspec/core/filter_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,16 @@ module BackwardCompatibility
# This is to support a use case that probably doesn't exist: overriding
# the if/unless procs.
def update(orig, opposite, *updates)
if updates.last.has_key?(:unless)
RSpec.warn_deprecation("\nDEPRECATION NOTICE: FilterManager#exclude(:unless => #{updates.last[:unless].inspect}) is deprecated with no replacement, and will be removed from rspec-3.0.")
@exclusions[:unless] = updates.last.delete(:unless)
end
if updates.last.has_key?(:if)
RSpec.warn_deprecation("\nDEPRECATION NOTICE: FilterManager#exclude(:if => #{updates.last[:if].inspect}) is deprecated with no replacement, and will be removed from rspec-3.0.")
@exclusions[:if] = updates.last.delete(:if)
end
_warn_deprecated_key(:unless, *updates) if updates.last.has_key?(:unless)
_warn_deprecated_key(:if, *updates) if updates.last.has_key?(:if)

super
end

def _warn_deprecated_key(key, *updates)
RSpec.warn_deprecation("\nDEPRECATION NOTICE: FilterManager#exclude(#{key.inspect} => #{updates.last[key].inspect}) is deprecated with no replacement, and will be removed from rspec-3.0.")
@exclusions[key] = updates.last.delete(key)
end
end

attr_reader :exclusions, :inclusions
Expand Down

0 comments on commit 13586e0

Please sign in to comment.