spec_helper.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.expect_with :rspec do |expectations|
  13. expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  14. end
  15. config.mock_with :rspec do |mocks|
  16. mocks.verify_partial_doubles = true
  17. config.around(:example, :without_verify_partial_doubles) do |example|
  18. mocks.verify_partial_doubles = false
  19. example.call
  20. mocks.verify_partial_doubles = true
  21. end
  22. end
  23. config.before :suite do
  24. Chewy.strategy(:bypass)
  25. end
  26. config.after :suite do
  27. gc_counter = 0
  28. FileUtils.rm_rf(Dir["#{Rails.root}/spec/test_files/"])
  29. end
  30. config.after :each do
  31. gc_counter += 1
  32. if gc_counter > 19
  33. GC.enable
  34. GC.start
  35. GC.disable
  36. gc_counter = 0
  37. end
  38. end
  39. end
  40. def body_as_json
  41. json_str_to_hash(response.body)
  42. end
  43. def json_str_to_hash(str)
  44. JSON.parse(str, symbolize_names: true)
  45. end