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

johnp
Running the examples in chapter 5 c under pytest 5.4.1 causes an AttributeError: ‘module’ object has no attribute ‘config’. In particula...
New
jdufour
Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
leonW
I ran this command after installing the sample application: $ cards add do something --owner Brian And got a file not found error: Fil...
New
jskubick
I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
EdBorn
Title: Agile Web Development with Rails 7: (page 70) I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. http://f...
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
foxtrottwist
Here’s our thread for the Keyboardio Atreus. It is a mechanical keyboard based on and a slight update of the original Atreus (Keyboardio ...
New
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New

Latest in PragProg

View all threads ❯