Skip to content

Instantly share code, notes, and snippets.

@alext
Created May 9, 2012 15:35
Show Gist options
  • Save alext/2645615 to your computer and use it in GitHub Desktop.
Save alext/2645615 to your computer and use it in GitHub Desktop.
Section helper for rspec request specs
module SectionHelper
def selector_of_section(section_name)
case section_name
when 'recent podcasts'
[:css, 'ul.podcasts']
when /^the row containing "[\"]+"$/
[:xpath, "//*[.='#{$1}']/ancestor::tr"]
else
raise "Can't find mapping from \"#{section_name}\" to a section."
end
end
def within_section(section_name)
within *selector_of_section(section_name) do
yield
end
end
end
RSpec.configuration.include SectionHelper, :type => :request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment