Skip to content

Commit

Permalink
Merge pull request #2020 from bf4/silence_grape_warnings
Browse files Browse the repository at this point in the history
Silence Grape warnings
  • Loading branch information
bf4 authored Jan 7, 2017
2 parents 7efb362 + b620c27 commit 98194cc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
22 changes: 20 additions & 2 deletions test/grape_test.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'

Expand Down
12 changes: 12 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 98194cc

Please sign in to comment.