Use spectre-build for tests

This commit is contained in:
Kyle Fuller
2016-02-02 12:16:43 +00:00
parent 19d712b4a4
commit b4ba12bbde
22 changed files with 621 additions and 579 deletions

View File

@@ -1 +1 @@
2.2-dev
DEVELOPMENT-SNAPSHOT-2016-01-25-a

8
.travis.yml Normal file
View File

@@ -0,0 +1,8 @@
os:
- osx
osx_image: xcode7.2
install:
- curl -sL https://gist.github.com/kylef/5c0475ff02b7c7671d2a/raw/621ef9b29bbb852fdfd2e10ed147b321d792c1e4/swiftenv-install.sh | bash
script:
- . ~/.swiftenv/init
- make test

7
Makefile Normal file
View File

@@ -0,0 +1,7 @@
stencil:
@echo "Building Stencil"
@swift build
test: stencil
@echo "Running Tests"
@.build/debug/spectre-build

View File

@@ -4,5 +4,8 @@ let package = Package(
name: "Stencil",
dependencies: [
.Package(url: "https://github.com/kylef/PathKit.git", majorVersion: 0, minor: 6),
],
testDependencies: [
.Package(url: "https://github.com/kylef/spectre-build", majorVersion: 0),
]
)

View File

@@ -1,6 +1,6 @@
# Stencil
[![Build Status](http://img.shields.io/circleci/project/kylef/Stencil/master.svg)](https://circleci.com/gh/kylef/Stencil)
[![Build Status](https://travis-ci.org/kylef/Stencil.svg?branch=master)](https://travis-ci.org/kylef/Stencil)
Stencil is a simple and powerful template language for Swift. It provides a
syntax similar to Django and Mustache. If you're familiar with these, you will

View File

@@ -2,6 +2,7 @@ import Spectre
import Stencil
func testContext() {
describe("Context") {
var context: Context!
@@ -63,3 +64,4 @@ describe("Context") {
try expect(context["name"] as? String) == "Kyle"
}
}
}

View File

@@ -2,6 +2,7 @@ import Spectre
import Stencil
func testFilter() {
describe("template filters") {
let context = Context(dictionary: ["name": "Kyle"])
@@ -21,7 +22,7 @@ describe("template filters") {
try expect(result) == "Kyle Kyle"
}
$0.it("allows you to register a custom filter") {
$0.it("allows you to register a custom which throws") {
let template = Template(templateString: "{{ name|repeat }}")
let namespace = Namespace()
namespace.registerFilter("repeat") { value in
@@ -58,7 +59,6 @@ describe("uppercase filter") {
}
}
describe("lowercase filter") {
let template = Template(templateString: "{{ name|lowercase }}")
@@ -67,3 +67,4 @@ describe("lowercase filter") {
try expect(result) == "kyle"
}
}
}

View File

@@ -2,6 +2,7 @@ import Spectre
import Stencil
func testLexer() {
describe("Lexer") {
$0.it("can tokenize text") {
let lexer = Lexer(templateString: "Hello World")
@@ -46,3 +47,4 @@ describe("Lexer") {
try expect(tokens[1]) == Token.Variable(value: "name")
}
}
}

View File

@@ -3,6 +3,7 @@ import Stencil
import Foundation
func testForNode() {
describe("ForNode") {
let context = Context(dictionary: [
"items": [1, 2, 3],
@@ -60,3 +61,4 @@ describe("ForNode") {
try expect(try node.render(context)) == "112233"
}
}
}

View File

@@ -1,6 +1,8 @@
import Spectre
import Stencil
func testIfNode() {
describe("IfNode") {
$0.describe("parsing") {
$0.it("can parse an if block") {
@@ -111,3 +113,4 @@ describe("IfNode") {
}
}
}
}

View File

@@ -9,6 +9,7 @@ class ErrorNode : NodeType {
}
func testNode() {
describe("Node") {
let context = Context(dictionary: [
"name": "Kyle",
@@ -56,3 +57,4 @@ describe("Node") {
}
}
}
}

View File

@@ -3,6 +3,7 @@ import Spectre
import Stencil
func testNowNode() {
describe("NowNode") {
$0.describe("parsing") {
$0.it("parses default format without any now arguments") {
@@ -37,3 +38,4 @@ describe("NowNode") {
}
}
}
}

View File

@@ -2,6 +2,7 @@ import Spectre
import Stencil
func testTokenParser() {
describe("TokenParser") {
$0.it("can parse a text token") {
let parser = TokenParser(tokens: [
@@ -53,3 +54,4 @@ describe("TokenParser") {
try expect(try parser.parse()).toThrow(TemplateSyntaxError("Unknown template tag 'unknown'"))
}
}
}

View File

@@ -9,6 +9,7 @@ class CustomNode : NodeType {
}
func testStencil() {
describe("Stencil") {
$0.it("can render the README example") {
let templateString = "There are {{ articles.count }} articles.\n" +
@@ -61,3 +62,4 @@ describe("Stencil") {
try expect(try template.render(namespace: namespace)) == "Hello World"
}
}
}

View File

@@ -3,8 +3,9 @@ import Stencil
import PathKit
func testInclude() {
describe("Include") {
let path = Path(__FILE__) + ".." + ".." + "Tests" + "fixtures"
let path = Path(__FILE__) + ".." + ".." + "fixtures"
let loader = TemplateLoader(paths: [path])
$0.describe("parsing") {
@@ -56,3 +57,4 @@ describe("Include") {
}
}
}
}

View File

@@ -3,8 +3,9 @@ import Stencil
import PathKit
func testInheritence() {
describe("Inheritence") {
let path = Path(__FILE__) + ".." + ".." + "Tests" + "fixtures"
let path = Path(__FILE__) + ".." + ".." + "fixtures"
let loader = TemplateLoader(paths: [path])
$0.it("can inherit from another template") {
@@ -13,3 +14,4 @@ describe("Inheritence") {
try expect(try template?.render(context)) == "Header\nChild"
}
}
}

View File

@@ -3,6 +3,7 @@ import Stencil
import PathKit
func testTemplateLoader() {
describe("TemplateLoader") {
let path = Path(__FILE__) + ".." + ".." + "Tests" + "fixtures"
let loader = TemplateLoader(paths: [path])
@@ -21,3 +22,4 @@ describe("TemplateLoader") {
}
}
}
}

View File

@@ -2,6 +2,7 @@ import Spectre
import Stencil
func testTemplate() {
describe("Template") {
$0.it("can render a template from a string") {
let context = Context(dictionary: [ "name": "Kyle" ])
@@ -10,3 +11,4 @@ describe("Template") {
try expect(result) == "Hello World"
}
}
}

View File

@@ -2,6 +2,7 @@ import Spectre
import Stencil
func testToken() {
describe("Token") {
$0.it("can split the contents into components") {
let token = Token.Text(value: "hello world")
@@ -30,3 +31,4 @@ describe("Token") {
try expect(components[1]) == "\"kyle fuller\""
}
}
}

View File

@@ -8,6 +8,7 @@ import Stencil
}
func testVariable() {
describe("Variable") {
let context = Context(dictionary: [
"name": "Kyle",
@@ -66,3 +67,4 @@ describe("Variable") {
try expect(result) == "Hello World"
}
}
}

15
Tests/main.swift Normal file
View File

@@ -0,0 +1,15 @@
testContext()
testFilter()
testLexer()
testToken()
testTokenParser()
testTemplateLoader()
testTemplate()
testVariable()
testNode()
testForNode()
testIfNode()
testNowNode()
testInclude()
testInheritence()
testStencil()

View File

@@ -1,21 +0,0 @@
machine:
xcode:
version: "7.0"
environment:
XCODE_SCHEME: NONE
XCODE_PROJECT: NONE
dependencies:
post:
- brew install --HEAD kylef/formulae/conche
test:
override:
- conche test
deployment:
release:
tag: /.*/
commands:
- pod trunk push