Skip to content

Commit

Permalink
Merge pull request #43 from gcentauri/add-docker-command
Browse files Browse the repository at this point in the history
Add: custom vars to use bin/rails test command and docker prefix
  • Loading branch information
arthurnn authored Dec 24, 2019
2 parents 429dc87 + 225b5d8 commit 68c16d5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ of your `.spacemacs` dotfile:
If you have another hook already in here make sure to add this hook within its own set of parenthesis so that
there is only one hook per parenthesis.

## Rails

If you are working on a Rails project, you can set `minitest-use-rails` to true in order to use the `bin/rails test`
command when running examples.

## Docker

You can run tests inside a Docker container by setting `minitest-use-docker` to
true and `minitest-docker-container` to the name of the container. By default this
will use the command `docker-compose exec` to run the minitest command, which assumes
you already have the specified container running. To customize the command, edit the
`minitest-docker-command` variable.

## Snippets

If you have yasnippet installed, you can load the snippets:
Expand Down
29 changes: 26 additions & 3 deletions minitest.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@
:type 'boolean
:group 'minitest)

(defcustom minitest-use-rails nil
"Use `bin/rails test' as the default runner"
:type 'boolean
:group 'minitest)

(defcustom minitest-use-docker nil
"Execute test command inside `minitest-docker-container' with `minitest-docker-command`'"
:type 'boolean
:group 'minitest)

(defcustom minitest-docker-command '("docker-compose" "exec")
"Command to execute tests with docker"
:type 'list
:group 'minitest)

(defcustom minitest-docker-container nil
"Specify the name of the docker container to target"
:type 'string
:group 'minitest)

(defcustom minitest-default-env nil
"Default env vars for minitest"
:type 'string
Expand All @@ -48,9 +68,12 @@
(concat "*Minitest " file-or-dir "*"))

(defun minitest-test-command ()
(cond (minitest-use-spring '("spring" "rake" "test"))
((minitest-zeus-p) '("zeus" "test"))
(t minitest-default-command)))
(let ((command (cond (minitest-use-spring '("spring" "rake" "test"))
((minitest-zeus-p) '("zeus" "test"))
(minitest-use-rails '("bin/rails" "test"))
(t minitest-default-command))))
(if minitest-use-docker (append minitest-docker-command (list minitest-docker-container) command)
command)))

(defun minitest-bundler-command ()
(cond (minitest-use-bundler '("bundle" "exec"))
Expand Down
12 changes: 11 additions & 1 deletion test/minitest-unit-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@
(ert-deftest test-minitest-test-command ()
(let ((minitest-use-spring t))
(should (equal (minitest-test-command) '("spring" "rake" "test"))))
(let ((minitest-use-docker t)
(minitest-docker-container "app")
(minitest-use-rails t))
(should (equal (minitest-test-command) '("docker-compose" "exec" "app" "bin/rails" "test"))))
(let ((minitest-use-docker t)
(minitest-docker-command '("docker-compose" "run"))
(minitest-docker-container "test"))
(should (equal (minitest-test-command) '("docker-compose" "run" "test" "ruby" "-Ilib:test:spec"))))
(let ((minitest-use-spring nil))
(should (equal (minitest-test-command) '("ruby" "-Ilib:test:spec")))))
(should (equal (minitest-test-command) '("ruby" "-Ilib:test:spec"))))
(let ((minitest-use-docker t) (minitest-docker-container "test"))
(should (equal (minitest-test-command) '("docker-compose" "exec" "test" "ruby" "-Ilib:test:spec")))))

(ert-deftest test-minitest-test-command-override ()
(with-mock
Expand Down

0 comments on commit 68c16d5

Please sign in to comment.