Sha256: c781528d3a6feb321894dfdad438a01eb56eecb3654a682fbfa7c01d71f75674

Contents?: true

Size: 1.96 KB

Versions: 14

Compression:

Stored size: 1.96 KB

Contents

require_relative "helper"

class TestGmanBin < Minitest::Test

  def setup
    @output, @status = test_bin("whitehouse.gov")
  end

  should "parse the domain" do
    output, status = test_bin("bar.gov")
    assert_match /Domain  : bar.gov/, output

    output, status = test_bin("foo@bar.gov")
    assert_match /Domain  : bar.gov/, output

    output, status = test_bin("http://bar.gov/foo")
    assert_match /Domain  : bar.gov/, output
  end

  should "err on invalid domains" do
    output, status = test_bin("foo.invalid")
    assert_equal 1, status.exitstatus
    assert_match /Invalid domain/, output
  end

  should "err on non-government domains" do
    output, status = test_bin("github.com")
    assert_equal 1, status.exitstatus
    assert_match /Not a government domain/, output
  end

  should "know the type" do
    assert_match /federal/, @output
    assert_equal 0, @status.exitstatus
  end

  should "know the agency" do
    assert_match /Executive Office of the President/, @output
    assert_equal 0, @status.exitstatus
  end

  should "know the country" do
    assert_match /United States/, @output
    assert_equal 0, @status.exitstatus
  end

  should "know the city" do
    assert_match /Washington/, @output
    assert_equal 0, @status.exitstatus
  end

  should "know the state" do
    assert_match /DC/, @output
    assert_equal 0, @status.exitstatus
  end

  should "allow you to disable colorization" do
    output, status = test_bin("whitehouse.gov", "--no-color")
    refute_match /\[0;32;49m/, output
  end

  should "color by default" do
    assert_match /\[0;32;49m/, @output
  end

  should "show help text" do
    output, status = test_bin
    assert_match /Usage/i, output

    output, status = test_bin("")
    assert_match /Usage/i, output

    output, status = test_bin("--no-color")
    assert_match /Usage/i, output
  end

  should "know if a country is sanctioned" do
    output, status = test_bin "kim@pyongyang.gov.kp"
    assert_match /SANCTIONED/, output
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
gman-5.0.3 test/test_gman_bin.rb
gman-5.0.2 test/test_gman_bin.rb
gman-5.0.1 test/test_gman_bin.rb
gman-5.0.0 test/test_gman_bin.rb
gman-4.7.1 test/test_gman_bin.rb
gman-4.7.0 test/test_gman_bin.rb
gman-4.6.5 test/test_gman_bin.rb
gman-4.6.4 test/test_gman_bin.rb
gman-4.6.3 test/test_gman_bin.rb
gman-4.6.2 test/test_gman_bin.rb
gman-4.6.1 test/test_gman_bin.rb
gman-4.6.0 test/test_gman_bin.rb
gman-4.5.1 test/test_gman_bin.rb
gman-4.5.0 test/test_gman_bin.rb