Hello,
I'm new in Rspec, so I think this is basic question.
(I'm using Rspec 3)
I have 3 spec files and want to use the same tmpdir in my all examples.
I'd like to call before(:all) only once and use the same dir, so I'd like to have it in global hook before(:all).
I'm thinking like below:
spec_helper.rb
-----------------------------
RSpec.configure do |config|
config.before(:all) do
@tmpdir = Dir.mktmpdir
# a lot of things to do here
end
config.after(:all) do
FileUtils.rm_rf(@tmpdir)
end
end
-----------------------------
target1_spec.rb, target2_spec.rb, target3_spec.rb
-----------------------------
require 'spec_helper'
describe 'test' do
# I want to use the temp dir name here
end
-----------------------------
When I googled this, somebody suggested to set global variable or constant value in spec_helper in similar situations.
Is there any other good way to get the temp dir name in the spec files?
Thanks,
Makoto