Skip to content

Commit

Permalink
Merge pull request teamcapybara#1219 from jdelStrother/rspec3
Browse files Browse the repository at this point in the history
Update HaveText to silence deprecations on RSpec3
  • Loading branch information
jnicklas committed Jan 6, 2014
2 parents 60683d9 + 2121ff1 commit f18637b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/capybara/rspec/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,20 @@ def does_not_match?(actual)
@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
Expand Down Expand Up @@ -88,14 +92,18 @@ def does_not_match?(actual)
@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
Expand Down

0 comments on commit f18637b

Please sign in to comment.