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.

56 lines
1.1 KiB

7 years ago
  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.before :suite do
  22. Chewy.strategy(:bypass)
  23. end
  24. config.after :suite do
  25. gc_counter = 0
  26. FileUtils.rm_rf(Dir["#{Rails.root}/spec/test_files/"])
  27. end
  28. config.after :each do
  29. gc_counter += 1
  30. if gc_counter > 19
  31. GC.enable
  32. GC.start
  33. GC.disable
  34. gc_counter = 0
  35. end
  36. end
  37. end
  38. def body_as_json
  39. json_str_to_hash(response.body)
  40. end
  41. def json_str_to_hash(str)
  42. JSON.parse(str, symbolize_names: true)
  43. end