Skip to content

Instantly share code, notes, and snippets.

View mreigen's full-sized avatar

Minh Reigen mreigen

  • Orange County / Los Angeles
View GitHub Profile
describe "make_dish_from_left_over" do
context "with dishes that are served cold" do
# before: set up cold dishes
# ...
# end
context "seasoning available" do
# before: set up seasoning
# ...
# end
expect(add_seasoning).to be_truthy
defp setup_cold_dishes(context) do
temp = 35
size = if context.size, do: size, else: :small
dish = set_temperature(temp)
|> set_size(size)
|> set_time_in_fridge(:15_hours)
|> build_dish
%{temp: temp, size: size, cold_dish: dish}
end
defp setup_cold_dish(%{size: size}) do
end
describe "make COLD dishes from left over" do
setup [:setup_cold_dish]
test "", context do
...
end
end
describe "make COLD dishes from left over when seasoning available" do
setup [:setup_cold_dish, :set_seasoning]
test "", context do
assert add_seasoning
end
end
describe "make COLD dishes when seasoning available" do
setup [:setup_cold_dish, :set_seasoning]
test "", context do
assert add_seasoning
end
end
describe "make COLD dishes when extra protein available" do
setup [:setup_cold_dish, :set_protein]
test "", context do
def pp(what_to_print, debug_message \\ "") do
IO.puts("#{IO.ANSI.yellow()} START #{debug_message} ====================")
IO.puts(IO.ANSI.yellow() <> inspect(what_to_print, pretty: true, limit: :infinity))
IO.puts("#{IO.ANSI.yellow()} END #{debug_message} ====================\n\n")
what_to_print
end
import Ecto.Query
...
from(store in Store,
where: fragment("NOT EXISTS (SELECT * FROM APPLIANCES item WHERE item.store_id == ? AND item.name == 'VCR player')", store.id),
where: fragment("NOT EXISTS (SELECT * FROM GAME_CONSOLES item WHERE item.store_id == ? AND item.name == 'Sega Genesis console')", store.id)
)
import Ecto.Query
...
from(store in Store,
where: fragment("NOT EXISTS (SELECT * FROM APPLIANCES item WHERE item.store_id == ? AND item.name == 'VCR player')", store.id),
where: fragment("NOT EXISTS (SELECT * FROM GAME_CONSOLES item WHERE item.store_id == ? AND item.name == 'Sega Genesis console')", store.id),
where: fragment("NOT EXISTS (SELECT * FROM DELIVERY_TRUCKS truck WHERE truck.store_id == ?)", store.id)
)
import Ecto.Query
...
defmacro store_items_not_exist(store_items_table_name, store_id, item_name) do
args = [
"NOT EXISTS (SELECT * FROM #{store_items_table_name} item WHERE item.store_id = ? AND item.name == ?)",
store_id,
item_name
]