-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0-M3: Made it so metaClasses are not modified by default but are fo…
…r the gradle plugin; also added processors to GroocssExtension and added tests
- Loading branch information
1 parent
ab6495f
commit 7e541d3
Showing
8 changed files
with
179 additions
and
10 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
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
30 changes: 30 additions & 0 deletions
30
groocss-gradle-plugin/src/test/groovy/org/groocss/GroocssExtensionSpec.groovy
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,30 @@ | ||
package org.groocss | ||
|
||
import spock.lang.Specification | ||
|
||
class GroocssExtensionSpec extends Specification { | ||
|
||
def "should have basic properties" () { | ||
expect: | ||
def ext = new GroocssExtension(compress: true, prettyPrint: true) | ||
ext.compress | ||
ext.prettyPrint | ||
ext.addMoz | ||
ext.addMs | ||
ext.addOpera | ||
ext.addWebkit | ||
} | ||
|
||
def "should have charset default of null" () { | ||
expect: | ||
def ext = new GroocssExtension() | ||
ext.charset == null | ||
} | ||
|
||
def "should have processors which is empty list by default" () { | ||
expect: | ||
def ext = new GroocssExtension() | ||
ext.processors.empty | ||
ext.processors instanceof Set | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
groocss-gradle-plugin/src/test/groovy/org/groocss/GroocssPluginSpec.groovy
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,35 @@ | ||
package org.groocss | ||
|
||
import org.gradle.api.NamedDomainObjectContainer | ||
import org.gradle.api.Project | ||
import org.gradle.api.Task | ||
import org.gradle.api.plugins.ExtensionContainer | ||
import org.gradle.api.tasks.TaskContainer | ||
import spock.lang.Specification | ||
|
||
class GroocssPluginSpec extends Specification { | ||
|
||
|
||
def "GroocssPlugin should work as a plugin" () { | ||
given: | ||
def project = Mock(Project.class) | ||
def extensions = Mock(ExtensionContainer) | ||
def files = Mock(NamedDomainObjectContainer) | ||
def tasks = Mock(TaskContainer) | ||
def convertCss = Mock(Task) | ||
when: | ||
def p = new GroocssPlugin() | ||
|
||
p.apply(project) | ||
then: | ||
project.getExtensions() >> { extensions } | ||
1 * extensions.create("groocss", GroocssExtension) | ||
project.container(GrooCssFile) >> files | ||
project.getTasks() >> { tasks } | ||
1* tasks.findByName("build") | ||
1* tasks.findByName("processResources") | ||
project.task("convertCss") >> { convertCss } | ||
1* convertCss.doFirst(_) | ||
} | ||
|
||
} |
78 changes: 78 additions & 0 deletions
78
groocss-gradle-plugin/src/test/groovy/org/groocss/GroocssTaskSpec.groovy
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,78 @@ | ||
package org.groocss | ||
|
||
import org.gradle.api.file.CopySpec | ||
import org.gradle.api.file.RelativePath | ||
import org.gradle.api.internal.file.copy.FileCopyDetailsInternal | ||
import org.gradle.internal.file.PathToFileResolver | ||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
class GroocssTaskSpec extends Specification { | ||
|
||
@Unroll | ||
def "should convert regular groocss file #i"() { | ||
given: | ||
def resolver = Mock(PathToFileResolver) | ||
def copySpec = Mock(CopySpec) | ||
def details = Mock(FileCopyDetailsInternal) | ||
def path = Mock(RelativePath) | ||
def config = new Config().noExts().compress() | ||
def target = File.createTempFile("test", ".css.groovy") | ||
File newTarget = new File(target.parentFile, GroocssPlugin.toCssName(target.name)) | ||
def testFile = File.createTempFile("input", ".css.groovy") | ||
when: | ||
testFile.text = groocss | ||
new GroocssTask.GroocssFileAction(resolver, config, copySpec).processFile(details) | ||
then: | ||
details.getRelativePath() >> { path } | ||
resolver.resolve(_) >> { target } | ||
details.copyTo(_) >> { target.text = testFile.text } | ||
|
||
assert newTarget.isFile() | ||
println(newTarget.text) | ||
assert newTarget.text == css | ||
where: | ||
i || groocss || css | ||
1 | '''import org.groocss.Config | ||
'test'.groocss(new Config().noExts().compress()) { | ||
body { fontSize 2.em color 0.color } | ||
article { padding 2.em } | ||
'thing'.id { fontSize 200.percent } | ||
keyframes('test') { | ||
from { color black } to { color red } | ||
} | ||
} | ||
''' | "body{font-size: 2em;color: #000000;}article{padding: 2em;}#thing{font-size: 200%;}"+ | ||
"@keyframes test {from{color: Black;}to{color: Red;}}" | ||
2 | ''' | ||
body { fontSize 2.em color 0.color } | ||
article { padding 2.em } | ||
'thing'.id { fontSize 200.percent } | ||
'test'.kf { | ||
from { color black } to { color red } | ||
} | ||
''' | "body{font-size: 2em;color: #000000;}article{padding: 2em;}#thing{font-size: 200%;}"+ | ||
"@keyframes test {from{color: Black;}to{color: Red;}}" | ||
3 | 'assert 1.initMetaClassesCalled()' | '' | ||
} | ||
|
||
def "should have default charset"() { | ||
given: | ||
def resolver = Mock(PathToFileResolver) | ||
def copySpec = Mock(CopySpec) | ||
def config = new Config() | ||
expect: | ||
def action = new GroocssTask.GroocssFileAction(resolver, config, copySpec) | ||
action.charset == 'UTF-8' | ||
} | ||
|
||
|
||
} |
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