Skip to content

Commit

Permalink
Added site and user guide.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjstehno committed Dec 7, 2016
1 parent dd11617 commit f4b8d2f
Show file tree
Hide file tree
Showing 16 changed files with 1,800 additions and 26 deletions.
60 changes: 48 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,57 @@
# Ersatz Server
[![Download](https://api.bintray.com/packages/cjstehno/stehno/ersatz/images/download.svg)](https://bintray.com/cjstehno/stehno/ersatz/_latestVersion)
[![Build Status](https://travis-ci.org/cjstehno/ersatz.svg?branch=master)](https://travis-ci.org/cjstehno/ersatz)
[![Coverage Status](https://coveralls.io/repos/github/cjstehno/ersatz/badge.svg?branch=master)](https://coveralls.io/github/cjstehno/ersatz?branch=master)

> _noun_ An artificial substance or article used to replace something natural or genuine; a substitute.
## Quick Links

A "mock" HTTP server library for testing HTTP/REST clients.
* Site: http://stehno.com/ersatz
* Project: https://github.com/cjstehno/ersatz
* User Guide: https://github.com/cjstehno/ersatz/guide/html5
* Groovy Docs: https://github.com/cjstehno/ersatz/groovydoc

## Introduction

The Ersatz Server is a HTTP client testing tool, which allows for request/response expectations to be configured in a flexible manner. The expectations
will respond in a configured manner to requests and allow testing with different responses and/or error conditions without having to write a lot of
boiler-plate code.

## Artifacts

For Gradle:

testCompile 'com.stehno.ersatz:ersatz:0.1.0'

For Maven:

<dependency>
<group>com.stehno.ersatz</group>
<artifact>ersatz</artifact>
<version>0.1.0</version>
</dependency>

## Build Instructions

Ersatz is build using Gradle with no custom build tasks:

./gradlew clean build

[![Build Status](https://travis-ci.org/cjstehno/ersatz.svg?branch=master)](https://travis-ci.org/cjstehno/ersatz)
[![Coverage Status](https://coveralls.io/repos/github/cjstehno/ersatz/badge.svg?branch=master)](https://coveralls.io/github/cjstehno/ersatz?branch=master)

## Features
## License

* Uses embedded Undertow to setup an HTTP server for unit testing HTTP client code
* compatible with Java and Groovy (and JVM language)
* compatible with JUnit and Spock testing frameworks
* Supports chained builder, Java 8 functions, and a Groovy DSL
```
Copyright (C) 2016 Christopher J. Stehno
## Atrifacts
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
compile 'com.stehno.ersatz:ersats:<CURRENT_VERSION>'
http://www.apache.org/licenses/LICENSE-2.0
> WARNING: This is very much a work in progress and not yet ready for general use.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
11 changes: 0 additions & 11 deletions TODO.md

This file was deleted.

87 changes: 86 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ plugins {
id 'maven-publish'
id 'com.github.kt3k.coveralls' version '2.7.1'
id 'com.jfrog.bintray' version '1.7.3'
id "org.asciidoctor.convert" version "1.5.3"
id "com.stehno.gradle.webpreview" version "0.1.1"
}

group = 'com.stehno.ersatz'
Expand All @@ -15,7 +17,6 @@ version = '0.1.0'
sourceCompatibility = 8
targetCompatibility = 8


repositories {
jcenter()
}
Expand Down Expand Up @@ -122,4 +123,88 @@ bintray {
vcsUrl = 'https://github.com/cjstehno/ersatz'
}
}
}

asciidoctor {
options doctype: 'book'

backends = ['html5']

attributes 'source-highlighter': 'coderay',
'coderay-linenums-mode': 'table',
icon: 'font',
linkattrs: true,
encoding: 'utf-8'
}

task site(group: 'Documentation', description: 'Builds the documentation web site.', dependsOn: ['build', 'groovydoc', 'jacocoTestReport', 'asciidoctor']) {
doLast {
logger.info 'Building documentation web site...'

// copy the templates
copy {
from 'src/site'
into 'build/site'
include '**/*.html'
expand([project_version: project.version, year: Calendar.instance.get(Calendar.YEAR)])
}

// copy the assets
copy {
from 'src/site'
into 'build/site'
include '**/stylesheets/**'
include '**/images/**'
}

copy {
from 'build/docs'
from 'build/reports'
include '**/**'
into 'build/site'
}

copy {
from 'build/asciidoc'
include '**/**'
into 'build/site/guide'
}
}
}

task publishSite(type: GradleBuild, group: 'Publishing', description: 'Publishes the documentation web site.', dependsOn: ['site']) {
buildFile = 'publish.gradle'
tasks = ['publishGhPages']
}

task updateVersion(group: 'Documentation', description: 'Updates the version in documentation based on the project version') {
doLast {
String newVersion = project.version
String oldVersion = project.property('from')

logger.lifecycle "Updating documentation versions from ${oldVersion} to ${newVersion}..."

ant.replace(file: 'README.md', token: oldVersion, value: newVersion)
ant.replace(dir: 'src/docs/asciidoc', token: oldVersion, value: newVersion)
}
}

task checkVersion(group: 'Verification', description: 'Verify that the project version is reflected in the documentation.') {
doLast {
logger.lifecycle "Verifying that the documentation references version ${project.subprojects[0].version}..."

// Not the most efficient way to do this but should be ok for now
boolean documented = ['README.md', 'src/docs/asciidoc/index.adoc'].every { f ->
boolean ok = project.file(f).text.contains(project.subprojects[0].version)

logger.info " - Checking: $f: $ok"
ok
}

assert documented, 'The documented project version does not match the project version: Run "./gradlew updateVersion -Pfrom=OLD_VERSION" and try again.'
}
}

webPreview {
resourceDir = file('build/site')
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Dec 06 14:29:46 CST 2016
#Wed Dec 07 06:26:31 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip
20 changes: 20 additions & 0 deletions publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'org.ajoberstar:gradle-git:1.0.0'
}
}

apply plugin: 'org.ajoberstar.github-pages'

githubPages {
repoUri = 'git@github.com:cjstehno/ersatz'
pages {
from(file('build/site')) {
into '.'
}
}
}

0 comments on commit f4b8d2f

Please sign in to comment.