CompassInstaller extends ScssFrameworkInstaller { protected void correctFilesImports(final File sourcesFolder, final int level) throws IOException { final File[] listFiles = sourcesFolder.listFiles(); if (listFiles == null) { return; } for (final File file : listFiles) { if (file.isDirectory()) { this.correctFilesImports(file, level + 1); } else if (file.getName().endsWith(".scss")) { this.correctFileImport(level, file); } } } CompassInstaller(final Project project, final Logger logger);   }
@Test public void correctFilesImports() throws IOException { final CompassInstaller compassInstaller = new CompassInstaller( this.project, this.logger); final File scssFileLevel0 = this.folder.newFile(".scss"); FileUtils.write(scssFileLevel0, "@import \"compass/test0\"",Charset.defaultCharset()); final File folderLevel0 = this.folder.newFolder(); final File scssFileLevel1 = Paths .get(folderLevel0.getAbsolutePath(), ".scss").toFile(); final String scssFileLevel1Input = new StringBuilder( System.lineSeparator()) .append(" @import \"compass/test10\"") .append(System.lineSeparator()) .append("$usage: prefix-usage($prefix, $capability, $capability-options);") .toString(); FileUtils.write(scssFileLevel1, scssFileLevel1Input,Charset.defaultCharset()); final File txtFileLevel1 = Paths .get(folderLevel0.getAbsolutePath(), ".txt").toFile(); FileUtils.write(txtFileLevel1, "import \"compass/test11\"",Charset.defaultCharset()); compassInstaller.correctFilesImports(this.folder.getRoot(), 0); Assert.assertEquals("@import \"compass/test0\"", FileUtils.readFileToString(scssFileLevel0,Charset.defaultCharset())); final String scssFileLvel1Result = new StringBuilder( System.lineSeparator()) .append(" @import \"../compass/test10\"") .append(System.lineSeparator()) .append("$usage: 0; .toString(); Assert.assertEquals(scssFileLvel1Result, FileUtils.readFileToString(scssFileLevel1,Charset.defaultCharset())); Assert.assertEquals("import \"compass/test11\"", FileUtils.readFileToString(txtFileLevel1, Charset.defaultCharset())); }