spec_helper.rb 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright 2015 gRPC authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. spec_dir = File.expand_path(File.dirname(__FILE__))
  15. root_dir = File.expand_path(File.join(spec_dir, '..'))
  16. lib_dir = File.expand_path(File.join(root_dir, 'lib'))
  17. $LOAD_PATH.unshift(spec_dir)
  18. $LOAD_PATH.unshift(lib_dir)
  19. $LOAD_PATH.uniq!
  20. # set up coverage
  21. require 'simplecov'
  22. SimpleCov.start do
  23. add_filter 'spec'
  24. add_filter 'bin'
  25. SimpleCov.command_name ENV['COVERAGE_NAME']
  26. end if ENV['COVERAGE_NAME']
  27. require 'rspec'
  28. require 'logging'
  29. require 'rspec/logging_helper'
  30. require 'grpc'
  31. require_relative 'support/services'
  32. require_relative 'support/helpers'
  33. # GRPC is the general RPC module
  34. #
  35. # Configure its logging for fine-grained log control during test runs
  36. module GRPC
  37. extend Logging.globally
  38. end
  39. Logging.logger.root.appenders = Logging.appenders.stdout
  40. Logging.logger.root.level = :info
  41. Logging.logger['GRPC'].level = :info
  42. Logging.logger['GRPC::ActiveCall'].level = :info
  43. Logging.logger['GRPC::BidiCall'].level = :info
  44. # Configure RSpec to capture log messages for each test. The output from the
  45. # logs will be stored in the @log_output variable. It is a StringIO instance.
  46. RSpec.configure do |config|
  47. include RSpec::LoggingHelper
  48. config.capture_log_messages # comment this out to see logs during test runs
  49. include GRPC::Spec::Helpers
  50. end
  51. RSpec::Expectations.configuration.warn_about_potential_false_positives = false
  52. Thread.abort_on_exception = true