Skip to content

Instantly share code, notes, and snippets.

@phinze
Created November 10, 2009 16:56
Show Gist options
  • Save phinze/231032 to your computer and use it in GitHub Desktop.
Save phinze/231032 to your computer and use it in GitHub Desktop.
# 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