-
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.
Added imports and comments (ability to import file/reader/stream with…
… parameters; and ability to include comments for output)
- Loading branch information
1 parent
9fdf6c3
commit c6f1512
Showing
7 changed files
with
158 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.groocss | ||
|
||
import spock.lang.Specification | ||
|
||
/** | ||
* Created by adavis on 8/10/17. | ||
*/ | ||
class CommentSpec extends Specification { | ||
|
||
def "comment should include comment in output"() { | ||
given: | ||
def css = GrooCSS.process { | ||
comment 'I am Groocss!' | ||
} | ||
expect: | ||
'/* I am Groocss! */' == "$css" | ||
} | ||
|
||
def "comment should print in order"() { | ||
given: | ||
def css = GrooCSS.process { | ||
comment 'comment1' | ||
a { fontSize 18.px } | ||
comment 'comment2' | ||
aside { fontSize 15.px } | ||
} | ||
expect: | ||
"$css" == ''' | ||
/* comment1 */ | ||
a{font-size: 18px;} | ||
/* comment2 */ | ||
aside{font-size: 15px;}'''.stripIndent().trim() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.groocss | ||
|
||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
/** | ||
* Created by adavis on 8/10/17. | ||
*/ | ||
class ImportSpec extends Specification { | ||
|
||
@Shared | ||
File otherCss | ||
|
||
def setup() { | ||
otherCss = new File(File.createTempDir(),"other.css") | ||
} | ||
|
||
@Unroll | ||
def "import should just import it: #name"() { | ||
given: | ||
otherCss.text = "a {color blue}" | ||
expect: | ||
def css = GrooCSS.process closure | ||
'a{color: Blue;}' == "$css".trim() | ||
where: | ||
name | closure | ||
'File name' | { importFile otherCss.absoluteFile.toString() } | ||
'File' | { importFile otherCss.absoluteFile } | ||
'String' | { importString otherCss.text } | ||
'InputStream' | { importStream otherCss.newInputStream() } | ||
} | ||
|
||
def "import should be put last"() { | ||
given: | ||
otherCss.text = "a {color blue}" | ||
expect: | ||
def css = GrooCSS.process { | ||
importFile otherCss.absoluteFile | ||
header { fontSize '15pt' } | ||
} | ||
'header{font-size: 15pt;}\na{color: Blue;}' == "$css".trim() | ||
} | ||
|
||
def "import should allow parameters"() { | ||
given: | ||
otherCss.text = "a {color linkColor}" | ||
expect: | ||
def css = GrooCSS.process { | ||
importFile otherCss.absoluteFile, linkColor: '#456789' | ||
} | ||
'a{color: #456789;}' == "$css".trim() | ||
} | ||
|
||
@Unroll | ||
def "import should allow #type parameter"() { | ||
given: | ||
otherCss.text = "a {color linkColor}" | ||
expect: | ||
def css = GrooCSS.process { | ||
importFile otherCss.absoluteFile, linkColor: value, param2: 123 | ||
} | ||
'a{color: #123456;}' == "$css".trim() | ||
where: | ||
type | value | ||
'String' | '#123456' | ||
'Integer' | 0x123456 | ||
'Color' | new Color(0x123456) | ||
} | ||
} |
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