From bc6ec8900ffa3c68b0a02367a7f15e991bcd4e32 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Sun, 27 Aug 2023 18:52:01 +0900 Subject: [PATCH] Fix broken mongoid/tasks/database_rake_spec --- lib/mongoid/tasks/encryption.rake | 5 ++--- spec/mongoid/tasks/database_rake_spec.rb | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/mongoid/tasks/encryption.rake b/lib/mongoid/tasks/encryption.rake index 2f9cf8cdfd..edd92048ef 100644 --- a/lib/mongoid/tasks/encryption.rake +++ b/lib/mongoid/tasks/encryption.rake @@ -20,9 +20,8 @@ namespace :db do options[:key_alt_name] = v end end - # rubocop:disable Lint/EmptyBlock - parser.parse!(parser.order!(ARGV) {}) - # rubocop:enable Lint/EmptyBlock + parser.parse!(parser.order!(ARGV) {}) # rubocop:disable Lint/EmptyBlock + result = Mongoid::Tasks::Encryption.create_data_key( client_name: options[:client_name], kms_provider_name: options[:kms_provider_name], diff --git a/spec/mongoid/tasks/database_rake_spec.rb b/spec/mongoid/tasks/database_rake_spec.rb index e920e99bea..110ad6c0fe 100644 --- a/spec/mongoid/tasks/database_rake_spec.rb +++ b/spec/mongoid/tasks/database_rake_spec.rb @@ -334,7 +334,8 @@ let(:config) do { - default: { + default: { hosts: SpecConfig.instance.addresses, database: database_id }, + encrypted: { hosts: SpecConfig.instance.addresses, database: database_id, options: { @@ -355,6 +356,9 @@ .to receive(:create_data_key) .with('local', {}) .and_call_original + + # OptionParser incorrectly handles RSpec's options such as --pattern + allow_any_instance_of(OptionParser).to receive(:order!).and_return({}) end it "creates the key" do