- Crie um novo arquivo em
spec/support
/
# spec/support/select_from_chosen.rb
module SelectFromChosen
# select_from_chosen('Option', from: 'id_of_field')
def select_from_chosen(item_text, options)
field = find_field(options[:from], :visible => false)
find("##{field[:id]}_chosen").click
find("##{field[:id]}_chosen ul.chosen-results li", :text => item_text).click
end
end
- Inclua o módulo na configuração Rspec para recursos:
# spec/rails_helper.rb
RSpec.configure do |config|
config.include SelectFromChosen, type: :feature
end
- Uso no cenário:
select_from_chosen('Option', from: 'id_of_field')