Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix bug introduced in previous commit where low priority exclusion

filters bypassed the deprecation warnings for if/unless.
  • Loading branch information...
commit a51efc7cb5630bc63641d0cc337513bff3705583 1 parent 399436c
@dchelimsky dchelimsky authored
View
22 lib/rspec/core/filter_manager.rb
@@ -83,20 +83,28 @@ def empty_without_conditional_filters?
end
module BackwardCompatibility
- # Supports a use case that probably doesn't exist: overriding the
- # if/unless procs.
def merge(orig, opposite, *updates)
- _warn_deprecated_key(:unless, *updates) if updates.last.has_key?(:unless)
- _warn_deprecated_key(:if, *updates) if updates.last.has_key?(:if)
+ _warn_deprecated_keys(updates.last)
+ super
+ end
+ def reverse_merge(orig, opposite, *updates)
+ _warn_deprecated_keys(updates.last)
super
end
+ # Supports a use case that probably doesn't exist: overriding the
+ # if/unless procs.
+ def _warn_deprecated_keys(updates)
+ _warn_deprecated_key(:unless, updates) if updates.has_key?(:unless)
+ _warn_deprecated_key(:if, updates) if updates.has_key?(:if)
+ end
+
# Emits a deprecation warning for keys that will not be supported in
# the future.
- 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)
+ def _warn_deprecated_key(key, updates)
+ RSpec.warn_deprecation("\nDEPRECATION NOTICE: FilterManager#exclude(#{key.inspect} => #{updates[key].inspect}) is deprecated with no replacement, and will be removed from rspec-3.0.")
+ @exclusions[key] = updates.delete(key)
end
end
View
20 spec/rspec/core/filter_manager_spec.rb
@@ -180,14 +180,26 @@ def opposite(name)
it 'deprecates an overridden :if filter' do
RSpec.should_receive(:warn_deprecation).with(/exclude\(:if.*is deprecated/)
- filter_manager = FilterManager.new
- filter_manager.exclude :if => :custom_filter
+ filter_manager = FilterManager.new
+ filter_manager.exclude :if => :custom_filter
+ end
+
+ it 'deprecates an :if filter overridden with low priority' do
+ RSpec.should_receive(:warn_deprecation).with(/exclude\(:if.*is deprecated/)
+ filter_manager = FilterManager.new
+ filter_manager.exclude_with_low_priority :if => :custom_filter
end
it 'deprecates an overridden :unless filter' do
RSpec.should_receive(:warn_deprecation).with(/exclude\(:unless.*is deprecated/)
- filter_manager = FilterManager.new
- filter_manager.exclude :unless => :custom_filter
+ filter_manager = FilterManager.new
+ filter_manager.exclude :unless => :custom_filter
+ end
+
+ it 'deprecates an :unless filter overridden with low priority' do
+ RSpec.should_receive(:warn_deprecation).with(/exclude\(:unless.*is deprecated/)
+ filter_manager = FilterManager.new
+ filter_manager.exclude_with_low_priority :unless => :custom_filter
end
it 'includes an overriden :if filter' do
Please sign in to comment.
Something went wrong with that request. Please try again.