require 'rails_helper'
require 'usda_importer'

RSpec.describe UsdaImporter do

  it 'imports' do
    i = UsdaImporter.new(Rails.root.join('spec', 'test_data'))
    i.import

    expect(UsdaFood.count).to eq 5
    butter = UsdaFood.where(ndbn: '01001').first
    expect(butter).not_to be_nil
    expect(butter.usda_food_weights.count).to eq 4

    clif_bar = UsdaFood.where(ndbn: '45042066').first
    expect(clif_bar).not_to be_nil
    expect(clif_bar.usda_food_weights.count).to eq 1
    expect(clif_bar.kcal).to eq 368
  end

end
