Skip to content

Instantly share code, notes, and snippets.

View antony's full-sized avatar
:octocat:
Loving SvelteJS

Antony Jones antony

:octocat:
Loving SvelteJS
View GitHub Profile
@antony
antony / ExamplePage.groovy
Created September 20, 2015 11:10
Testing asynchronously inserted content (such as modals) with Geb. Thanks to Verity.
// We use 'to:' on the modal trigger to force a refresh of the page cache once the modal has been inserted.
// Angular Bootstrap modals are actually created in the DOM once they are triggered, so our initial page parse doesn't grab them.
// If we don't do this, you will end up with a lot of nulls since Geb 0.11.
class ExamplePage extends Page {
static content = {
modalTrigger(to: ExamplePage) { $('.show-modal') }
modal { $('.my-modal').module(ModalDialogModule) }
}
@antony
antony / ExampleTemplateRenderingHelperSpec.groovy
Created October 21, 2015 13:55
Handlebars Testing Framework for Ratpack
package pm.renderer.handlebars
import com.github.jknack.handlebars.Handlebars
import com.github.jknack.handlebars.Options
import com.github.jknack.handlebars.Template
import energizedwork.support.HandlebarsSpecification
import ratpack.handlebars.NamedHelper
import spock.lang.Ignore
class ExampleTemplateRenderingHelperSpec extends HandlebarsSpecification<TemplateRenderingHelper, String> {
@antony
antony / spock.sjs
Last active November 21, 2015 11:42
Writing spock language in javascript with sweet.js (WIP)
let spec = macro {
rule { $name:lit { $body ... } } => {
describe($name, function () {
$body ...
});
}
}
@antony
antony / ShiroAwareSpecification.groovy
Created November 30, 2015 10:28
Unit Testing Shiro Subjects with Spock
class ShiroAwareSpecification extends Specification {
@Shared Subject subject
@Shared ThreadState threadState
void setupSpec() {
subject = Mock(Subject)
threadState = new SubjectThreadState(subject)
threadState.bind()
}
@antony
antony / example.js
Last active June 9, 2016 15:56
Dynamic Selenium Page Model example in NodeJS / JavaScript
'use strict'
class MagicPage {
constructor () {
var contents = Object.keys(this.getContent())
contents.map((key) => {
this[key] = this.getContent()[key]
})
}
}
@antony
antony / Chance.groovy
Last active August 31, 2016 08:59
ChanceJS from Groovy / Java
package vendigo.support.extensions
import groovy.json.JsonOutput
import javax.script.ScriptEngine
import javax.script.ScriptEngineManager
class Chance {
private static ScriptEngine engine
@antony
antony / BrowserLoggingBaseSpec.groovy
Created October 24, 2016 10:15
Get JavaScript console errors in Geb
package myapp.specs.base
import geb.spock.GebReportingSpec
import spock.lang.Shared
import static org.openqa.selenium.logging.LogType.BROWSER
abstract class BrowserLoggingBaseSpec extends GebReportingSpec {
void cleanup() {

Keybase proof

I hereby claim:

  • I am antony on github.
  • I am aiten (https://keybase.io/aiten) on keybase.
  • I have a public key ASCn6d0qJgOXOuqmRnQSHTAYoj2U_pdHzKHZS2mUT9fAcwo

To claim this, I am signing this object:

@antony
antony / gist:11b028fc1ff39f63be64824f9642eac8
Created February 11, 2018 21:20
Seed hapijs v17 application.
'use strict'
const Hapi = require('hapi')
const server = Hapi.server({ port: 3000, host: 'localhost' })
const init = async () => {
await server.start()
console.log(`Server running at: ${server.info.uri}`)
}
04fa8427a6bd1febc6863fa38e2dd82a1dc6c26860ba43eaf095629f68f55e452a625e8e14dddb4626d0b0f180f0024a7d460cdce5dda44f8684ce33e016ebf5c8;wayne-o