Skip to content

Not getting full file path of spec in terminal #104

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

Open
patrickspencer opened this issue Dec 18, 2015 · 6 comments
Open

Not getting full file path of spec in terminal #104

patrickspencer opened this issue Dec 18, 2015 · 6 comments

Comments

@patrickspencer
Copy link

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?

@patrickspencer patrickspencer changed the title Does not load full file path Not getting full file path of spec in terminal Dec 18, 2015
@gylaz
Copy link
Contributor

gylaz commented Dec 19, 2015

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
Copy link
Author

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
Copy link
Contributor

gylaz commented Dec 23, 2015

What is the result of :pwd?

@patrickspencer
Copy link
Author

: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:

  • Vim is 7.4 (installed by Homebrew)
  • Rails 4.2
  • RSpec 3.4
  • iTerm 2.1.4

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
Copy link

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
Copy link

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.

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

4 participants