Skip to content

Commit

Permalink
[cqfn#163] update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbao01 committed Jan 3, 2022
1 parent 647e4ea commit db1daed
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 60 deletions.
17 changes: 0 additions & 17 deletions features/catches_broken_puzzles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,4 @@ Feature: Catches Broken Puzzles
}
}
"""
When I run pdd it fails with "Space expected"
When I run pdd it fails with "Sample.java:6"

Scenario: Throwing exception on yet another broken puzzle
Given I have a "Sample.java" file with content:
"""
public class Main {
//
// @todo #13 This puzzle has an incorrect format
// because there is no space character in the
// second and third lines
//
public void main(String[] args) {
// later
}
}
"""
When I run pdd it fails with "Space expected"
4 changes: 4 additions & 0 deletions features/parsing.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Feature: Parsing
* @todo #ABC-67:15min And this one ever later
* @todo #F-78-3:2h/DEV This is for a developer
* who will join us later
* @todo #44 This puzzle has a correct format
* even though it doesn't start with a space on
* the second and the third lines
*/
public void main(String[] args) {
// later
Expand All @@ -48,3 +51,4 @@ Feature: Parsing
And XML matches "//puzzle[ticket='F-78-3' and lines='5-6']"
And XML matches "//puzzle[ticket='ABC-67' and estimate='15']"
And XML matches "//puzzle[ticket='F-78-3' and estimate='120']"
And XML matches "//puzzle[ticket='44' and lines='7-9']"
35 changes: 10 additions & 25 deletions test/test_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def test_parsing
list = source.puzzles
assert_equal 2, list.size
puzzle = list.first
assert_equal '2-3', puzzle.props[:lines]
assert_equal 'привет, how are you doing?', puzzle.props[:body]
assert_equal '2-4', puzzle.props[:lines]
assert_equal 'привет, how are you doing? -something else', \
puzzle.props[:body]
assert_equal '44', puzzle.props[:ticket]
assert puzzle.props[:author].nil?
assert puzzle.props[:email].nil?
Expand Down Expand Up @@ -78,33 +79,16 @@ def test_parsing_leading_spaces
end
end

def test_failing_on_invalid_puzzle
Dir.mktmpdir 'test' do |dir|
file = File.join(dir, 'a.txt')
File.write(
file,
"
* \x40todo #44 this is an incorrectly formatted puzzle,
* with a second line without a leading space
"
)
error = assert_raises PDD::Error do
stub_source_find_github_user(file, 'hey', &:puzzles)
end
assert !error.message.index('Space expected').nil?
end
end

def test_succeed_despite_bad_puzzles
Dir.mktmpdir 'test' do |dir|
file = File.join(dir, 'a.txt')
File.write(
file,
"
* \x40todo #44 this is an incorrectly formatted puzzle,
* \x40todo #44 this is a correctly formatted puzzle,
* with a second line without a leading space
Another badly formatted puzzle
* \x40todo this puzzle misses ticket name/number
* \x40todo this bad puzzle misses ticket name/number
Something else
* \x40todo #123 This puzzle is correctly formatted
"
Expand All @@ -113,11 +97,12 @@ def test_succeed_despite_bad_puzzles
stub_source_find_github_user(file, 'hey') do |source|
list = source.puzzles
PDD.opts = nil
assert_equal 1, list.size
assert_equal 2, list.size
puzzle = list.first
assert_equal '7-7', puzzle.props[:lines]
assert_equal 'This puzzle is correctly formatted', puzzle.props[:body]
assert_equal '123', puzzle.props[:ticket]
assert_equal '2-3', puzzle.props[:lines]
assert_equal 'this is a correctly formatted puzzle, with a second ' \
'line without a leading space', puzzle.props[:body]
assert_equal '44', puzzle.props[:ticket]
end
end
end
Expand Down
18 changes: 0 additions & 18 deletions test/test_source_todo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,6 @@ def test_todo_colon_parsing_multi_line
)
end

def test_todo_failing_no_space_on_second_line
check_invalid_puzzle(
"
* TODO #45 this puzzle
* has not space on second line",
'Space expected'
)
end

def test_todo_colon_failing_no_space_on_second_line
check_invalid_puzzle(
"
* TODO: #45 this puzzle
* has not space on second line",
'Space expected'
)
end

def test_todo_failing_no_ticket
check_invalid_puzzle(
"
Expand Down

0 comments on commit db1daed

Please sign in to comment.