diaspora/features/step_definitions/scope_steps.rb
Stephen Caudill 8a93c67166 Add the Hashrocket default step definitions
Tweaked for mongomapper and diaspora
2010-09-26 11:35:50 -04:00

30 lines
672 B
Ruby

module SectionLocator
def within_parent(content, elements = ['*'], &block)
expr = %(//*[(#{elements.join('|')})/descendant-or-self::*[contains(., "#{content}")]])
within(expr, &block)
end
end
World(SectionLocator)
sections = %w(h1 h2 h3 h4 h5 h6 legend caption dt strong)
When /^(.*) in the "([^\"]*)" section$/ do |action, title|
within_parent(title, sections) do
When action
end
end
When /^(.*) in the "([^\"]*)" section:$/ do |action, title, table|
within_parent(title, sections) do
When "#{action}:", table
end
end
When /^(.*) in the "([^\"]*)" row$/ do |action, title|
within_parent(title, %w(th td)) do
When action
end
end