Sha256: 345ad257b96472b8f15b13547154fa04454bfbb08b96178105d27194c7cc9463

Contents?: true

Size: 1.79 KB

Versions: 4

Compression:

Stored size: 1.79 KB

Contents

require 'coveralls'
Coveralls.wear!

require 'minitest/autorun'
require 'ffaker'

# Loads lolcommits directly from the lib folder so don't have to create
# a gem before testing
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'lolcommits'

include Lolcommits

class PluginsTest < MiniTest::Test
  #
  # issue #57, https://github.com/mroth/lolcommits/issues/57
  #
  def test_tranzlate
    [['what the hell', '(WH|W)UT TEH HELL'], ['seriously wtf', 'SRSLEH WTF']].each do |normal, lol|
      tranzlated = Lolcommits::Plugin::Tranzlate.tranzlate(normal)
      assert_match(/^#{lol}/, tranzlated)
    end
  end

  #
  # issue #136, https://github.com/mroth/lolcommits/issues/136
  def test_lol_twitter_build_tweet
    long_commit_message = FFaker::Lorem.sentence(500)
    plugin              = Lolcommits::Plugin::LolTwitter.new(nil)
    max_tweet_size      = 116
    suffix              = '... #lolcommits'

    Lolcommits::Plugin::LolTwitter.send(:define_method, :max_tweet_size, proc { max_tweet_size })
    Lolcommits::Plugin::LolTwitter.send(:define_method, :configuration, proc { {} })
    assert_equal "#{long_commit_message[0..(max_tweet_size - suffix.length)]}#{suffix}", plugin.build_tweet(long_commit_message)
  end

  def test_lol_twitter_prefix_suffix
    plugin = Lolcommits::Plugin::LolTwitter.new(nil)
    Lolcommits::Plugin::LolTwitter.send(:define_method, :max_tweet_size, proc { 116 })
    assert_match 'commit msg #lolcommits', plugin.build_tweet('commit msg')

    plugin_config = {
      'prefix' => '@prefixing!',
      'suffix' => '#suffixing!'
    }
    Lolcommits::Plugin::LolTwitter.send(:define_method, :configuration, proc { plugin_config })
    assert_equal '@prefixing! commit msg #suffixing!', plugin.build_tweet('commit msg')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lolcommits-0.9.3 test/plugins_test.rb
lolcommits-0.9.3.pre3 test/plugins_test.rb
lolcommits-0.9.3.pre2 test/plugins_test.rb
lolcommits-0.9.3.pre1 test/plugins_test.rb