RSpec's rake task runs the specs in a separate process, so configuration you do with RSpec.configure
in the buildfile will not be visible to the running specs.
Two suggestions for passing info from the buildfile to your spec task:
- Generate a
spec_helper
and require it from your specs (or via rspec's-r
command line option and therspec_opts
config parameter onRSpec::Core::RakeTask
). You could use buildr's filtering to substitute values from the buildfile into the helper. - Set values in
ENV
and then read them out from your specs. Environment variables are shared from parent to child processes.
By request, an example for #1:
RSpec::Core::RakeTask.new do |t|
t.rspec_opts = "-r '#{_(:target, 'spec_helper.rb')}'"
end
This assumes that you (probably in another task) generate the spec helper into _(:target, 'spec_helper.rb')