Created
November 10, 2009 16:56
-
-
Save phinze/231032 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/support/matchers/be_hidden.rb | |
module Spec::Matchers | |
class BeHidden | |
def initialize(scope) | |
@scope = scope | |
end | |
def matches?(actual) | |
@actual = actual | |
# match only on root element, a little stricter but I think also prevents evil | |
@scope.have_tag('*:root[style *= ?]', /display\s*:\s*none/).matches?(actual) | |
end | |
def failure_message_for_should | |
"expected root element of '#{@actual}' to be hidden, but I saw it" | |
end | |
def failure_message_for_should_not | |
"expected root element of '#{@actual}' be visible, but it was, in fact, hidden" | |
end | |
def description | |
"be hidden via xhtml" | |
end | |
end | |
def be_hidden | |
BeHidden.new(self) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment