Skip to content

Commit

Permalink
feat: update first chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
pmareke committed Oct 7, 2023
1 parent 6ac99c0 commit 9d80383
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
14 changes: 10 additions & 4 deletions content.en/docs/before-start/install-minitest.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,32 @@ weight: 4

# Install Minitest

For this book we're going to use [Minitest](https://github.com/minitest/minitest),
this testing tool was added to Ruby’s standard library.
For this book we're going to use [Minitest](https://github.com/minitest/minitest)
as the testing framerwork. There are another alternatives like `RSpec` but for the
sake of simplicity I prefer to use Minitest.

## How to install Minitest

In order to add a new library in our project we just need to add them in the `Gemfile` file:

```sh
# Gemfile
source "https://rubygems.org"

gem "minitest"
```

After that we need to install it using the following command:

```sh
bundle install
```
If everything works fine now we're in a position to create our first test.

## Validate Minitest is installed

Once you have Minitest installed you need to create
a new file called `test_foo.rb` with the following code
a new file called `test_foo.rb` inside the `src` folder with the following code
(*right now don't care about it!*):

```ruby
Expand All @@ -39,7 +45,7 @@ end
Save the file and run the following command in the terminal:

```sh
ruby test_foo.rb
ruby tests/test_foo.rb
```

You should see something like these results:
Expand Down
20 changes: 18 additions & 2 deletions content.en/docs/before-start/prepare-the-book.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,35 @@ weight: 3

# Prepare the project for this book

Once we have Ruby installed we need to create the folders
structure in which weŕe going to write the code for each
chapter.


## Create the folder for the chapters and its tests

To do so, we need to create a couple of folders with the
following command:

```sh
mkdir tests src
```

## Create a new Ruby project

After that we're in position of creating the project using Bundler.

To do it, just run the following command in the terminal:

```sh
bundle init
```
This command will create a new file called `Gemfile` in which we're
going to add in the future all the dependecies (like `minitest`).

```sh
# Gemfile
# frozen_string_literal: true

source "https://rubygems.org"

# gem "rails"
```
5 changes: 5 additions & 0 deletions examples/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

# gem "rails"
7 changes: 7 additions & 0 deletions examples/tests/test_foo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "minitest/autorun"

class TestFoo < Minitest::Test
def test_foo
assert_equal 1, 1
end
end

0 comments on commit 9d80383

Please sign in to comment.