How to save a file that has no changes?

I am using guard (https://github.com/guard/guard).  
I am working on a ruby file, let's call it banana.rb.  
I have a test file banana_test.rb.  
When I save banana.rb, I want guard to run banana_test.rb.

This always works in sublime or textmate.  In rubymine, this only works if I make a change to banana.rb.  I'm guessing rubymine is trying to be helpful/efficient, and is refusing to save banana.rb unless I've made a change to it.  

Any help is much appreciated.

4
16 comments

Oh, I'm using rubymine 6.3.3, if that matters.

0

Hi,

there is no such way, but it is unclear why you want to re-test unchanged file?

Regards, Oleg.

0

Thanks Oleg.

> there is no such way,

That's unfortunate.

> but it is unclear why you want to re-test unchanged file?

One example would be changing a string in a locale file (e.g. en.yml).  Guard doesn't realize that changing that string requires re-running certain tests.  This is something I could configure in my Guardfile, I suppose, though I doubt that's a common practice.

Thanks anyways,
-Jared

2

I think you have answered your question: guard should trigger a new run when en.yml is changed.
It is exactly what you need not a way to modify a file w/o actual modification.

Regards, Oleg.

-2

It's not my preferred solution, but yes, it'll work, thanks.  

By the way, your response sounds a bit defensive, telling me what "I need".  I am a customer after all ..

0

I'm sorry if tone of my response was inapropriate :(  (English is not my native language)

Regards, Oleg.

0

I completely disagree, there are many reason you want to save an unmodified file and I've never used an editor before that tried to be smart about this.

Say you have a testfile that sometimes fails and you're trying to get to the bottom of it. I don't want to be adding/removing characters for each run.

Also I don't agree that the guard file should specify all dependencies, that would quickly run way too many tests on saving some files (It would probably have to run all integration tests on all model saves), which gets in the way of developing. I'll run a few integration tests that I know might fail and let my ci-server run the rest when I push my branch.

I expect my editor to save a file when I tell it to save a file, it's really as simple as that.

Henk.

p.s. sorry if this sounds aggressive, english is not my first language.

4

So, you are saying that when you want to debug/investigate failure of the particular test you still want to run tests using Guard, instead of running the problematic one?
Why so? I mean you sill either have to press shortcut for save or for run the test, but why you still prefer the former?

Regards, Oleg.

-2

This is a big pain point for me as well. Our workflow depends heavily on build/test tools like guard and grunt, which rely on filesystem events to trigger actions. RubyMine takes away my ability to send those triggers at will.

I've come up with a crazy workaround that involves using a macro (bound to Cmd-S) to Save Document and then run `touch` as an external command. It is getting the job done, but RubyMine's world where almost everything is highly-configurable, I don't think I should have to go to such lengths.

2

+1 to make this work or can you help make the touch plugin work?

Here's my scenario

I'm working on a model or service modifying/adding functionality.

I have a variety of feature tests which depend on a large set of other components so it's infeasible to make a complicated Guardfile to cover all possibilities. Though Oleg, if you are volunteering...

So I need to be able to touch the file for the rspec and it's silly to keep adding blank lines or whatever.

I did notice the touch plugin for IDEA

https://plugins.jetbrains.com/plugin/4948?pr=

But it doesnt work in rubymine.  There are no errors, but no Touch operation shows up according to the docs.

Oleg, if we can't have this native in RubyMine, could you help make the plugin work?

 

2

I'd like to see any good solution on this. Right now I'm making an incidental change to the file I want to run in guard, saving the file and then reverting it to get the desired behaviour. This isn't really ideal.

 

If you stumble on this thread and would like to see a change, please comment and upvote the relevant comments.

2

+1

Like Henk said above, I expect my editor to save a file when I tell it to save a file, it's really as simple as that.

Also realized Command-S saves all the files, there's no option to save just the current file.

2

+1. Sometimes the dev server in a Create React App project doesn't pick up the current version of the file I'm modifying (this seems to happen much more often in WebStorm btw). When this happens in any other editor, I can hit Cmd+S which will save the file every time, trigger a filesystem event, and reload the dev server. In WebStorm I have to make some unnecessary change like adding a blank line in order to get it to save the file.

Like all other users in this thread, I just want it to save the file when I tell it to save the file - that's the reason I'm pressing Cmd+S. If I wanted to avoid saving the file, I'm perfectly able to do so by simply not pressing those keys. Please at least have the option to disable this "smart" save.

2

I also need this functionality. While someone can argue that you should configure Guard to watch all changed files, it does not work when you need to run the test manually after you modified something in your db or changed state of a remote system. It's ridiculous to add/delete random characters to your file just to make the IDE save it.

0

+1. This is the only issue that prevents me from using WebStorm for work-related projects.

Every time I need to clear data for example from the Redis cache I then need to save any file for nodemon to restart the application so I can fetch specific data again from our backend. This is such a common workflow for me that it simply prevents me from using WebStorm. And I don't want to have VSCode open just so that I can save files whenever I need to.

0

Please sign in to leave a comment.