From b620c275e5b0787ca5f6da97dd64b24f588e831d Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Fri, 6 Jan 2017 12:39:07 -0600 Subject: [PATCH] Silence Grape warnings --- test/grape_test.rb | 22 ++++++++++++++++++++-- test/test_helper.rb | 12 ++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/test/grape_test.rb b/test/grape_test.rb index b026021d8..4851e57a7 100644 --- a/test/grape_test.rb +++ b/test/grape_test.rb @@ -1,5 +1,7 @@ require 'test_helper' -require 'grape' +TestHelper.silence_warnings do + require 'grape' +end require 'grape/active_model_serializers' require 'kaminari' require 'kaminari/hooks' @@ -53,7 +55,15 @@ def self.collection class GrapeTest < Grape::API format :json - include Grape::ActiveModelSerializers + TestHelper.silence_warnings do + include Grape::ActiveModelSerializers + end + + def self.resources(*) + TestHelper.silence_warnings do + super + end + end resources :grape do get '/render' do @@ -93,6 +103,14 @@ def app Grape::Middleware::Globals.new(GrapeTest.new) end + extend Minitest::Assertions + def self.run_one_method(*) + _, stderr = capture_io do + super + end + fail Minitest::Assertion, stderr if stderr !~ /grape/ + end + def test_formatter_returns_json get '/grape/render' diff --git a/test/test_helper.rb b/test/test_helper.rb index e96c4840f..294fa33c4 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -40,6 +40,18 @@ def serialization_options(options) require 'minitest/autorun' Minitest.backtrace_filter = Minitest::BacktraceFilter.new +module TestHelper + module_function + + def silence_warnings + original_verbose = $VERBOSE + $VERBOSE = nil + yield + ensure + $VERBOSE = original_verbose + end +end + require 'support/rails_app' # require "rails/test_help"