Sha256: aeda8168df51b49d32ddc6fd8e6e0444fbe47259d3118b71574d220574c90e91

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require "pry"
require "simplecov"
SimpleCov.start "rails"

require "minitest/reporters"
Minitest::Reporters.use!(Minitest::Reporters::DefaultReporter.new)

require File.expand_path("../dummy/config/environment.rb",  __FILE__)
require "rails/test_help"
require "mocha/mini_test"

Rails.backtrace_cleaner.remove_silencers!

# Run any available migration from dummy app
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

# Load fixtures from the engine
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
Fogged.test_mode!

class ActiveSupport::TestCase
  fixtures :all

  def response_json
    @response_json ||= JSON.parse(response.body, :symbolize_names => true)
  end

  # helper for fork testing
  def in_a_fork
    ActiveRecord::Base.connection.disconnect!
    begin
      rout, wout = IO.pipe
      pid = fork do
        STDERR.reopen(wout)
        begin
          ActiveRecord::Base.establish_connection
          yield
        ensure
          ActiveRecord::Base.connection.disconnect!
        end

        SimpleCov.at_exit {}
      end
      Process.waitpid(pid)
      wout.close
      result = rout.readlines
      unless result.empty?
        result.each { |r| STDERR.puts r }
        fail("Test in a fork has failed")
      end
    ensure
      ActiveRecord::Base.establish_connection
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fogged-0.0.4 test/test_helper.rb
fogged-0.0.3 test/test_helper.rb