Skip to content

Commit

Permalink
Reliable way to check a path with Capybara
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobm committed Oct 26, 2024
1 parent 4efb849 commit 7aad39c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions spec/features/index_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
visit admin_customers_path
click_on "Edit"

expect(current_path).to eq(edit_admin_customer_path(customer))
expect(page).to have_current_path(edit_admin_customer_path(customer))
end

it "links to the new page" do
visit admin_customers_path
click_on("New customer")

expect(current_path).to eq(new_admin_customer_path)
expect(page).to have_current_path(new_admin_customer_path)
end

it "displays translated labels" do
Expand Down
4 changes: 2 additions & 2 deletions spec/features/log_entries_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
visit admin_log_entries_path
click_on t("administrate.actions.edit")

expect(current_path).to eq(edit_admin_log_entry_path(log_entry))
expect(page).to have_current_path(edit_admin_log_entry_path(log_entry))
end

scenario "user clicks through to the new page" do
visit admin_log_entries_path
click_on("New log entry")

expect(current_path).to eq(new_admin_log_entry_path)
expect(page).to have_current_path(new_admin_log_entry_path)
end

scenario "user deletes record", js: true do
Expand Down
4 changes: 2 additions & 2 deletions spec/features/orders_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
visit admin_orders_path
click_on t("administrate.actions.edit")

expect(current_path).to eq(edit_admin_order_path(order))
expect(page).to have_current_path(edit_admin_order_path(order))
end

scenario "user clicks through to the new page" do
visit admin_orders_path
click_on("New order")

expect(current_path).to eq(new_admin_order_path)
expect(page).to have_current_path(new_admin_order_path)
end

scenario "user deletes record", js: true do
Expand Down
6 changes: 3 additions & 3 deletions spec/features/products_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

expect(page).to have_content(product.name)
expect(page).to have_content(product.description)
expect(current_path).to eq(admin_product_path(product))
expect(page).to have_current_path(admin_product_path(product))
end

it "links to the edit page" do
Expand All @@ -28,14 +28,14 @@
visit admin_products_path
click_on "Edit"

expect(current_path).to eq(edit_admin_product_path(product))
expect(page).to have_current_path(edit_admin_product_path(product))
end

it "links to the new page" do
visit admin_products_path
click_on("New product")

expect(current_path).to eq(new_admin_product_path)
expect(page).to have_current_path(new_admin_product_path)
end

scenario "product sorted by has_one association" do
Expand Down

0 comments on commit 7aad39c

Please sign in to comment.