Skip to content

Using rspec‐mode with Podman Compose

John Hamelink edited this page Aug 22, 2023 · 4 revisions

Here’s a way to get podman-compose working well with rspec-mode:

The project root’s .dir-locals.el should include this snippet:

((nil . ((rspec-use-docker-when-possible . t)
      (rspec-use-relative-path . t)
      (rspec-docker-file-name . "./docker-compose.yml")
      (rspec-docker-command . "podman-compose exec")
      (rspec-docker-cwd . "/app/")
      (rspec-docker-container . "rails-app")))

And your Emacs’ init.el should include this snippet:

(defun jjh/rspec--compose-default-wrapper (_compose compose-service command)
    "Wrap a COMMAND for execution inside a podman container in COMPOSE-SERVICE."
    (format "podman-compose -f %s exec %s sh -c \"%s\""
            rspec-docker-file-name compose-service command))

(use-package rspec-mode
    :custom
    rspec-docker-wrapper-fn #'jjh/rspec--compose-default-wrapper)

(add-to-list 'safe-local-variable-values
             '(rspec-docker-command . "podman-compose exec"))
Clone this wiki locally