diff --git a/.rubocop.yml b/.rubocop.yml index aa4094b..cb27cc7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -22,8 +22,7 @@ Lint/UnusedMethodArgument: AllowUnusedKeywordArguments: true RSpec/DescribeClass: - Exclude: - - spec/tasks/active_storage_db_tasks_spec.rb + Enabled: false RSpec/ExampleLength: # Default is 5 diff --git a/spec/models/active_storage_db/file_spec.rb b/spec/models/active_storage_db/file_spec.rb index 93868ea..51545f6 100644 --- a/spec/models/active_storage_db/file_spec.rb +++ b/spec/models/active_storage_db/file_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe ActiveStorageDB::File, type: :model do +RSpec.describe ActiveStorageDB::File do let(:file) { create(:active_storage_db_file, ref: 'just_some_key') } context 'when creating a file with an already existing key' do diff --git a/spec/requests/file_controller_spec.rb b/spec/requests/file_controller_spec.rb index 71748ba..2e8828b 100644 --- a/spec/requests/file_controller_spec.rb +++ b/spec/requests/file_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe 'File controller', type: :request do +RSpec.describe 'File controller' do def create_blob(data: 'Hello world!', filename: 'hello.txt', content_type: 'text/plain', identify: true, record: nil) ActiveStorage::Blob.create_and_upload!( io: StringIO.new(data), diff --git a/spec/requests/file_url_spec.rb b/spec/requests/file_url_spec.rb index 9f75650..dd7d392 100644 --- a/spec/requests/file_url_spec.rb +++ b/spec/requests/file_url_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe 'File URL', type: :request do +RSpec.describe 'File URL' do let(:app_url_helpers) { Rails.application.routes.url_helpers } let(:engine_url_helpers) { ActiveStorageDB::Engine.routes.url_helpers } diff --git a/spec/service/active_storage/service/db_service_spec.rb b/spec/service/active_storage/service/db_service_spec.rb index 9af4131..86fe38d 100644 --- a/spec/service/active_storage/service/db_service_spec.rb +++ b/spec/service/active_storage/service/db_service_spec.rb @@ -52,14 +52,14 @@ describe '.compose' do subject(:compose) { service.compose(%w[key1 key2 key3], 'dest_key') } - let!(:db_file1) { create(:active_storage_db_file, ref: 'key1', data: 'first file') } - let!(:db_file2) { create(:active_storage_db_file, ref: 'key2', data: 'second file') } - let!(:db_file3) { create(:active_storage_db_file, ref: 'key3', data: 'third file') } + let!(:first_db_file) { create(:active_storage_db_file, ref: 'key1', data: 'first file') } + let!(:second_db_file) { create(:active_storage_db_file, ref: 'key2', data: 'second file') } + let!(:third_db_file) { create(:active_storage_db_file, ref: 'key3', data: 'third file') } it 'composes the source files' do expect { compose }.to change { ActiveStorageDB::File.where(ref: 'dest_key').count }.by(1) expect(compose).to be_a ActiveStorageDB::File - expect(compose.data).to eq [db_file1.data, db_file2.data, db_file3.data].join + expect(compose.data).to eq [first_db_file.data, second_db_file.data, third_db_file.data].join end end end @@ -70,7 +70,7 @@ before { upload } it 'deletes the file' do - expect { delete }.to change { ActiveStorageDB::File.count }.from(1).to(0) + expect { delete }.to change(ActiveStorageDB::File, :count).from(1).to(0) end end @@ -80,7 +80,7 @@ before { upload } it 'deletes the files' do - expect { delete_prefixed }.to change { ActiveStorageDB::File.count }.from(1).to(0) + expect { delete_prefixed }.to change(ActiveStorageDB::File, :count).from(1).to(0) end end diff --git a/spec/tasks/active_storage_db_tasks_spec.rb b/spec/tasks/active_storage_db_tasks_spec.rb index cbbec45..b9f59c9 100644 --- a/spec/tasks/active_storage_db_tasks_spec.rb +++ b/spec/tasks/active_storage_db_tasks_spec.rb @@ -6,16 +6,12 @@ describe 'asdb:list' do subject(:task) { execute_task('asdb:list') } - let(:file1) { create(:active_storage_blob, filename: 'some file 1', created_at: Time.now - 1.hour) } - let(:file2) { create(:active_storage_blob, filename: 'some file 2', created_at: Time.now - 5.hour) } - let(:file3) { create(:active_storage_blob, filename: 'some file 3', created_at: Time.now - 3.hour) } - - before do - [file1, file2, file3] - end + let!(:first_file) { create(:active_storage_blob, filename: 'some file 1', created_at: Time.now - 1.hour) } + let!(:second_file) { create(:active_storage_blob, filename: 'some file 2', created_at: Time.now - 5.hour) } + let!(:third_file) { create(:active_storage_blob, filename: 'some file 3', created_at: Time.now - 3.hour) } it 'prints the columns header + the list of 3 files', :aggregate_failures do - pattern = /#{file3.id} #{file3.filename}.+#{file2.id} #{file2.filename}.+#{file1.id} #{file1.filename}/m + pattern = /#{third_file.id} #{third_file.filename}.+#{second_file.id} #{second_file.filename}.+#{first_file.id} #{first_file.filename}/m expect(task).to match pattern expect(task.split("\n").size).to be 4 end