-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #256 from mroth/minitest
migrate unit tests from test-unit to mini-test
- Loading branch information
Showing
6 changed files
with
60 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- encoding : utf-8 -*- | ||
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::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 = Faker::Lorem.sentence(500) | ||
plugin = Lolcommits::LolTwitter.new(nil) | ||
max_tweet_size = 116 | ||
suffix = '... #lolcommits' | ||
|
||
Lolcommits::LolTwitter.send(:define_method, :max_tweet_size, Proc.new { max_tweet_size }) | ||
Lolcommits::LolTwitter.send(:define_method, :configuration, Proc.new { {} }) | ||
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::LolTwitter.new(nil) | ||
Lolcommits::LolTwitter.send(:define_method, :max_tweet_size, Proc.new { 116 }) | ||
assert_match 'commit msg #lolcommits', plugin.build_tweet('commit msg') | ||
|
||
plugin_config = { | ||
'prefix' => '@prefixing!', | ||
'suffix' => '#suffixing!' | ||
} | ||
Lolcommits::LolTwitter.send(:define_method, :configuration, Proc.new { plugin_config }) | ||
assert_equal '@prefixing! commit msg #suffixing!', plugin.build_tweet('commit msg') | ||
end | ||
end |