Created
March 3, 2015 19:48
-
-
Save peijiehu/12da8f29a7f3947f5889 to your computer and use it in GitHub Desktop.
Get an rspec example's path at run time in rspec configure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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