forked from searls/jasmine-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for require.js scriptloader
- Loading branch information
Showing
52 changed files
with
1,220 additions
and
253 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Feature: Support amd modules in javaScript | ||
|
||
In order to support amd modules | ||
I want the maven build to include specs using require.js format instead of script tags | ||
So that tests can be loaded using the require.js scriptloader | ||
|
||
Scenario: project with javascript using require.js | ||
|
||
Given I am currently in the "jasmine-webapp-amd-support" project | ||
When I run "mvn clean test" | ||
Then the build should succeed | ||
And I should see "Results: 2 specs, 0 failures" |
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
101 changes: 101 additions & 0 deletions
101
src/main/java/com/github/searls/jasmine/io/scripts/AbstractScriptResolver.java
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,101 @@ | ||
package com.github.searls.jasmine.io.scripts; | ||
|
||
import com.github.searls.jasmine.io.RelativizesFilePaths; | ||
import com.github.searls.jasmine.model.ScriptSearch; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.LinkedHashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public abstract class AbstractScriptResolver implements ScriptResolver { | ||
private Set<String> sources; | ||
private Set<String> specs; | ||
protected File baseDir; | ||
protected ScriptSearch scriptSearchSources; | ||
protected ScriptSearch scriptSearchSpecs; | ||
protected List<String> preloads; | ||
protected RelativizesASetOfScripts relativizer = new RelativizesASetOfScripts(); | ||
protected RelativizesFilePaths relativizesFilePaths = new RelativizesFilePaths(); | ||
|
||
public void resolveScripts() throws IOException { | ||
ResolvesLocationOfPreloadSources resolvesLocationOfPreloadSources = new ResolvesLocationOfPreloadSources(); | ||
FindsScriptLocationsInDirectory findsScriptLocationsInDirectory = new FindsScriptLocationsInDirectory(); | ||
|
||
setScriptsToPreload(new LinkedHashSet<String>(resolvesLocationOfPreloadSources.resolve(preloads, scriptSearchSources.getDirectory(), scriptSearchSpecs.getDirectory()))); | ||
setSources(new LinkedHashSet<String>(findsScriptLocationsInDirectory.find(scriptSearchSources))); | ||
setSpecs(new LinkedHashSet<String>(findsScriptLocationsInDirectory.find(scriptSearchSpecs))); | ||
|
||
} | ||
|
||
public Set<String> getPreloads() { | ||
return this.scriptsToPreload; | ||
} | ||
|
||
public Set<String> getSources() { | ||
return this.sources; | ||
} | ||
|
||
public Set<String> getSpecs() { | ||
return this.specs; | ||
} | ||
|
||
public Set<String> getAllScripts() { | ||
return addAllScripts(scriptsToPreload, sources, specs); | ||
} | ||
|
||
public String getSourceDirectory() { | ||
return scriptSearchSources.getDirectory().getAbsolutePath(); | ||
} | ||
|
||
public String getSpecDirectoryPath() { | ||
return scriptSearchSpecs.getDirectory().getAbsolutePath(); | ||
} | ||
|
||
public Set<String> getSourcesRelativePath() throws IOException { | ||
return relativizer.relativize(baseDir, this.sources); | ||
} | ||
|
||
public Set<String> getSpecsRelativePath() throws IOException { | ||
return relativizer.relativize(baseDir, this.specs); | ||
} | ||
|
||
public Set<String> getPreloadsRelativePath() throws IOException { | ||
return relativizer.relativize(baseDir, this.scriptsToPreload); | ||
} | ||
|
||
public Set<String> getAllScriptsRelativePath() throws IOException { | ||
return addAllScripts(getPreloadsRelativePath(), getSourcesRelativePath(), getSpecsRelativePath()); | ||
} | ||
|
||
public String getSourceDirectoryRelativePath() throws IOException { | ||
return relativizesFilePaths.relativize(baseDir, scriptSearchSources.getDirectory()); | ||
} | ||
|
||
public String getSpecDirectoryRelativePath() throws IOException { | ||
return relativizesFilePaths.relativize(baseDir, scriptSearchSpecs.getDirectory()); | ||
} | ||
|
||
private Set<String> addAllScripts(Set<String> preloadedSources, Set<String> sources, Set<String> specs) { | ||
LinkedHashSet<String> allScripts = new LinkedHashSet<String>(); | ||
allScripts.addAll(preloadedSources); | ||
allScripts.addAll(sources); | ||
allScripts.addAll(specs); | ||
return allScripts; | ||
} | ||
|
||
private Set<String> scriptsToPreload; | ||
|
||
public void setScriptsToPreload(Set<String> scriptsToPreload) { | ||
this.scriptsToPreload = scriptsToPreload; | ||
} | ||
|
||
public void setSources(Set<String> sources) { | ||
this.sources = sources; | ||
} | ||
|
||
public void setSpecs(Set<String> specs) { | ||
this.specs = specs; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/github/searls/jasmine/io/scripts/ProjectDirScripResolver.java
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,17 @@ | ||
package com.github.searls.jasmine.io.scripts; | ||
|
||
import com.github.searls.jasmine.model.ScriptSearch; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public class ProjectDirScripResolver extends AbstractScriptResolver { | ||
|
||
public ProjectDirScripResolver(File projectBaseDir, ScriptSearch sources, ScriptSearch specs, List<String> preloads) throws IOException { | ||
this.preloads = preloads; | ||
this.scriptSearchSpecs = specs; | ||
this.scriptSearchSources = sources; | ||
this.baseDir = projectBaseDir; | ||
} | ||
} |
Oops, something went wrong.