In RSpec, I'm specifying the behavior I expect a Rake task to have. The task is defined in the Rakefile located at the root or the project.
From my understanding, the following code runs the task as running rake xml:export
in the console.
require 'spec_helper'
RSpec.describe 'xml:export' do
load 'Rakefile'
let(:task) { Rake::Task['xml:export'] }
it '' do
task.execute
end
end
However, The task requires to be run as rake xml:export date=2020-01-01
since it expects the ENV['date']
to be passed in.
How can I provide the date when executing the task in my spec?
I have tried system('rake xml:export date=2020-01-01')
instead of task.execute
but it doesn't work.