Sha256: b44f3b1b45df3839b7043a4a86a37cd4f63b9ed6bdc92095ad6636d0b940c819

Contents?: true

Size: 937 Bytes

Versions: 4

Compression:

Stored size: 937 Bytes

Contents

require "spec_helper"

require 'lita/handlers/enhance/enhancer_example'

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

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

  it_should_behave_like 'an enhancer'

  it 'should enhance a string with EC2 instance IDs in it' do
    message = 'before i-fe4cddcb i-f4ff6aff after'
    substitutions = enhancer.enhance!(message, 1)
    expect(substitutions).to contain_exactly(
      sub_klass.new(7...17, '*box01*'),
      sub_klass.new(18...28, '*box02*')
    )
  end

  it 'should not enhance an unrecognized EC2 instance ID' do
    message = 'i-f00bac12'
    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 /instance IDs 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/instance_id_enhancer_spec.rb
lita-enhance-0.9.2 spec/lita/handlers/enhance/enhancers/instance_id_enhancer_spec.rb
lita-enhance-0.9.1 spec/lita/handlers/enhance/enhancers/instance_id_enhancer_spec.rb
lita-enhance-0.9.0 spec/lita/handlers/enhance/enhancers/instance_id_enhancer_spec.rb