Sha256: e6f008065e9e47b1bbf22ad8d2409a59c40ae74822de43e6f5332a427a375a15

Contents?: true

Size: 868 Bytes

Versions: 10

Compression:

Stored size: 868 Bytes

Contents

require 'minitest/autorun'
require_relative '../lib/twiglet/message'

describe Twiglet::Message do
  it 'raises if message is empty' do
    assert_raises RuntimeError do
      Twiglet::Message.new('   ')
    end
  end

  it 'raises if message is not provided' do
    assert_raises RuntimeError do
      Twiglet::Message.new(foo: 'bar')
    end
  end

  it 'raises on unrecognized inputs' do
    assert_raises RuntimeError do
      Twiglet::Message.new(OpenStruct.new(message: 'hello'))
    end
  end

  it 'returns a message hash from a string' do
    assert_equal Twiglet::Message.new('hello, world'), { message: 'hello, world' }
  end

  it 'returns a message hash with symbolized keys' do
    input_message = { 'key' => 'value', 'message' => 'hello, world' }
    assert_equal Twiglet::Message.new(input_message), { key: 'value', message: 'hello, world' }
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
twiglet-3.0.8 test/message_test.rb
twiglet-3.0.6 test/message_test.rb
twiglet-3.0.5 test/message_test.rb
twiglet-3.0.4 test/message_test.rb
twiglet-3.0.3 test/message_test.rb
twiglet-3.0.2 test/message_test.rb
twiglet-3.0.1 test/message_test.rb
twiglet-3.0.0 test/message_test.rb
twiglet-2.4.0 test/message_test.rb
twiglet-2.3.11 test/message_test.rb