Sha256: 5e53918529e11f5f71d1858cb22690bc9c56f90ce4308cc53995ffa47cdcfa7a

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8

class Nanoc::CLI::ErrorHandlerTest < MiniTest::Unit::TestCase

  include Nanoc::TestHelpers

  def setup
    super
    @handler = Nanoc::CLI::ErrorHandler.new
  end

  def test_resolution_for_with_unknown_gem
    error = LoadError.new('no such file to load -- afjlrestjlsgrshter')
    assert_nil @handler.send(:resolution_for, error)
  end

  def test_resolution_for_with_known_gem_without_bundler
    def @handler.using_bundler? ; false ; end
    error = LoadError.new('no such file to load -- kramdown')
    assert_match(/^Install the 'kramdown' gem using `gem install kramdown`./, @handler.send(:resolution_for, error))
  end

  def test_resolution_for_with_known_gem_with_bundler
    def @handler.using_bundler? ; true ; end
    error = LoadError.new('no such file to load -- kramdown')
    assert_match(/^Make sure the gem is added to Gemfile/, @handler.send(:resolution_for, error))
  end

  def test_resolution_for_with_not_load_error
    error = RuntimeError.new('nuclear meltdown detected')
    assert_nil @handler.send(:resolution_for, error)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nanoc-3.6.1 test/cli/test_error_handler.rb
nanoc-3.6.0 test/cli/test_error_handler.rb