Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add default RSpec description for all matchers #68

Open
wants to merge 1 commit into from

2 participants

@dnagir

This is addition to #66 that provides the default description for all the matchers

@dnagir

Anybody minds to take a look at this PR and maybe release?

@dnagir

Knock-knock...

@mandrews

+1 - currently using @dnagir's patch as a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 5, 2012
  1. @dnagir
This page is out of date. Refresh to see the latest.
View
6 lib/webrat/core/matchers/have_content.rb
@@ -19,6 +19,12 @@ def matches?(stringlike)
end
# ==== Returns
+ # String:: The default description for the spec when it is not provided.
+ def description
+ "contain #{@content.inspect}"
+ end
+
+ # ==== Returns
# String:: The failure message.
def failure_message
"expected the following element's content to #{content_message}:\n#{squeeze_space(@element)}"
View
10 lib/webrat/core/matchers/have_selector.rb
@@ -6,16 +6,6 @@ module Matchers
class HaveSelector < HaveXpath #:nodoc:
# ==== Returns
- # String:: The default description for the spec when it is not provided.
- def description
- "have selector #{@expected.inspect}" + if @options && @options.any?
- " with #{@options.inspect}"
- else
- ''
- end
- end
-
- # ==== Returns
# String:: The failure message.
def failure_message
"expected following output to contain a #{tag_inspect} tag:\n#{@document}"
View
14 lib/webrat/core/matchers/have_xpath.rb
@@ -68,6 +68,20 @@ def query
@expected
end
+ def matcher_name
+ self.class.name.split('::').last.sub(/^Have/, '').downcase
+ end
+
+ # ==== Returns
+ # String:: The default description for the spec when it is not provided.
+ def description
+ "have #{matcher_name} #{@expected.inspect}" + if @options && @options.any?
+ " with #{@options.inspect}"
+ else
+ ''
+ end
+ end
+
# ==== Returns
# String:: The failure message.
def failure_message
Something went wrong with that request. Please try again.