rails_helper.rb 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ENV["RAILS_ENV"] ||= 'test'
  2. if ENV['COVERAGE']
  3. require 'simplecov'
  4. SimpleCov.start 'rails'
  5. else
  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!
  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. # Run specs in random order to surface order dependencies. If you find an
  42. # order dependency and want to debug it, you can fix the order by providing
  43. # the seed, which is printed after each run.
  44. # --seed 1234
  45. config.order = "random"
  46. config.global_fixtures = :all
  47. config.render_views
  48. config.include Devise::TestHelpers, type: :controller
  49. config.include SpecHelpers
  50. config.include Delorean
  51. end