Configure rake specs in one place

So we don't have to add it to every rake spec file.
This commit is contained in:
Maikel Linke
2025-08-29 16:47:27 +10:00
parent 570b72868b
commit 6d284023fe
9 changed files with 7 additions and 22 deletions

View File

@@ -145,6 +145,10 @@ RSpec.configure do |config|
config.default_formatter = "doc"
end
config.define_derived_metadata(file_path: %r{/spec/lib/tasks/}) do |metadata|
metadata[:type] = :rake
end
# Reset locale for all specs.
config.around(:each) do |example|
locale = ENV.fetch('LOCALE', 'en_TST')
@@ -245,6 +249,8 @@ RSpec.configure do |config|
# You can use `rspec -n` to run only failed specs.
config.example_status_persistence_file_path = "tmp/rspec-status.txt"
config.include_context "rake", type: :rake
# Helpers
config.include FactoryBot::Syntax::Methods
config.include JsonSpec::Helpers

View File

@@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe 'truncate_data.rake' do
include_context "rake"
describe ':truncate' do
context 'when months_to_keep is specified' do
it 'truncates order cycles closed earlier than months_to_keep months ago' do

View File

@@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe 'enterprises.rake' do
include_context "rake"
describe ':remove_enterprise' do
context 'when the enterprises exists' do
it 'removes the enterprise' do

View File

@@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe 'ofn:import:product_images' do
include_context "rake"
describe 'task' do
context "filename is blank" do
it 'raises an error' do

View File

@@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe "reset.rake" do
include_context "rake"
it "clears job queues" do
job_class = Class.new do
include Sidekiq::Job

View File

@@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe 'sample_data.rake' do
include_context "rake"
before do
# Create seed data required by the sample data.
create(:user)

View File

@@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe "simplecov.rake" do
include_context "rake"
describe "simplecov:collate_results" do
context "when there are reports to merge" do
let(:input_dir) { Rails.root.join("spec/fixtures/simplecov") }

View File

@@ -4,8 +4,6 @@ require 'spec_helper'
require 'rake'
RSpec.describe 'users.rake' do
include_context "rake"
describe ':remove_enterprise_limit' do
context 'when the user exists' do
let(:user) { create(:user) }

View File

@@ -1,13 +1,6 @@
# frozen_string_literal: true
# Let this context take care of Rake testing gotchas.
#
# ```rb
# RSpec.describe "my_task.rake" do
# include_context "rake"
# # ..
# ```
#
# A shared context for all rake specs
shared_context "rake" do
before(:all) do
# Make sure that Rake tasks are only loaded once.