Sha256: 5fadaf0b717451a43b937e226b98de6592ea90d3e3279e018929655932a3ac4a

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

require 'rspec'
require 'stringio'
require "yajl"

require_relative "gorgon_rspec_formatter"

class RspecRunner
  class << self
    def run_file(filename)
      args = [
              '-f', 'RSpec::Core::Formatters::GorgonRspecFormatter',
              filename
             ]

      err, out = StringIO.new, StringIO.new

      keep_config_modules do
        RSpec::Core::Runner.run(args, err, out)
      end

      out.rewind

      Yajl::Parser.new(symbolize_keys: true).parse(out.read)
    end

    def runner
      :rspec
    end

    private

    def keep_config_modules
      orig_configuration = ::RSpec.configuration.clone
      yield
    ensure
      ::RSpec.reset
      ::RSpec.instance_variable_set(:@configuration, orig_configuration)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gorgon-0.10.2 lib/gorgon/rspec_runner.rb