I'm running the test using bundle exec rspec
, which gives me the error of:
WARN: Screenshot could not be saved. page.current_path is empty
.
also getting this error:
1) adding a new task can re-order a task
Failure/Error: expect(page).to have_selector(".name", text: "Take Notes")
expected to find visible css ".name" with text "Take Notes" within #
<Capybara::Node::Element tag="tr" path="/HTML/BODY[1]/TABLE[1]/TBODY[1]/TR[2]"> but there were
no matches. Also found "Use Telescope", which matched the selector but not all filters.
Ruby: 2.7.2 Rails: 6.0.3.4
After the following test, I got the error.
Here's the test I'm trying to test:
/spec/system/add_task_spec.rb
require "rails_helper"
RSpec.describe "adding a new task" do
let!(:project) { create(:project, name: "Project Bluebook") }
let!(:task_1) { create(
:task, project: project, title: "Search Sky", size: 1, project_order: 1) }
let!(:task_2) { create(
:task, project: project, title: "Use Telescope", size: 1,
project_order: 2) }
let!(:task_3) { create(
:task, project: project, title: "Take Notes", size: 1,
project_order: 3) }
it "can re-order a task", :js do
visit(project_path(project))
find("#task_3")
within("#task_3") do
click_on("Up")
end
expect(page).to have_selector(
"tbody:nth-child(2) .name", text: "Take Notes")
#END:P1
#START:P2
visit(project_path(project))
find("#task_2")
within("#task_2") do
expect(page).to have_selector(".name", text: "Take Notes")
end
end
end
I resolved the error by changing the test like this:
it "can re-order a task" do
visit(project_path(project))
find("#task_3")
within("#task_3") do
click_on("Up")
end
expect(page).to have_selector("tbody:nth-child(2) .name", text: "Take Notes")
visit(project_path(project))
within("#task_2") do
expect(page).to have_selector(".name", text: "Use Telescope")
end
end