Created
March 4, 2010 14:57
-
-
Save lukeredpath/321764 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def assert_select_elements_in_order(selector, values, options={}) | |
| options.reverse_merge!(:starting_from_index => 1) | |
| values.each_with_index do |value, index| | |
| position = options[:starting_from_index] + index | |
| assert_select "#{selector}:nth-of-type(#{position})", value, | |
| "Expected value at #{selector}:(n=#{position}) to be #{value}" | |
| end | |
| end | |
| # <ul id="list"> | |
| # <li>Foo</li> | |
| # <li>Bar</li> | |
| # <li>Baz</li> | |
| # </ul> | |
| # | |
| # assert_select_elements_in_order("#list li", %w{Foo Bar Baz}) | |
| # | |
| # <ul id="list"> | |
| # <li>Not relevant</li> | |
| # <li>Foo</li> | |
| # <li>Bar</li> | |
| # <li>Baz</li> | |
| # </ul> | |
| # | |
| # assert_select_elements_in_order("#list li", %w{Foo Bar Baz}, :starting_at_index => 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment