Projectile: Toggling between implementation and test fails in large rails codebase

Created on 1 Mar 2017  路  3Comments  路  Source: bbatsov/projectile

Expected behavior

In a large rails code base, I expect projectile-toggle-between-implementation-and-test to toggle between my test file and implementation file.

Actual behavior

This works fine in a small rails project, but it doesn't in my organizations monolith. When I run the M-x projectile-toggle-between-implementation-and-test (I'm using spacemacs so it's bound to SPC p a) in both a test file and an implementation file I receive the following message:

No matching test file found

I suspect this has to do with the fact that this is a large rails app. It seems like (I'm new to emacs list, so forgive me if I'm wrong), that this method searches through every file in the project to find the appropriate associated file. In a large rails app like mine (or the one I link to in steps to reproduce), it seems as if it's timing out while searching.

Steps to reproduce the problem

I can't give you my repo, but I've cloned the Discourse repo and I can reproduce my issue.

  1. Clone the discourse repository
  2. Open app/models/user.rb
  3. Try to toggle between test and implementation

Should be noted that I'm using Spacemacs and it includes projectile-rails. I wasn't sure if the issue was there, or here.

Environment & Version information

Projectile version information

Projectile version: 20170106.606

Emacs version

GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911))

Operating system

OSX 10.11.16

Most helpful comment

thanks @darrenboyd your comment got me to look into this and I got it working, here's an example .dir-locals.el that works for me:

((nil . ((projectile-project-type . rails-rspec)
         )))

You might have to restart emacs for the changes to take effect.

All 3 comments

+1

I looked into this issue (as I'm also suffering from it) and discovered the following...

In the discourse repo linked to above, projectile-project-info reports the _project type_ as ruby-test. However, it should be rails-rspec. If the _test_ folder is deleted (i.e., rm -fr test from the project dir), then projectile will see the project type as ruby-rspec, and will properly switch between test (spec in this case) and implementation.

In the project I'm working on, which is also a Rails with RSpec project, the _project type_ is reported as npm. If I remove the package.json file, projectile will see the project as ruby-rspec, and the toggle between implementation and spec will work properly.

I found documentation* that seems to suggest certain things can be overridden with a .dir-locals.el file in the project root. However, I was unable to get the project type explicitly set, due to insufficient elisp skills :slightly_frowning_face:.

thanks @darrenboyd your comment got me to look into this and I got it working, here's an example .dir-locals.el that works for me:

((nil . ((projectile-project-type . rails-rspec)
         )))

You might have to restart emacs for the changes to take effect.

Was this page helpful?
0 / 5 - 0 ratings