Update HaveText & HaveTitle to silence deprecations on RSpec3

This commit is contained in:
Jonathan del Strother 2013-12-31 10:55:35 +00:00
parent 60683d9054
commit 2121ff12fb
1 changed files with 13 additions and 5 deletions

View File

@ -51,16 +51,20 @@ module Capybara
@actual.has_no_text?(type, content, options)
end
def failure_message_for_should
def failure_message
message = Capybara::Helpers.failure_message(description, options)
message << " in #{format(@actual.text(type))}"
message
end
def failure_message_for_should_not
failure_message_for_should.sub(/(to find)/, 'not \1')
def failure_message_when_negated
failure_message.sub(/(to find)/, 'not \1')
end
# RSpec 2 compatibility:
alias_method :failure_message_for_should, :failure_message
alias_method :failure_message_for_should_not, :failure_message_when_negated
def description
"text #{format(content)}"
end
@ -88,14 +92,18 @@ module Capybara
@actual.has_no_title?(title)
end
def failure_message_for_should
def failure_message
"expected there to be title #{title.inspect} in #{@actual.title.inspect}"
end
def failure_message_for_should_not
def failure_message_when_negated
"expected there not to be title #{title.inspect} in #{@actual.title.inspect}"
end
# RSpec 2 compatibility:
alias_method :failure_message_for_should, :failure_message
alias_method :failure_message_for_should_not, :failure_message_when_negated
def description
"have title #{title.inspect}"
end