Created
May 9, 2012 15:35
-
-
Save alext/2645615 to your computer and use it in GitHub Desktop.
Section helper for rspec request specs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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