parsley/spec/models/ingredient_unit_spec.rb

31 lines
715 B
Ruby

require 'rails_helper'
RSpec.describe IngredientUnit, type: :model do
describe 'matches?' do
it 'matches empty units to each-like terms' do
each_terms = [
'Each',
'each',
'ech',
'item',
'per',
'PER',
'Per'
]
each_terms.each do |t|
expect(create(:ingredient_unit, name: t).matches?('')).to eq(true), "expected #{t} to match"
end
end
it 'matches unit names' do
expect(create(:ingredient_unit, name: 'Clove').matches?('clove')).to eq true
end
it 'matches pluralized unit names' do
expect(create(:ingredient_unit, name: 'Clove').matches?('cloves')).to eq true
end
end
end