You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.5 KiB

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