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
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/6f39bee7-b917-4a38-8a0d-1e9aeed129a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.