commit: c66fe2aeba84af5ab47c20298ddc8dceaf0e179f
parent: fbe1115114edb2d46c05b5065398b7234b9fb6a0
Author: Eugen Rochko <eugen@zeonfederated.com>
Date: Thu, 24 Aug 2017 13:31:55 +0200
Minor performance improvement for test suite (#4678)
Diffstat:
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/app/models/account.rb b/app/models/account.rb
@@ -268,7 +268,7 @@ class Account < ApplicationRecord
def generate_keys
return unless local?
- keypair = OpenSSL::PKey::RSA.new(Rails.env.test? ? 1024 : 2048)
+ keypair = OpenSSL::PKey::RSA.new(Rails.env.test? ? 512 : 2048)
self.private_key = keypair.to_pem
self.public_key = keypair.public_key.to_pem
end
diff --git a/spec/controllers/api/v1/accounts/relationships_controller_spec.rb b/spec/controllers/api/v1/accounts/relationships_controller_spec.rb
@@ -50,14 +50,14 @@ describe Api::V1::Accounts::RelationshipsController do
json = body_as_json
expect(json).to be_a Enumerable
- expect(json.first[:id]).to be simon.id
+ expect(json.first[:id]).to eq simon.id
expect(json.first[:following]).to be true
expect(json.first[:followed_by]).to be false
expect(json.first[:muting]).to be false
expect(json.first[:requested]).to be false
expect(json.first[:domain_blocking]).to be false
- expect(json.second[:id]).to be lewis.id
+ expect(json.second[:id]).to eq lewis.id
expect(json.second[:following]).to be false
expect(json.second[:followed_by]).to be true
expect(json.second[:muting]).to be false
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
@@ -1,11 +1,15 @@
require 'simplecov'
+GC.disable
+
SimpleCov.start 'rails' do
add_group 'Services', 'app/services'
add_group 'Presenters', 'app/presenters'
add_group 'Validators', 'app/validators'
end
+gc_counter = -1
+
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
@@ -22,8 +26,21 @@ RSpec.configure do |config|
end
config.after :suite do
+ gc_counter = 0
FileUtils.rm_rf(Dir["#{Rails.root}/spec/test_files/"])
end
+
+ config.after :each do
+ gc_counter += 1
+
+ if gc_counter > 19
+ GC.enable
+ GC.start
+ GC.disable
+
+ gc_counter = 0
+ end
+ end
end
def body_as_json