The handy method has_select?(field, :selected => text)
does not behave as expected with Cucumber 0.10.2, Capybara 0.4.1.2 and Selenium 0.2.2. It may not recognize a select field if the selected option
with the text
has no value. If you don't have the possibility to upgrade these Gems, probably the best way to go is to distinguish the current Capybara driver:
Then /^"([^"]*)" should be selected for "([^"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
with_scope(selector) do
# currently needed due to different behaviour of Capybara drivers
if page.driver.class.name == "Capybara::Driver::RackTest"
xpath_field = find_field(field)
selected_option = xpath_field.find(:xpath, "option[@selected='selected']") rescue nil
selected_option ||= xpath_field.find(:xpath, 'option')
selected_option.text.should == value
else
page.should have_select(field, :selected => value)
end
end
end
Posted by Dominik Schöler to makandra dev (2012-02-23 10:09)