A simple work flow I often use when running an rspec test I have just been working on, in vim, is as follows:
15: it "my example test" do
16: expect(1 == 1).to be true
17: end
And to run this test, you can do:
!rspec %:15
This runs rspec as an external command. % expands to the current filename, and :15 tells rspec to only run the test line 15, rather than all tests in the file.
This technique works fine under normal circumstances. However, if you try to run a test on lines 80-89 then something strange happens:
84: it "my other test" do
85: expect(4 > 3).to be false
86: end
!rspec %:84
This runs the command rspec [filename]4 - i.e. the :8 characters disappear! (And you get a "file not found" error.)
A workaround to avoid this problem is to press TAB after entering %, which immediately expands % to the full path name.
However, what's the reason behind this strange vim behaviour? Is it a bug, or a feature?