Skip to content

Instantly share code, notes, and snippets.

@rubysolo
Created December 7, 2010 22:08
Show Gist options
  • Select an option

  • Save rubysolo/732523 to your computer and use it in GitHub Desktop.

Select an option

Save rubysolo/732523 to your computer and use it in GitHub Desktop.
module ResponseHelpers
def response_dom
html = response.try(:body) || page.try(:body)
$stderr.puts "WARNING: No response HTML!" if html.blank?
Nokogiri::HTML(html)
end
end
World(ResponseHelpers)
Then /^"([^\"]*)" should be disabled$/ do |element|
e = response_dom.search("//input[@id='#{ element }']").first ||
response_dom.search("//input[@name='#{ element }']").first ||
response_dom.search("//input[contains(@value, '#{ element }')]")
if defined?(Spec::Rails::Matchers)
e.should_not be_nil
e.attr('disabled').to_s.should eql('disabled')
else
assert_not_nil e
assert_equal 'disabled', e.attr('disabled').to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment