From 3fbe6a27601dc5e88d843d7928ec9a509b21ef31 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sat, 23 Mar 2019 16:27:51 -0600 Subject: [PATCH] Implement Java naming --- src/spectator/formatting/junit_test_case.cr | 7 ++++++- src/spectator/formatting/junit_test_suite.cr | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/spectator/formatting/junit_test_case.cr b/src/spectator/formatting/junit_test_case.cr index 4f7e4cb..80de989 100644 --- a/src/spectator/formatting/junit_test_case.cr +++ b/src/spectator/formatting/junit_test_case.cr @@ -28,7 +28,12 @@ module Spectator::Formatting # Java-ified class name created from the spec. private def classname - "TODO" + path = result.example.source.path + file = File.basename(path) + ext = File.extname(file) + name = file[0...-(ext.size)] + dir = path[0...-(file.size + 1)] + {dir.gsub('/', '.').underscore, name.camelcase}.join('.') end end end diff --git a/src/spectator/formatting/junit_test_suite.cr b/src/spectator/formatting/junit_test_suite.cr index ffff476..9abca41 100644 --- a/src/spectator/formatting/junit_test_suite.cr +++ b/src/spectator/formatting/junit_test_suite.cr @@ -32,12 +32,17 @@ module Spectator::Formatting # Java-ified name of the test suite. private def name - "TODO" + file = File.basename(@path) + ext = File.extname(file) + name = file[0...-(ext.size)] + name.camelcase end # Java-ified package (path) of the test suite. private def package - "TODO" + file = File.basename(@path) + dir = @path[0...-(file.size + 1)] + dir.gsub('/', '.').underscore end # Selector for creating a JUnit test case based on a result.