test/test_source.rb in pdd-0.20.3 vs test/test_source.rb in pdd-0.20.4
- old
+ new
@@ -26,20 +26,18 @@
# Source test.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2014-2018 Yegor Bugayenko
# License:: MIT
class TestSource < Minitest::Test
- # @todo #85:30min Make this test pass on AppVeyor.
def test_parsing
- skip('Skipped because it fails on AppVeyor')
Dir.mktmpdir 'test' do |dir|
file = File.join(dir, 'a.txt')
File.write(
file,
"
* \x40todo #44 привет,
- * how are you\t\r\tdoing?
+ * how are you\t\tdoing?
* -something else
Something else
~~ \x40todo #ABC-3 this is another puzzle
~~ and it also has to work
"
@@ -88,22 +86,20 @@
assert !error.to_s.index("\x40todo is not followed by").nil?
end
end
def test_failing_on_broken_unicode
- skip if Gem.win_platform?
Dir.mktmpdir 'test' do |dir|
file = File.join(dir, 'xx.txt')
File.write(file, ' * \x40todo #44 this is a broken unicode: ' + 0x92.chr)
assert_raises PDD::Error do
PDD::VerboseSource.new(file, PDD::Source.new(file, 'xx')).puzzles
end
end
end
def test_failing_on_invalid_puzzle_without_hash_sign
- skip('doesnt work now')
Dir.mktmpdir 'test' do |dir|
file = File.join(dir, 'a.txt')
File.write(
file,
"
@@ -111,11 +107,11 @@
"
)
error = assert_raises PDD::Error do
PDD::VerboseSource.new(file, PDD::Source.new(file, 'hey')).puzzles
end
- assert !error.message.index('Incorrect format').nil?
+ assert !error.message.index('is not followed by a puzzle marker').nil?
end
end
def test_failing_on_puzzle_without_leading_space
Dir.mktmpdir 'test' do |dir|
@@ -194,8 +190,43 @@
assert_equal '1-1', puzzle.props[:lines]
assert_equal 'this is the puzzle', puzzle.props[:body]
assert_equal 'test', puzzle.props[:author]
assert_nil puzzle.props[:email]
assert_match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, puzzle.props[:time])
+ end
+ end
+
+ def test_uses_github_login
+ skip if Gem.win_platform?
+ Dir.mktmpdir 'test' do |dir|
+ raise unless system("
+ cd '#{dir}'
+ git init --quiet .
+ git config user.email yegor256@gmail.com
+ git config user.name test
+ echo '\x40todo #1 this is the puzzle' > a.txt
+ git add a.txt
+ git commit --quiet -am 'first version'
+ ")
+ list = PDD::Source.new(File.join(dir, 'a.txt'), '').puzzles
+ assert_equal 1, list.size
+ puzzle = list.first
+ assert_equal '@yegor256', puzzle.props[:author]
+ end
+ end
+
+ def test_skips_thymeleaf_close_tag
+ Dir.mktmpdir 'test' do |dir|
+ file = File.join(dir, 'a.txt')
+ File.write(
+ file,
+ '<!--/* @todo #123 puzzle info */-->'
+ )
+ list = PDD::VerboseSource.new(file, PDD::Source.new(file, 'hey')).puzzles
+ assert_equal 1, list.size
+ puzzle = list.first
+ assert_equal '1-1', puzzle.props[:lines]
+ assert_equal 'puzzle info', puzzle.props[:body]
+ assert_equal '123', puzzle.props[:ticket]
end
end
end