taguniversalmachine

taguniversalmachine

Real-Time Phoenix: ProductChannelTest - undefined function describe/2 (pg 203)

Hi,

I am getting an error I cannot figure out on my test.
I have what I think is the exact code from the book, other than I changed “use” to “import” to fix a deprecation warning:

defmodule Sneakers23Web.ProductChannelTest do

  #use Sneakers23Web.ChannelCase, async: true
  import Sneakers23Web.ChannelCase
  alias Sneakers23Web.{Endpoint, ProductChannel}
  alias Sneakers23.Inventory.CompleteProduct

  describe "notify product released" do
    test "the size selector for the product is broadcast" do
      {inventory, _data} = Test.Factory.InventoryFactory.complete_products()
      [_, product] = CompleteProduct.get_complete_products(inventory)

      topic = "product:#{id}"
      Endpoint.subscribe(topic)

      ProductChannel.notify_product_released(product)

      assert_broadcast "released", %{size_html: html}

      assert html =~ "size-container__entry"

      Enum.each(product.items, fn item ->
        assert html =~ ~s(value="#{item.id}")
      end)
    end
  end
end

The error I get is:

sneakers_23 % mix test

12:57:13.705 [info] Migrations already up

== Compilation error in file test/sneakers_23_web/product_channel_test.exs ==
** (CompileError) test/sneakers_23_web/product_channel_test.exs:8: undefined function describe/2
(stdlib 3.15.2) erl_eval.erl:685: :erl_eval.do_apply/6
(elixir 1.12.1) lib/kernel/parallel_compiler.ex:428: Kernel.ParallelCompiler.require_file/2
(elixir 1.12.1) lib/kernel/parallel_compiler.ex:321: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7

I can imagine why describe would not show up if I am not importing the right test module, but why is it saying I have describe/2 when I am clearly only giving it one argument? Changing import back to use doesn’t fix anything either.

Marked As Solved

sb8244

sb8244

Author of From Ruby to Elixir and Real-Time Phoenix

Ah, that’s due to the Erlang version. You are right to upgrade it if you’re following with other books.

I’m unsure of the problem you’re facing because changed the use to import in channel_case.ex but no difference is not correct. When you change from use to import there, that warning will disappear.

I’m unable to provide updated code for the book because that has to go through a process with the publisher. I’m willing to evaluate my options for providing a code-update, but I need to get their thoughts here.

What about this: you upload your warning code (not the one with :pg2 failing) to Github and I’ll update it to work with latest Erlang/Elixir without warnings. I cannot do every chapter’s code, but I can do it for the current code you’re stuck on. It is likely something you can then apply to other chapters.

Popular Prag Prog topics Top

jimmykiang
This test is broken right out of the box… — FAIL: TestAgent (7.82s) agent_test.go:77: Error Trace: agent_test.go:77 agent_test.go:...
New
curtosis
Running mix deps.get in the sensor_hub directory fails with the following error: ** (Mix) No SSH public keys found in ~/.ssh. An ssh aut...
New
dsmith42
Hey there, I’m enjoying this book and have learned a few things alredayd. However, in Chapter 4 I believe we are meant to see the “>...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New
s2k
Hi all, currently I wonder how the Tailwind colours work (or don’t work). For example, in app/views/layouts/application.html.erb I have...
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New
a.zampa
@mfazio23 I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
New
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New

Other popular topics Top

PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New

Latest in PragProg

View all threads ❯