Skip to content

Instantly share code, notes, and snippets.

@wesgibbs
Created November 9, 2010 11:25
Show Gist options
  • Save wesgibbs/668982 to your computer and use it in GitHub Desktop.
Save wesgibbs/668982 to your computer and use it in GitHub Desktop.
# web_custom_steps.rb
module ClassMatcher
def contains_class(css_class)
"contains(concat(' ',normalize-space(@class),' '),' #{css_class} ')"
end
end
World(ClassMatcher)
# example step
Then /^I should see only one block for ([^\"]*) on ([^\"]*)$/ do |time, day|
time = Time.parse(time)
page.should have_xpath(%|//div[#{contains_class(day.parameterize)}]/div[#{contains_class(time.to_s(:hmm))}]|, :count => 1)
end
# credit to http://pivotallabs.com/users/alex/blog/articles/427-xpath-css-class-matching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment