ruby on rails - Capybara click_link works wrong -
i have such bug. here code:
it "shows places sorted date of creation" click_button( i18n.t("models.places.actions.index.sort_by")) click_link(i18n.t("models.places.actions.index.date_of_creation")) sorted_places_names = places.map(&:name).reverse link_names = all("a.place-link").map(&:text) expect(link_names).to eq(sorted_places_names) end
and problem click link here must send params: "?by_created_at: true
" , controller response sorted places date of creation, in descendant order. problem when capybara clicks on link, request have path, without params needed.i`m using poltergeist here.
also have such test:
it "shows orders today" today_order.customer.reputations << create(:reputation, place: place) visit place_statistics_loyalty_path(place) click_link(i18n.t("statistics.loyalty.today")) expect(page).to have_selector("#order_#{today_order.id}") end
it tests out similar behaviour. , works properly, here not using js. javascript driver problem ? thanks. sorry bad text, it`s first question.
what you're looking use poltergeist's "send_key" method shown here in documentation:
https://github.com/teampoltergeist/poltergeist#sending-keys
setting keys using method , proceeding clicking link should work.