1
0

spec_helper.rb 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. GC.disable
  2. if ENV['DISABLE_SIMPLECOV'] != 'true'
  3. require 'simplecov'
  4. SimpleCov.start 'rails' do
  5. add_group 'Services', 'app/services'
  6. add_group 'Presenters', 'app/presenters'
  7. add_group 'Validators', 'app/validators'
  8. end
  9. end
  10. gc_counter = -1
  11. RSpec.configure do |config|
  12. config.example_status_persistence_file_path = "tmp/rspec/examples.txt"
  13. config.expect_with :rspec do |expectations|
  14. expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  15. end
  16. config.mock_with :rspec do |mocks|
  17. mocks.verify_partial_doubles = true
  18. config.around(:example, :without_verify_partial_doubles) do |example|
  19. mocks.verify_partial_doubles = false
  20. example.call
  21. mocks.verify_partial_doubles = true
  22. end
  23. end
  24. config.before :suite do
  25. Rails.application.load_seed
  26. Chewy.strategy(:bypass)
  27. end
  28. config.after :suite do
  29. gc_counter = 0
  30. FileUtils.rm_rf(Dir["#{Rails.root}/spec/test_files/"])
  31. end
  32. config.after :each do
  33. gc_counter += 1
  34. if gc_counter > 19
  35. GC.enable
  36. GC.start
  37. GC.disable
  38. gc_counter = 0
  39. end
  40. end
  41. end
  42. def body_as_json
  43. json_str_to_hash(response.body)
  44. end
  45. def json_str_to_hash(str)
  46. JSON.parse(str, symbolize_names: true)
  47. end
  48. def expect_push_bulk_to_match(klass, matcher)
  49. expect(Sidekiq::Client).to receive(:push_bulk).with(hash_including({
  50. "class" => klass,
  51. "args" => matcher
  52. }))
  53. end