Sha256: 518261e0b5ec3c626f579171379afb5dda6a802f6d306a87674d605265cef3ac

Contents?: true

Size: 1.62 KB

Versions: 62

Compression:

Stored size: 1.62 KB

Contents

require 'coveralls'
Coveralls::Output.silent = !ENV['CI']
Coveralls.wear!

require 'rubygems'
require 'bundler/setup'
require 'webmock/rspec'
require 'webmock_helpers'
require 'ostruct'
require 'pry'

require 'json'
require 'softcover'
require 'softcover/utils'
require 'softcover/config'
require 'softcover/server/app'
require 'softcover/commands/publisher'
Softcover::Output.silence!

# Load support files.
Dir.glob(File.join(File.dirname(__FILE__), "./support/**/*.rb")).each do |f|
  require_relative(f)
end

RSpec.configure do |config|
  include Softcover::Utils
  config.expect_with :rspec do |c|
    c.syntax = :expect
  end

  Softcover::set_test_mode!

  config.before do
    Softcover::set_test_mode!
    Softcover::Utils.reset_current_book!
    Softcover::Config.remove
    Softcover::BookConfig.remove
  end

  config.before(:each) do
    Softcover::Output.silence!
    Softcover::Commands::Server.no_listener = true
  end

  config.after do
    Softcover::Config.remove
    Softcover::BookConfig.remove
  end

  config.include WebmockHelpers
end

TEST_API_KEY = 'asdfasdfasdfasdfasdf'

# Captures a stream.
# This is taken directly from Rails Active Support `capture`.
# The `capture` method is deprecated because it's not thread-safe, but
# we don't care about that and the deprecation warnings are annoying.
def capture(stream)
  stream = stream.to_s
  captured_stream = Tempfile.new(stream)
  stream_io = eval("$#{stream}")
  origin_stream = stream_io.dup
  stream_io.reopen(captured_stream)

  yield

  stream_io.rewind
  return captured_stream.read
ensure
  captured_stream.close
  captured_stream.unlink
  stream_io.reopen(origin_stream)
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
softcover-1.6.2 spec/spec_helper.rb
softcover-1.6.1 spec/spec_helper.rb
softcover-1.6.0 spec/spec_helper.rb
softcover-1.5.11 spec/spec_helper.rb
softcover-1.5.10 spec/spec_helper.rb
softcover-1.5.9 spec/spec_helper.rb
softcover-1.5.8 spec/spec_helper.rb
softcover-1.5.7 spec/spec_helper.rb
softcover-1.5.6 spec/spec_helper.rb
softcover-1.5.5 spec/spec_helper.rb
softcover-1.5.4 spec/spec_helper.rb
softcover-1.5.3 spec/spec_helper.rb
softcover-1.5.2 spec/spec_helper.rb
softcover-1.5.1 spec/spec_helper.rb
softcover-1.5.0 spec/spec_helper.rb
softcover-1.4.9 spec/spec_helper.rb
softcover-1.4.8 spec/spec_helper.rb
softcover-1.4.7 spec/spec_helper.rb
softcover-1.4.6 spec/spec_helper.rb
softcover-1.4.5 spec/spec_helper.rb