Sha256: e2e6a02f82f2bca5c04d52bc1a97ab067503dbee979bc135e8ff8ee3ea8bd322

Contents?: true

Size: 997 Bytes

Versions: 1

Compression:

Stored size: 997 Bytes

Contents

if ENV['COVERAGE']
  raise "simplecov only works on 1.9" unless RUBY_PLATFORM >= "1.9"
  require 'simplecov'
  SimpleCov.start {
    add_filter "spec/"
  }
end

$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require 'har'
require 'pry'

module HAR
  module SpecHelper
    def fixture_path(name)
      File.join(File.expand_path("../fixtures", __FILE__), name)
    end

    def har_path(name)
      fixture_path File.join("hars", "#{name}.har")
    end

    def json(path)
      JSON.parse(File.read(path))
    end

    def all_hars
      Dir[fixture_path("hars/*.har")]
    end

    def google_path
      har_path "google.com"
    end

    def good_hars
      all_hars.reject { |e| e =~ /bad/ }
    end

    def with_stdin_replaced_by(file_path)
      stdin = $stdin
      begin
        File.open(file_path, "r") { |io|
          $stdin = io
          yield
        }
      ensure
        $stdin = stdin
      end
    end
  end
end

RSpec.configure do |c|
  c.include HAR::SpecHelper
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
har-0.0.9 spec/spec_helper.rb