dwyl / learn-elixir

:droplet: Learn the Elixir programming language to build functional, fast, scalable and maintainable web applications!
1.62k stars 109 forks source link

Update first project in README for Elixir v1.9 #133

Closed iteles closed 5 years ago

iteles commented 5 years ago

I currently have Elixir v1.9 installed and as I go through the first project, I'm catching a few things that have been updated in elixir since the README was written.

They're very minor but may throw off complete beginners!

iteles commented 5 years ago
  1. In the initial output after mix new <project-name> is now:

    * creating README.md
    * creating .formatter.exs
    * creating .gitignore
    * creating mix.exs
    * creating lib
    * creating lib/animals.ex
    * creating test
    * creating test/test_helper.exs
    * creating test/animals_test.exs
  2. The example in the boilerplate lib/animals.ex is now:

    ## Examples
    
      iex> Animals.hello()
      :world
iteles commented 5 years ago

For the first project code this was kind of it 😄 Not really tinkering with the basics in version iterations 😉

Added one or two clarifications to the readme for good measure.

Moving onto the Documentation section and beyond.

iteles commented 5 years ago

Updating the version of ex_doc installed to 0.21 because there's no reason not to for the sake of this simple initial tutorial.

defp deps do
  [
    {:ex_doc, "~> 0.21"}
  ]
end

image

iteles commented 5 years ago

Onto Testing

The boiler plate for this has also changed to:

defmodule AnimalsTest do
  use ExUnit.Case
  doctest Animals

  test "greets the world" do
    assert Animals.hello() == :world
  end
end
iteles commented 5 years ago

It wasn't until I ran mix test that I realised why some Examples were missing from the animals.exs file removed in this commit: https://github.com/dwyl/learn-elixir/commit/748ce190742a53973821b637624c1d12680879f2

I'm assuming now it's because the doctest for this will often fail based on the example.

I imagine that rather than doing this, we'll want to alert people in the readme that because of the dotests, they should remove examples from functions like this to test them well?

iteles commented 5 years ago

Onto formatting

Aside from #136 which I have created as a separate question:

When you create a new project in Elixir 1.9, the .formatter.exs file is now created by default with the following code:

# Used by "mix format"
[
  inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]

This means we no longer need to create it ourselves, so we need to update the readme accordingly: image

iteles commented 5 years ago

Moved PR to review as I've finished going over the first project 'section' (generating the project, basic functions, docs, testing, formatting and publishing) with which this issue is concerned.

Further issues to be opened for the rest if relevant.

iteles commented 5 years ago

PR #135 merged.