thoughtbot / vim-rspec

Run Rspec specs from Vim
https://robots.thoughtbot.com
MIT License
656 stars 108 forks source link

Not getting full file path of spec in terminal #104

Open patrickspencer opened 8 years ago

patrickspencer commented 8 years ago

For some reason when I run any of the vim-rspec commands it shows up in my terminal as something like "rspec ~/railsapp/user_spec.rb" instead of "rspec ~/railsapp/spec/models/user_spec.rb". I changed

function! s:CurrentFilePath()
  return @%
endfunction

to

function! s:CurrentFilePath()
  return expand('%:p')
endfunction

in plugin/rspec.vim and it seemed to fix it. I was wondering if anyone else had this problem?

gylaz commented 8 years ago

It's likely you are in the directory of the file that you have open.

What is the result of running :echo @% from Vim when you have the file open? Do you have something that changes the directory when you open the file?

patrickspencer commented 8 years ago

Running :echo @% from Vim when I have the file open returns the current file name without the path. I don't think I have anything that changes the directory when I open the file. Perhaps this is just an issue with some dotfile I have somewhere.

gylaz commented 8 years ago

What is the result of :pwd?

patrickspencer commented 8 years ago

:pwd always prints full path to the file but not including the file name. For example if I had the file /Users/Patrick/project/app/controllers/user.rb open, then :pwd would output /Users/Patrick/project/app/controllers. (This is on a mac)

Also here are the versions I'm using:

I'm also not sure if I'm using vim-rspec correctly. We are supposed to hit <leader>t from the controller file or from the test file? Actually, neither work for me when I use @% instead of expand('%:p'). For example if I call <leader>t from something like spec/controllers/user_controller_spec.rb or from the controller file e.g. app/controllers/user_controller.rb using @% nothing happens (a terminal window doesn't even show up) but when I use expand('%:p') then I can call the tests from both of these places.

davidhan527 commented 8 years ago

I am also getting the same issue but I only came across this since I started using this vim distribution https://github.com/spf13/spf13-vim . I'm assuming there is a configuration within spf13's vim distribution that changes the file path somehow.

phallguy commented 7 years ago

I'm getting the same behavior...but only some times. I'm using FZF using Ag to build list of files (vimrc). It seems that on occasion when a file is opened with :FZF @% will only expand to the relative and not the full path. But expand('%:p') does get the fully qualified path.