phase002 complete
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe FuelEntry do
|
||||
it "has a valid factory" do
|
||||
expect(build(:fuel_entry)).to be_valid
|
||||
end
|
||||
|
||||
it "requires all fields" do
|
||||
entry = build(
|
||||
:fuel_entry,
|
||||
vehicle: nil,
|
||||
updated_by_user: nil,
|
||||
odometer: nil,
|
||||
gallons_pumped: nil,
|
||||
price_paid: nil,
|
||||
date: nil
|
||||
)
|
||||
|
||||
expect(entry).not_to be_valid
|
||||
expect(entry.errors.attribute_names).to include(:vehicle, :updated_by_user, :odometer, :gallons_pumped, :price_paid, :date)
|
||||
end
|
||||
|
||||
it "requires valid numeric values" do
|
||||
entry = build(:fuel_entry, odometer: -1, gallons_pumped: 0, price_paid: 0)
|
||||
|
||||
expect(entry).not_to be_valid
|
||||
expect(entry.errors[:odometer]).to be_present
|
||||
expect(entry.errors[:gallons_pumped]).to be_present
|
||||
expect(entry.errors[:price_paid]).to be_present
|
||||
end
|
||||
|
||||
it "rejects future dates" do
|
||||
entry = build(:fuel_entry, date: Date.current + 1.day)
|
||||
|
||||
expect(entry).not_to be_valid
|
||||
expect(entry.errors[:date]).to be_present
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user