Sha256: 72bd616716c4d59228b62415b941f3777e871273b758ba5a203ee5247f79ea4a

Contents?: true

Size: 1.69 KB

Versions: 4

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

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

  let(:session) { Lita::Handlers::Enhance::Session.new(redis, 'foo', 30) }

  it 'should return nil for last_level and last_message if no message has been enhanced' do
    expect(session.last_message).to be_nil
    expect(session.last_level).to be_nil
  end

  it 'should return the last message and level after enhancing a message' do
    session.enhance!('hello world', 2)
    expect(session.last_message).to eq('hello world')
    expect(session.last_level).to eq(2)
  end

  it 'should edit the message to enhance it' do
    message = 'hello world box01'
    enhanced_message = session.enhance!(message, 1)
    expect(enhanced_message).to eq('hello world *box01*')
  end

  it 'should enhance at the supplied level' do
    message = 'hello world box01'
    enhanced_message = session.enhance!(message, 2)
    expect(enhanced_message).to eq('hello world *box01 (us-west-2b)*')
  end

  it 'should should take care to not double enhance text', focus: true do
    message = 'hello world 10.254.74.122'
    enhanced_message = session.enhance!(message, 2)
    expect(enhanced_message).to eq('hello world *stg-web01 (us-west-2b)*')
  end

  it 'should be able to enhance multiple items' do
    message = 'box01 box02'
    enhanced_message = session.enhance!(message, 2)
    expect(enhanced_message).to eq('*box01 (us-west-2b)* *box02 (us-west-1c)*')
  end

  it 'should be able to correctly apply substitutions that result in shorter text' do
    message = 'before 22:00:0A:FE:4A:79 F2:3C:91:56:A2:00 after'
    enhanced_message = session.enhance!(message, 1)
    expect(enhanced_message).to eq('before *box01* *box03* after')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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