Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMcFadden Gavender
4,893 PointsError when running destroy test
require 'spec_helper'
describe "Destroy medication reminder" do
medication_reminders = MedicationReminder.create(medication: "My Medication Name")
it "Destroys the medication reminder if successful" do
visit "/medication_reminders"
within "#medication_reminder_#{medication_reminders.id}" do
click_link "Destroy"
end
expect(page).to_not have_content(medication_reminder.medication)
expect(MedicationReminder.count).to eq (0)
end
end
My scaffold was created with the name 'medication_reminders'. Can't quite figure out why the test is failing. It appears to be failing at the 'to_not have_content' portion of the code.
3 Answers
Max Alexander
7,258 PointsJust going to throw an answer out there, if it's not helping just ignore me!
Currently you have typed in medication_reminder, but everywhere else you have it as medication_reminders
expect(page).to_not have_content(medication_reminder.medication)
It could be a simple spelling mistake? The following example has fixed the spelling error.
expect(page).to_not have_content(medication_reminders.medication)
Jim Withington
12,025 PointsI'm pretty new at this, but I wonder: do you need a line of code that includes a reload in order to check if the content is gone?
Maciej Czuchnowski
36,441 PointsTry removing the space after eq
in this line:
expect(MedicationReminder.count).to eq (0)
so it should look like this:
expect(MedicationReminder.count).to eq(0)
Maciej Czuchnowski
36,441 PointsBy the way, if this doesn't help, please paste your error here. It will help a lot in pinpointing the cause :)
McFadden Gavender
4,893 PointsMcFadden Gavender
4,893 PointsThat was it! Big thanks!
McFadden Gavender
4,893 PointsMcFadden Gavender
4,893 PointsThat was it! Big thanks!
McFadden Gavender
4,893 PointsMcFadden Gavender
4,893 PointsThat was it! Big thanks!
Max Alexander
7,258 PointsMax Alexander
7,258 PointsNo problem Jeremy! Glad to help :)