Sha256: 94a95481f724303593d9cc432a17343c72344a4a295f9bca0f694f3a5df56a54

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

require 'test_helper'

class InstitutionListTest < ActiveSupport::TestCase

  def setup
    InstitutionList.class_variable_set(:@@institutions_yaml_path, nil)
    InstitutionList.instance.instance_variable_set(:@institutions, nil)
    @yaml_path = "#{File.dirname(__FILE__)}/../support/config/institutions.yml"
  end
  
  test "yaml_path" do
    assert_raise ArgumentError do
      InstitutionList.yaml_path=  nil
    end
    assert_raise NameError do
      InstitutionList.yaml_path= "garbage_path"
    end
    assert_nothing_raised do
      InstitutionList.yaml_path= @yaml_path
      InstitutionList.instance.institutions
    end
  end
  
  test "defined" do
    assert(!InstitutionList.institutions_defined?)
    InstitutionList.yaml_path= @yaml_path
    assert(InstitutionList.institutions_defined?)
  end
  
  test "defaults" do
    assert_raise ArgumentError do
      InstitutionList.instance.defaults
    end
    assert_nothing_raised do
      InstitutionList.yaml_path= @yaml_path
      InstitutionList.instance.defaults
    end
    assert_not_nil(InstitutionList.instance.defaults)
    assert_equal([InstitutionList.instance.get("NYUAD")], InstitutionList.instance.defaults)
  end
  
  test "institutions_with_ip" do
    assert_raise ArgumentError do
      InstitutionList.instance.institutions_with_ip "128.122.149.122"
    end
    assert_nothing_raised do
      InstitutionList.yaml_path= @yaml_path
      InstitutionList.instance.institutions_with_ip "128.122.149.122"
    end
    assert_not_nil(InstitutionList.instance.institutions_with_ip "128.122.149.122")
    assert_equal([InstitutionList.instance.get("NYU")], InstitutionList.instance.institutions_with_ip("128.122.149.122"))
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
authpds-0.0.18 test/unit/institution_list_test.rb
authpds-0.0.17 test/unit/institution_list_test.rb