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.10.4 spec/spec_helper.rb
softcover-1.10.3 spec/spec_helper.rb
softcover-1.10.2 spec/spec_helper.rb
softcover-1.10.1 spec/spec_helper.rb
softcover-1.10.0 spec/spec_helper.rb
softcover-1.9.1 spec/spec_helper.rb
softcover-1.9.0 spec/spec_helper.rb
softcover-1.8.3 spec/spec_helper.rb
softcover-1.8.2 spec/spec_helper.rb
softcover-1.8.1 spec/spec_helper.rb
softcover-1.8.0 spec/spec_helper.rb
softcover-1.7.5 spec/spec_helper.rb
softcover-1.7.4 spec/spec_helper.rb
softcover-1.7.3 spec/spec_helper.rb
softcover-1.7.2 spec/spec_helper.rb
softcover-1.7.1 spec/spec_helper.rb
softcover-1.7.0 spec/spec_helper.rb
softcover-1.6.5 spec/spec_helper.rb
softcover-1.6.4 spec/spec_helper.rb
softcover-1.6.3 spec/spec_helper.rb