Skip to content

Commit eff969d

Browse files
Howard M. MillerHoward M. Miller
authored andcommitted
Streamline capybara matchers for system/supervisors/index_spec
1 parent 1258e01 commit eff969d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

spec/system/supervisors/index_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,9 @@
360360
no_active_contact_element = supervisor_stats.find("span.no-attempted-contact")
361361

362362
expect(active_contact_element).to have_text(active_contacts_expected)
363-
expect(active_contact_element.has_css?("pr-#{active_contacts_expected * 15}"))
363+
expect(active_contact_element).to match_css(".pr-#{active_contacts_expected * 15}")
364364
expect(no_active_contact_element).to have_text(no_active_contacts_expected)
365-
expect(no_active_contact_element.has_css?("pl-#{no_active_contacts_expected * 15}"))
365+
expect(no_active_contact_element).to match_css(".pl-#{no_active_contacts_expected * 15}")
366366
expect(supervisor_stats.find(".status-btn.deactive-bg")).to have_text(transition_aged_youth_expected)
367367
end
368368

@@ -378,9 +378,9 @@
378378
no_active_contact_element = supervisor_stats.find("span.no-attempted-contact")
379379

380380
expect(active_contact_element).to have_text(active_contacts_expected)
381-
expect(active_contact_element.has_css?("pr-#{active_contacts_expected * 15}"))
381+
expect(active_contact_element).to match_css(".pr-#{active_contacts_expected * 15}")
382382
expect(no_active_contact_element).to have_text(no_active_contacts_expected)
383-
expect(no_active_contact_element.has_css?("pl-#{no_active_contacts_expected * 15}"))
383+
expect(no_active_contact_element).to match_css(".pl-#{no_active_contacts_expected * 15}")
384384
expect(supervisor_stats.find(".status-btn.deactive-bg")).to have_text(transition_aged_youth_expected)
385385
end
386386

@@ -393,10 +393,10 @@
393393
transition_aged_youth_expected = 3
394394
active_contact_element = supervisor_stats.find("span.attempted-contact")
395395

396-
expect { supervisor_stats.find("span.no-attempted-contact") }.to raise_error(Capybara::ElementNotFound)
397396
expect(active_contact_element).to have_text(active_contacts_expected)
398-
expect(active_contact_element.has_css?("pl-#{active_contacts_expected * 15}"))
397+
expect(active_contact_element).to match_css(".pl-#{active_contacts_expected * 15}")
399398
expect(supervisor_stats.find(".status-btn.deactive-bg")).to have_text(transition_aged_youth_expected)
399+
expect(supervisor_stats).not_to have_css("span.no-attempted-contact")
400400
end
401401

402402
it "shows the correct element for a supervisor with only no contact volunteers", :js do
@@ -408,11 +408,11 @@
408408
transition_aged_youth_expected = 2
409409
no_contact_element = supervisor_stats.find("span.no-attempted-contact")
410410

411-
expect { supervisor_stats.find("span.attempted-contact") }.to raise_error(Capybara::ElementNotFound)
412-
expect { supervisor_stats.find("span.attmepted-contact-end") }.to raise_error(Capybara::ElementNotFound)
413411
expect(no_contact_element).to have_text(no_contacts_expected)
414-
expect(no_contact_element.has_css?("pl-#{no_contacts_expected * 15}"))
412+
expect(no_contact_element).to match_css(".pl-#{no_contacts_expected * 15}")
415413
expect(supervisor_stats.find(".status-btn.deactive-bg")).to have_text(transition_aged_youth_expected)
414+
expect(supervisor_stats).not_to have_css("span.attempted-contact")
415+
expect(supervisor_stats).not_to have_css("span.attempted-contact-end")
416416
end
417417

418418
it "shows the correct text with a supervisor with no assigned volunteers", :js do
@@ -422,7 +422,7 @@
422422
supervisor_no_volunteer_stats = page.find("tr#supervisor-#{no_active_volunteers_supervisor.id}-information")
423423
expect(supervisor_no_volunteer_stats).to have_text("No assigned volunteers")
424424
expect(supervisor_no_volunteer_stats.find("span.no-volunteers")).to be_truthy
425-
expect(supervisor_no_volunteer_stats.find("span.no-volunteers").style("flex-grow")).to eq({"flex-grow" => "1"})
425+
expect(supervisor_no_volunteer_stats.find("span.no-volunteers").style("flex-grow")).to eq({ "flex-grow" => "1" })
426426
end
427427
end
428428
end

0 commit comments

Comments
 (0)