Sha256: d984a9e716122ab1c7ceca656ecb979eec22c052c829e93bff1279b6bbf8445b

Contents?: true

Size: 1.61 KB

Versions: 7

Compression:

Stored size: 1.61 KB

Contents

require 'simplecov'
require 'webmock'
require 'vcr'

class InceptionFormatter
  def format(result)
    Coveralls::SimpleCov::Formatter.new.format(result)
  end
end

def setup_formatter
  SimpleCov.formatter = if ENV['TRAVIS'] || ENV['COVERALLS_REPO_TOKEN']
    InceptionFormatter
  else
    SimpleCov::Formatter::HTMLFormatter
  end

  # SimpleCov.start 'test_frameworks'
  SimpleCov.start do
    add_filter do |source_file|
      source_file.filename =~ /spec/ && !(source_file.filename =~ /fixture/)
    end
  end
end

setup_formatter

require 'coveralls'

VCR.config do |c|
  c.cassette_library_dir = 'fixtures/vcr_cassettes'
  c.stub_with :webmock
end

RSpec.configure do |config|
  config.treat_symbols_as_metadata_keys_with_true_values = true
  config.run_all_when_everything_filtered = true
  config.filter_run :focus
  config.include WebMock::API
  config.after(:suite) do
    WebMock.disable!
  end
end

def stub_api_post
  body = "{\"message\":\"\",\"url\":\"\"}"
  stub_request(:post, Coveralls::API::API_BASE+"/jobs").with(
    :body => /.+/,
    :headers => {
      'Accept'=>'*/*; q=0.5, application/xml',
      'Accept-Encoding'=>'gzip, deflate',
      'Content-Length'=>/.+/,
      'Content-Type'=>/.+/,
      'User-Agent'=>'Ruby'
    }
  ).to_return(:status => 200, :body => body, :headers => {})
end

def silence
  return yield if ENV['silence'] == 'false'

  silence_stream(STDOUT) do
    yield
  end
end

module Kernel
  def silence_stream(stream)
    old_stream = stream.dup
    stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
    stream.sync = true
    yield
  ensure
    stream.reopen(old_stream)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
coveralls-0.7.0 spec/spec_helper.rb
coveralls-0.6.9 spec/spec_helper.rb
coveralls-0.6.8 spec/spec_helper.rb
coveralls-0.6.7 spec/spec_helper.rb
coveralls-0.6.6 spec/spec_helper.rb
coveralls-0.6.5 spec/spec_helper.rb
coveralls-0.6.4 spec/spec_helper.rb