require "spec" require "../src/josie-health-lut" describe JosieHealth::LUT::AlcoholLUT do describe ".default_serving_for" do it "returns can for beer" do JosieHealth::LUT::AlcoholLUT.default_serving_for("heineken").should eq("can") end it "returns can for seltzer" do JosieHealth::LUT::AlcoholLUT.default_serving_for("whiteclaw").should eq("can") end it "returns can for cider" do JosieHealth::LUT::AlcoholLUT.default_serving_for("strongbow").should eq("can") end it "returns glass for wine" do JosieHealth::LUT::AlcoholLUT.default_serving_for("wine").should eq("glass") end it "returns shot for spirits" do JosieHealth::LUT::AlcoholLUT.default_serving_for("vodka").should eq("shot") end it "returns shot for liqueur" do JosieHealth::LUT::AlcoholLUT.default_serving_for("jager").should eq("shot") end it "returns nil for cocktail" do JosieHealth::LUT::AlcoholLUT.default_serving_for("mojito").should be_nil end it "returns nil for unknown brand" do JosieHealth::LUT::AlcoholLUT.default_serving_for("notabrand").should be_nil end end describe "whiteclaw and truly brands" do it "looks up whiteclaw" do brand = JosieHealth::LUT::AlcoholLUT.lookup_brand("whiteclaw") brand.should_not be_nil brand.not_nil![:abv].should eq(5.0) brand.not_nil![:category].should eq("seltzer") brand.not_nil![:default_ml].should eq(355) end it "looks up truly" do brand = JosieHealth::LUT::AlcoholLUT.lookup_brand("truly") brand.should_not be_nil brand.not_nil![:abv].should eq(5.0) brand.not_nil![:category].should eq("seltzer") brand.not_nil![:default_ml].should eq(355) end end describe "seltzer category defaults" do it "has seltzer in CATEGORY_DEFAULTS" do defaults = JosieHealth::LUT::AlcoholLUT::CATEGORY_DEFAULTS["seltzer"]? defaults.should_not be_nil defaults.not_nil![:abv].should eq(5.0) defaults.not_nil![:default_ml].should eq(355) end end end describe JosieHealth::LUT::CaffeineLUT do describe ".default_serving_for" do it "returns can for energy drinks" do JosieHealth::LUT::CaffeineLUT.default_serving_for("monster").should eq("can") end it "returns cup for coffee" do JosieHealth::LUT::CaffeineLUT.default_serving_for("coffee").should eq("cup") end it "returns cup for tea" do JosieHealth::LUT::CaffeineLUT.default_serving_for("tea").should eq("cup") end it "returns can for soda" do JosieHealth::LUT::CaffeineLUT.default_serving_for("coke").should eq("can") end it "returns nil for unknown brand" do JosieHealth::LUT::CaffeineLUT.default_serving_for("notabrand").should be_nil end end end describe JosieHealth::LUT do describe ".alcohol_default_serving" do it "delegates to AlcoholLUT" do JosieHealth::LUT.alcohol_default_serving("whiteclaw").should eq("can") end end describe ".caffeine_default_serving" do it "delegates to CaffeineLUT" do JosieHealth::LUT.caffeine_default_serving("monster").should eq("can") end end end