lib/spreewald/web_steps.rb in spreewald-1.1.2 vs lib/spreewald/web_steps.rb in spreewald-1.2.0

- old
+ new

@@ -664,11 +664,11 @@ authorizer.basic_authorize(user, password) visit path end end -# Go to the previously viewed page. +# Goes to the previously viewed page. When /^I go back$/ do case Capybara::current_driver when :selenium, :webkit page.evaluate_script('window.history.back()') else @@ -676,6 +676,16 @@ visit page.driver.browser.last_request.env['HTTP_REFERER'] else visit page.driver.last_request.env['HTTP_REFERER'] end end +end + +# Tests whether a select field is sorted. Uses Array#natural_sort, if defined; +# Array#sort else. +Then /^the "(.*?)" select should( not)? be sorted$/ do |label, negate| + select = find_field(label) + options = select.all('option').reject { |o| o.value.blank? } + option_texts = options.collect(&:text) + + option_texts.send((negate ? :should_not : :should), be_sorted) end