Skip to content

Instantly share code, notes, and snippets.

@peijiehu
Created March 3, 2015 19:48
Show Gist options
  • Save peijiehu/12da8f29a7f3947f5889 to your computer and use it in GitHub Desktop.
Save peijiehu/12da8f29a7f3947f5889 to your computer and use it in GitHub Desktop.
Get an rspec example's path at run time in rspec configure
# can be useful when you are not in that directory, eg. use it in RSpec.configure block
# but you'll need access to the example object
RSpec.configure do |config|
config.before :each do |example|
puts spec_dir = File.dirname(example.metadata[:file_path])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment