Skip to content

Commit

Permalink
validates_nilness_of RSpec 3 non-deprecation
Browse files Browse the repository at this point in the history
MSP-12130

metasploit-cache runs with deprecations as errors, so
validates_uniqueness_of needs to use the non-deprecated message methods
for RSpec 3 when they are available.
  • Loading branch information
limhoff-r7 committed Feb 10, 2015
1 parent 60a970e commit a516569
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/metasploit/model/version.rb
Expand Up @@ -7,7 +7,7 @@ module Version
# The minor version number, scoped to the {MAJOR} version number.
MINOR = 29
# The patch number, scoped to the {MAJOR} and {MINOR} version numbers.
PATCH = 1
PATCH = 2
# The prerelease version, scoped to the {MAJOR}, {MINOR}, and {PATCH} version numbers.
PRERELEASE = 'validates-nilness-of'

Expand Down
18 changes: 16 additions & 2 deletions spec/support/matchers/validate_nilness_of.rb
Expand Up @@ -3,11 +3,25 @@
"require nil for #{attribute}"
end

failure_message_for_should do |instance|
failure_message_method = :failure_message_for_should

# RSpec compatibility without deprecation warnings
if respond_to?(:failure_message)
failure_message_method = :failure_message
end

send(failure_message_method) do |instance|
"Expected errors to include 'must be nil' when #{attribute} is set to an arbitrary string"
end

failure_message_for_should_not do |instance|
failure_message_when_negated_method = :failure_message_for_should_not

# RSpec compatibility without deprecation warnings
if respond_to?(:failure_message_when_negated)
failure_message_when_negated_method = :failure_message_when_negated
end

send(failure_message_when_negated_method) do |instance|
"Expected errors not to include 'must be nil' when #{attribute} is set"
end

Expand Down

0 comments on commit a516569

Please sign in to comment.