parsley/spec/models/food_unit_spec.rb

31 lines
691 B
Ruby
Raw Normal View History

2016-07-05 16:31:36 -05:00
require 'rails_helper'
2018-09-11 10:38:07 -05:00
RSpec.describe FoodUnit, type: :model do
2016-07-05 16:31:36 -05:00
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|
2018-09-11 10:38:07 -05:00
expect(create(:food_unit, name: t).matches?('')).to eq(true), "expected #{t} to match"
2016-07-05 16:31:36 -05:00
end
end
it 'matches unit names' do
2018-09-11 10:38:07 -05:00
expect(create(:food_unit, name: 'Clove').matches?('clove')).to eq true
2016-07-05 16:31:36 -05:00
end
it 'matches pluralized unit names' do
2018-09-11 10:38:07 -05:00
expect(create(:food_unit, name: 'Clove').matches?('cloves')).to eq true
2016-07-05 16:31:36 -05:00
end
end
end