【发布时间】:2016-06-01 19:25:55
【问题描述】:
我有这样的错误。这是我的代码:
it "shows places sorted by date of creation" do
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
我的问题是这里的点击链接必须发送参数:
“?by_created_at: true”和控制器响应,按创建日期排序,按后代顺序排列。
我的问题是当水豚点击这个链接时,GET 请求只有路径,不需要参数。我在这里使用 poltergeist。
我也有这样的测试:
it "shows orders today" do
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
它测试出类似的行为。它工作正常,但这里我没有使用js。 是javascript驱动问题吗? 谢谢。抱歉文字不好,这是我的第一个问题。
【问题讨论】:
-
谢谢大家,我的问题在于 FactoryGirl 生成的记录具有相同的 created_at 字段
标签: ruby-on-rails rspec capybara integration-testing poltergeist