Sha256: b641103c08474f1d4257e92bf0cb6cb4b7379c8ce9462071c0cbd07f61df8779

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

Stored size: 934 Bytes

Contents

# frozen_string_literal: true

class ActiveRecordDoctor::RunnerTest < Minitest::Test
  def setup
    @io = StringIO.new
    @runner = ActiveRecordDoctor::Runner.new(
      config: load_config,
      logger: ActiveRecordDoctor::Logger::Dummy.new,
      io: @io
    )
  end

  def test_run_one_raises_on_unknown_detectors
    assert_raises(KeyError) do
      @runner.run_one(:performance_issues)
    end
  end

  def test_run_all_returns_true_when_no_errors
    assert(@runner.run_all)
    assert(@io.string.blank?)
  end

  def test_run_all_returns_false_when_errors
    # Create a model without its underlying table to trigger an error.
    define_model(:User)

    refute(@runner.run_all)
    refute(@io.string.blank?)
  end

  def test_help_prints_help
    ActiveRecordDoctor.detectors.each do |name, _|
      @io.truncate(0)

      @runner.help(name)

      refute(@io.string.blank?, "expected help for #{name}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_record_doctor-1.12.0 test/active_record_doctor/runner_test.rb
active_record_doctor-1.11.0 test/active_record_doctor/runner_test.rb