Sha256: 6c23a9503e241307482f4d6b9fafe0c255085b7d1f9ab9ded906eda53e784ba5

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

# -*- coding: utf-8 -*-
# vim:ft=ruby:enc=utf-8

require File.dirname(__FILE__)+'/helper'

class TestAlgorithmReader < Test::Unit::TestCase
  test_presence ToPass::AlgorithmReader

  def test_initialize
    assert_nothing_raised do
      klass.new( :basic_de )
    end
  end

  def test_load
    assert_respond_to klass, :load
    assert_kind_of Hash, klass.load(:basic_de)
  end

  def test_discover
    assert_respond_to klass, :discover
    assert_kind_of Array, klass.discover
  end

  def test_has_load_path
    assert_respond_to reader, :load_path
    assert_kind_of Array, reader.load_path
  end

  def test_load_path_contains_standard_dirs
    dirs = [
      '~/.to_pass/algorithms' ,
      "#{File.dirname(__FILE__)}/../lib/to_pass/algorithms"
    ]

    Pathname.any_instance.expects(:exist?).times(dirs.size).returns(true)

    dirs.each do |reldir|
      dir = Pathname.new(reldir).expand_path
      assert( reader.load_path.include?(dir), "#{reader.load_path.inspect} should include #{dir.inspect}" )
    end
  end

  def test_loads_from_user_dir
    with_algorithm_in_user_dir do
      assert_kind_of Hash, klass.load(:user_alg)
    end
  end

  protected

  def klass
    ToPass::AlgorithmReader
  end
  def reader(algorithm = :basic_de)
    @reader ||= klass.new(algorithm)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
to_pass-0.5.2 test/test_algorithm_reader.rb
to_pass-0.5.0 test/test_algorithm_reader.rb
to_pass-0.4.0 test/test_algorithm_reader.rb