Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence Grape warnings #2020

Merged
merged 1 commit into from
Jan 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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