spec_helper.rb 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. require 'simplecov'
  2. GC.disable
  3. SimpleCov.start 'rails' do
  4. add_group 'Services', 'app/services'
  5. add_group 'Presenters', 'app/presenters'
  6. add_group 'Validators', 'app/validators'
  7. end
  8. gc_counter = -1
  9. RSpec.configure do |config|
  10. config.expect_with :rspec do |expectations|
  11. expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  12. end
  13. config.mock_with :rspec do |mocks|
  14. mocks.verify_partial_doubles = true
  15. config.around(:example, :without_verify_partial_doubles) do |example|
  16. mocks.verify_partial_doubles = false
  17. example.call
  18. mocks.verify_partial_doubles = true
  19. end
  20. end
  21. config.after :suite do
  22. gc_counter = 0
  23. FileUtils.rm_rf(Dir["#{Rails.root}/spec/test_files/"])
  24. end
  25. config.after :each do
  26. gc_counter += 1
  27. if gc_counter > 19
  28. GC.enable
  29. GC.start
  30. GC.disable
  31. gc_counter = 0
  32. end
  33. end
  34. end
  35. def body_as_json
  36. json_str_to_hash(response.body)
  37. end
  38. def json_str_to_hash(str)
  39. JSON.parse(str, symbolize_names: true)
  40. end