spec/spec_helper.rb in citeproc-ruby-0.0.6 vs spec/spec_helper.rb in citeproc-ruby-1.0.0

- old
+ new

@@ -1,18 +1,71 @@ -require 'rubygems' -require 'citeproc' -require 'json' -require 'yaml' +require 'bundler' +begin + Bundler.setup +rescue Bundler::BundlerError => e + $stderr.puts e.message + $stderr.puts "Run `bundle install` to install missing gems" + exit e.status_code +end -RSpec.configuration do |c| +begin + require 'simplecov' + require 'coveralls' if ENV['CI'] +rescue LoadError + # ignore end -module CiteProc - module Test - module Fixtures - Names = YAML.load(File.read(File.expand_path("../fixtures/names.yaml", __FILE__))) - Dates = YAML.load(File.read(File.expand_path("../fixtures/dates.yaml", __FILE__))) - Nodes = YAML.load(File.read(File.expand_path("../fixtures/nodes.yaml", __FILE__))) - Processor = Hash[Dir.glob(File.expand_path("../../resource/test/processor/*.json", __FILE__)).map { |file| [file, JSON.parse(File.read(file))] }] - end +begin + case + when RUBY_PLATFORM < 'java' + require 'debug' + Debugger.start + when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' + require 'rubinius/debugger' + else + require 'debugger' end -end \ No newline at end of file +rescue LoadError + # ignore +end + +require 'citeproc/ruby' + +module Fixtures + PATH = File.expand_path('../fixtures', __FILE__) + + Dir[File.join(PATH, '*.rb')].each do |fixture| + require fixture + end +end + +module SilentWarnings + require 'stringio' + # + # Adapted form silent_warnings gist by @avdi + # https://gist.github.com/1170926 + # + def silent_warnings + original_stderr = $stderr + $stderr = StringIO.new + yield + ensure + $stderr = original_stderr + end +end + +RSpec.configure do |config| + config.include(SilentWarnings) + config.include(Fixtures) + + config.before :all do + @style_root, @locale_root = CSL::Style.root, CSL::Locale.root + + CSL::Style.root = File.join(Fixtures::PATH, 'styles') + CSL::Locale.root = File.join(Fixtures::PATH, 'locales') + end + + config.after :all do + CSL::Style.root, CSL::Locale.root = @style_root, @locale_root + end + +end