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 / 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 / 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 / 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 / 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 / AngularJsAware.groovy
Last active February 11, 2020 15:12
Make Geb work with AngularJS reliably, by waiting for the angular views to be resolved before attempting assertions. This uses the same onReady technique as Protractor.
package extensions
trait AngularJsAware {
boolean isAngularReady() {
js.exec('window.MYAPP.waitForAngular();');
waitFor {
js.MYAPP.APP_READY == true
}

Modelling Family, Friends, Enemies, Pets and Deaths in the Wizarding World

Setup

@antony
antony / gist:282033be1dae877fea45
Created October 10, 2014 15:59
Create a Jenkins view filter.
<!--
You need to install the 'anything-goes' plugin and enable it, first:
https://wiki.jenkins-ci.org/pages/viewpage.action?pageId=60915753
Then click 'edit description' on your view, and just paste this whole file into it and click save.
Done. Type to filter.
-->
<input class="search" placeholder="Type to filter..." style="font-size: 24px; padding: 10px; height: 50px; width: 100%;" autofocus />
<script>
!function(){function a(b,c,d){var e=a.resolve(b);if(null==e){d=d||b,c=c||"root";var f=new Error('Failed to require "'+d+'" from "'+c+'"');throw f.path=d,f.parent=c,f.require=!0,f}var g=a.modules[e];if(!g._resolving&&!g.exports){var h={};h.exports={},h.client=h.component=!0,g._resolving=!0,g.call(this,h.exports,a.relative(e),h),delete g._resolving,g.exports=h.exports}return g.exports}a.modules={},a.aliases={},a.resolve=function(b){"/"===b.charAt(0)&&(b=b.slice(1));for(var c=[b,b+".js",b+".json",b+"/index.js",b+"/index.json"],d=0;d<c.length;d++){var b=c[d];if(a.modules.hasOwnProperty(b))return b;if(a.aliases.h
### Keybase proof
I hereby claim:
* I am antony on github.
* I am aiten (https://keybase.io/aiten) on keybase.
* I have a public key whose fingerprint is 17B8 82E3 9AE7 A87E 11FE 4F78 DEEF 31AE A794 9547
To claim this, I am signing this object:
@antony
antony / stripe-checkout.js
Last active January 4, 2016 04:29
Faking out the Stripe CheckoutJS for Functional Tests. A simple drop-in replacement for https://checkout.stripe.com/checkout.js for your functional test environment.
var handler,
StripeHandler = new Klass({
initialize: function(token) {
this._callback = token;
},
open: function(attrs) {
var _self = this,
button = $('<button id="dummy-stripe">').html(attrs.description),
overlay = $('<div>', {id: 'dummy-stripe-overlay', style: "position: absolute; width: 20%; height: 40%; background-color: #fff; top: 30%; left: 40%; border: 4px solid #000; display: block; margin: auto auto;"}).html(button);
$('body').append(overlay);
@antony
antony / TestShard.groovy
Created July 4, 2013 13:41
Parallelise your Grails functional tests! Put this in your scripts dir.
import org.codehaus.groovy.grails.test.support.GrailsTestTypeSupport
import org.codehaus.groovy.grails.test.GrailsTestTypeResult
import org.codehaus.groovy.grails.test.event.GrailsTestEventPublisher
import org.codehaus.groovy.grails.test.GrailsTestTargetPattern
includeTargets << grailsScript("_GrailsClean")
includeTargets << grailsScript("_GrailsTest")
// grails t-s shard=1 shards=4