Created
March 23, 2009 15:17
-
-
Save samaaron/83584 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| use("ispec") | |
| use("../lib/tik") | |
| describe(Tik, | |
| it("should exist and have the correct kind", | |
| Tik should have kind("Tik") | |
| ) | |
| describe("create", | |
| it("should be possible to create a new template from a given source text", | |
| Tik create("source text") should != nil | |
| ) | |
| it("should be possible to override the start of each token", | |
| Tik create("source", tokenOpenIdentifier: "<") source tokenOpenIdentifier should == "<" | |
| ) | |
| it("should be possible to override the end of each token", | |
| Tik create("source", tokenCloseIdentifier: ">") source tokenCloseIdentifier should == ">" | |
| ) | |
| it("should be possible to override the substitution token identifier", | |
| Tik create("source", substitutionTokenIdentifier: "sub") source substitutionTokenIdentifier should == "sub" | |
| ) | |
| it("should be possible to override the iteration token", | |
| Tik create("source", iterationTokenIdentifier: "iter") source iterationTokenIdentifier should == "iter" | |
| ) | |
| it("should be possible to override the conditional token", | |
| Tik create("source", conditionalTokenIdentifier: "cond") source conditionalTokenIdentifier should == "cond" | |
| ) | |
| it("should be possible to override the end token", | |
| Tik create("source", endTokenIdentifier: "end") source endTokenIdentifier should == "end" | |
| ) | |
| ) | |
| describe(Tik Source, | |
| describe("text", | |
| it("should be possible to retrieve the original source text", | |
| template = Tik create("source text") | |
| template source text should == "source text" | |
| ) | |
| ) | |
| describe("tokenOpenIdentifier", | |
| it("should have a default value of [", | |
| Tik create("source") source tokenOpenIdentifier should == "[" | |
| ) | |
| ) | |
| describe("tokenCloseIdentifier", | |
| it("should have a default value of ]", | |
| Tik create("source") source tokenCloseIdentifier should == "]" | |
| ) | |
| ) | |
| describe("substitutionTokenIdentifier", | |
| it("should have a default value of ~", | |
| Tik create("source") source substitutionTokenIdentifier should == "~" | |
| ) | |
| ) | |
| describe("iterationTokenIdentifier", | |
| it("should have a default value of #", | |
| Tik create("source") source iterationTokenIdentifier should == "#" | |
| ) | |
| ) | |
| describe("conditionalTokenIdentifier", | |
| it("should have a default value of ?", | |
| Tik create("source") source conditionalTokenIdentifier should == "?" | |
| ) | |
| ) | |
| describe("endTokenIdentifier", | |
| it("should have a default value of -", | |
| Tik create("source") source endTokenIdentifier should == "-" | |
| ) | |
| ) | |
| describe("iterationTokenMatcher", | |
| it("should have the correct default value", | |
| Tik create("source") source iterationTokenMatcher should == #// | |
| ) | |
| ) | |
| ) | |
| Describe(Tik Parser, | |
| describe("numIterationStartTokens", | |
| it("should know that there are no iteration start tokens in a source that doesn't contain any", | |
| Tik create("source with no itereation start tokens") parser numIterationStartTokens should == 0 | |
| ) | |
| it("should know that there is one iteration start token in a source that contains one", | |
| Tik create("source [#iterateMe] with an iteration start token") parser numIterationStartTokens should == 1 | |
| ) | |
| ) | |
| describe("valid", | |
| it("should validate source containing no tokens", | |
| Tik create("source with no tokens") parser valid? should == true | |
| ) | |
| ) | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment