rails_helper.rb 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ENV["RAILS_ENV"] ||= 'test'
  2. if ENV['COVERAGE']
  3. require 'simplecov'
  4. SimpleCov.start 'rails'
  5. elsif ENV['CI'] == 'true'
  6. require 'coveralls'
  7. Coveralls.wear!('rails')
  8. end
  9. require File.expand_path("../../config/environment", __FILE__)
  10. require 'rspec/rails'
  11. require 'rr'
  12. require 'webmock/rspec'
  13. WebMock.disable_net_connect!(allow_localhost: true)
  14. # Requires supporting ruby files with custom matchers and macros, etc,
  15. # in spec/support/ and its subdirectories.
  16. Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
  17. ActiveRecord::Migration.maintain_test_schema!
  18. # Mix in shoulda matchers
  19. Shoulda::Matchers.configure do |config|
  20. config.integrate do |with|
  21. with.test_framework :rspec
  22. with.library :rails
  23. end
  24. end
  25. RSpec.configure do |config|
  26. config.mock_with :rr
  27. # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  28. config.fixture_path = "#{::Rails.root}/spec/fixtures"
  29. # If you're not using ActiveRecord, or you'd prefer not to run each of your
  30. # examples within a transaction, remove the following line or assign false
  31. # instead of true.
  32. config.use_transactional_fixtures = true
  33. # rspec-rails 3 will no longer automatically infer an example group's spec type
  34. # from the file location. You can explicitly opt-in to this feature using this
  35. # snippet:
  36. config.infer_spec_type_from_file_location!
  37. # If true, the base class of anonymous controllers will be inferred
  38. # automatically. This will be the default behavior in future versions of
  39. # rspec-rails.
  40. config.infer_base_class_for_anonymous_controllers = false
  41. # These two settings work together to allow you to limit a spec run
  42. # to individual examples or groups you care about by tagging them with
  43. # `:focus` metadata. When nothing is tagged with `:focus`, all examples
  44. # get run.
  45. config.filter_run :focus
  46. config.run_all_when_everything_filtered = true
  47. # Run specs in random order to surface order dependencies. If you find an
  48. # order dependency and want to debug it, you can fix the order by providing
  49. # the seed, which is printed after each run.
  50. # --seed 1234
  51. config.order = "random"
  52. config.global_fixtures = :all
  53. config.render_views
  54. config.example_status_persistence_file_path = "./spec/examples.txt"
  55. config.include Devise::Test::ControllerHelpers, type: :controller
  56. config.include SpecHelpers
  57. config.include ActiveSupport::Testing::TimeHelpers
  58. end
  59. if ENV['RSPEC_TASK'] != 'spec:nofeatures'
  60. require 'capybara_helper'
  61. end