parsley/spec/models/ingredient_spec.rb

38 lines
643 B
Ruby
Raw Normal View History

2016-01-12 18:43:00 -06:00
require 'rails_helper'
RSpec.describe Ingredient, type: :model do
2016-01-14 15:22:15 -06:00
describe 'validation' do
it 'validates density' do
i = build(:ingredient)
expect(i).to be_valid
i.density = '5'
expect(i).not_to be_valid
i.density = '5 cup'
expect(i).not_to be_valid
i.density = '5 gram/cup'
expect(i).to be_valid
i.density = '5 mile/hour'
expect(i).not_to be_valid
end
end
describe 'set_usda_food' do
it 'sets the density' do
i = build(:ingredient)
f = create(:salted_butter)
i.set_usda_food(f)
expect(i.density).not_to be_nil
end
end
2016-01-12 18:43:00 -06:00
end