Sha256: a8878ad1bdea1e4632066c8a59beacc46e2997ec6efc9fd5729afbb0eedb254b

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

require "spec_helper"

require 'lita/handlers/enhance/enhancer_example'

describe Lita::Handlers::Enhance::IpEnhancer do
  include_context 'indexed'

  let(:enhancer) { Lita::Handlers::Enhance::IpEnhancer.new(redis) }
  let(:sub_klass) { Lita::Handlers::Enhance::Substitution }

  it_should_behave_like 'an enhancer'

  it 'should enhance a string with EC2 external IPs in it' do
    message = 'before 54.214.188.37 184.169.229.1 after'
    substitutions = enhancer.enhance!(message, 1)
    expect(substitutions).to contain_exactly(
      sub_klass.new(7...20, '*box01*'),
      sub_klass.new(21...34, '*box02*')
    )
  end

  it 'should enhance a string with EC internal IPs in it' do
    message = 'before 10.254.74.121 10.196.75.1 after'
    substitutions = enhancer.enhance!(message, 1)
    expect(substitutions).to contain_exactly(
      sub_klass.new(7...20, '*box01*'),
      sub_klass.new(21...32, '*box02*')
    )
  end

  it 'should enhance a string with Linode IPs in it' do
    message = 'before 192.155.85.2 after'
    substitutions = enhancer.enhance!(message, 1)
    expect(substitutions).to contain_exactly(
      sub_klass.new(7...19, '*box03*')
    )
  end

  it 'should not enhance an unrecognized IP' do
    message = '127.0.0.1'
    substitutions = enhancer.enhance!(message, 1)
    expect(substitutions).to be_empty
  end

  it 'should return a custom response to to_s' do
    expect(enhancer.to_s).to match /IPs indexed/
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lita-enhance-0.9.3 spec/lita/handlers/enhance/enhancers/ip_enhancer_spec.rb
lita-enhance-0.9.2 spec/lita/handlers/enhance/enhancers/ip_enhancer_spec.rb
lita-enhance-0.9.1 spec/lita/handlers/enhance/enhancers/ip_enhancer_spec.rb
lita-enhance-0.9.0 spec/lita/handlers/enhance/enhancers/ip_enhancer_spec.rb