1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
# require 'simplecov'
# require 'coveralls'
# SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
# SimpleCov::Formatter::HTMLFormatter,
# Coveralls::SimpleCov::Formatter
# ]
# SimpleCov.start do
# add_filter 'spec'
# add_filter 'vendor'
# end
require 'multi_json'
require 'rspec'
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
end
end
def silence_warnings
old_verbose, $VERBOSE = $VERBOSE, nil
yield
ensure
$VERBOSE = old_verbose
end
def macruby?
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
end
def jruby?
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
end
def undefine_constants(*consts)
values = {}
consts.each do |const|
if Object.const_defined?(const)
values[const] = Object.const_get(const)
Object.send :remove_const, const
end
end
yield
ensure
values.each do |const, value|
Object.const_set const, value
end
end
def break_requirements
requirements = MultiJson::REQUIREMENT_MAP
MultiJson::REQUIREMENT_MAP.each_with_index do |(library, adapter), index|
MultiJson::REQUIREMENT_MAP[index] = ["foo/#{library}", adapter]
end
yield
ensure
requirements.each_with_index do |(library, adapter), index|
MultiJson::REQUIREMENT_MAP[index] = [library, adapter]
end
end
def simulate_no_adapters
break_requirements do
undefine_constants :JSON, :Oj, :Yajl, :Gson, :JrJackson do
yield
end
end
end
|