Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble using rspec-mode with docker #192

Open
miguelbernadi opened this issue Feb 15, 2020 · 6 comments
Open

Trouble using rspec-mode with docker #192

miguelbernadi opened this issue Feb 15, 2020 · 6 comments

Comments

@miguelbernadi
Copy link

I'm trying to run the specs with rspec-mode against docker but it always fails as it tries to run the specs locally (bundler not installed locally). I also can't figure how to get some more verbose output to debug if my config may be wrong.

Setup is as follows:

~/docker-projects/
  |- docker-compose.yml
  |- project_1
    |- Dockerfile
    |- spec/
    |- .dir-locals.el
  |- project-2
    |- Dockerfile
    |- spec/
    |- .dir-locals.el

Each of the projects is a separate git repository and they are put in this order manually (no submodules or anything similar). The projects interdepend, so we have a single docker-compose.yml for all of it.

I'm setting the variables in the dir-locals for each project as recommended in the README.

.dir-locals.el of project_1:

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((rspec-compilation-mode
  (rspec-docker-file-name . Dockerfile)
  (rspec-docker-cwd . /var/lib/app-user/project_1/current)
  (rspec-docker-container . project_1)
  (rspec-use-docker-when-possible . t)))

I'm setting rspec-docker-file-name as it seems to be necessary to detect the docker support (by skimming the code) which is not documented in the README. Also in my case, as the docker-compose.yml is outside the project root I'm overwriting it for the Dockerfile, which is present. I got the warning about unsafe dir-locals and accepted it, so I'm not expecting the error to be there.

Any idea on what may be wrong or how to further debug the issue? Toggling from spec to implementation works and I assume all other features do work as well.

@dgutov
Copy link
Collaborator

dgutov commented Feb 15, 2020

Dockerfile should be "Dockerfile", it's a string. Same for rspec-docker-container. But you should be getting a more obvious error because of that.

Where does Gemfile reside? Check that (rspec-project-root) returns the correct directory in each case.

@miguelbernadi
Copy link
Author

There is a Gemfile for each project next to each Dockerfile. I've updated the strings to use quotes as you mentioned but it still does not work.

I wasn't sure how to run (rspec-project-root) so I did it in a scratch buffer opened in the root of my project. I run:

(rspec-mode)
(rspec-project-root)

and it returned the path to the root of my project (~/docker-projects/project_1/).

@pedz
Copy link
Contributor

pedz commented Feb 15, 2020 via email

@miguelbernadi
Copy link
Author

@pedz Thanks for the tip!

Just run it in the buffer where I was failing to run the specs and it returned the project root properly.

@dgutov
Copy link
Collaborator

dgutov commented Feb 15, 2020

Then I can recommend edebug-ing rspec--docker-wrapper.

@dgutov
Copy link
Collaborator

dgutov commented Nov 15, 2020

BTW, you might want to try https://github.com/bibendi/dip. It's a semi-transparent wrapper for docker and docker-compose.

Configuring rspec-mode for use with it is pretty trivial:

(setq rspec-spec-command "dip rspec")
(setq rspec-use-bundler-when-possible nil)

(Or do that in .dir-locals.el).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants