Skip to content

Instantly share code, notes, and snippets.

@cheezy
Created March 27, 2012 00:33
Show Gist options
  • Save cheezy/2211029 to your computer and use it in GitHub Desktop.
Save cheezy/2211029 to your computer and use it in GitHub Desktop.
RSpec::Matchers.define :have_element_named do |expected|
match do |page|
page.respond_to?("#{expected.to_s}_element") and page.send "#{expected.to_s}?"
end
failure_message_for_should do |page|
"Expected the page to have an element named '#{expected.to_s}'"
end
failure_message_for_should_not do |page|
"Expected the page to not have an element named '#{expected.to_s}'"
end
end
Can be used like this:
page.should have_element_named :continue
where
link(:continue, :id => 'some_id')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment