Class: Spec::Matchers::Watir::ElementMatcher
- Inherits:
-
Object
- Object
- Spec::Matchers::Watir::ElementMatcher
- Defined in:
- lib/spec/ui/watir/matchers.rb
Overview
:nodoc
Instance Method Summary collapse
- #arg_string ⇒ Object
- #failure_message ⇒ Object
-
#initialize(kind, *args) ⇒ ElementMatcher
constructor
A new instance of ElementMatcher.
- #matches?(container) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(kind, *args) ⇒ ElementMatcher
Returns a new instance of ElementMatcher.
38 39 40 |
# File 'lib/spec/ui/watir/matchers.rb', line 38 def initialize(kind, *args) @kind, @args = kind, args end |
Instance Method Details
#arg_string ⇒ Object
67 68 69 |
# File 'lib/spec/ui/watir/matchers.rb', line 67 def arg_string @args.map{|a| a.inspect}.join(", ") end |
#failure_message ⇒ Object
59 60 61 |
# File 'lib/spec/ui/watir/matchers.rb', line 59 def "Expected #{@container.class} to have #{@kind}(#{arg_string}), but it was not found" end |
#matches?(container) ⇒ Boolean
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/spec/ui/watir/matchers.rb', line 42 def matches?(container) @container = container begin element = @container.__send__(@kind, *@args) if element.respond_to?(:assert_exists) # IE element.assert_exists true else # Safari element.exists? end rescue ::Watir::Exception::UnknownObjectException => e false end end |
#negative_failure_message ⇒ Object
63 64 65 |
# File 'lib/spec/ui/watir/matchers.rb', line 63 def "Expected #{@container.class} to not have #{@kind}(#{arg_string}), but it was found" end |