I have created a simple Rspec test to verfiy if a model created has been deleted. However, the test fails because the model still exists. Can anyone provide any assistance on how to determine if the record was actually deleted?
RSpec.describe Person, type: :model do
let(:person) {
Person.create(
name: "Adam",
serial_number: "1"
)
}
it "destroys associated relationships when person destroyed" do
person.destroy
expect(person).to be_empty()
end
end
expect { person.reload }.to raise_error(ActiveRecord::RecordNotFound)
instead ofexpect(person.reload).to raise_error(ActiveRecord::RecordNotFound)
– Undersurface