Sha256: fe497c48213ee2bf0a906fd810db19c93b4b898e1f251d16e45f5b4645d0df53

Contents?: true

Size: 973 Bytes

Versions: 2

Compression:

Stored size: 973 Bytes

Contents

# coding: utf-8

require 'test_helper'

include IRCSupport::Masks

describe "Masks" do
  it "should normalize the mask" do
    normalize_mask('*@*').must_equal '*!*@*'
    normalize_mask('foo*').must_equal 'foo*!*@*'
  end

  banmask = 'stalin*!*@*'

  it "should match the mask" do
    match = 'stalin!joe@kremlin.ru'
    matches_mask(banmask, match).must_equal true
    result = matches_mask_array([banmask], [match])
    result.must_be_kind_of Hash
    result.must_include 'stalin*!*@*'
    result['stalin*!*@*'].must_be_kind_of Array
    result['stalin*!*@*'].must_include "stalin!joe@kremlin.ru"
  end

  it "should not match the mask" do
    no_match = 'BinGOs!foo@blah.com'
    matches_mask(banmask, no_match).must_equal false
    no_result = matches_mask_array([banmask], [no_match])
    no_result.must_be_kind_of Hash
    no_result.must_be_empty
  end

  it "should fail miserably" do
    proc { matches_mask('$r:Lee*', 'foo') }.must_raise ArgumentError
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ircsupport-0.2.0 test/masks_test.rb
ircsupport-0.1.0 test/masks_test.rb