Skip to content

Instantly share code, notes, and snippets.

@ck1125
ck1125 / FancyControllerTests
Created February 22, 2011 19:13
Controller with multiple inter-related collaborators
package mypackage
import grails.plugin.spock.ControllerSpec
import org.hamcrest.CoreMatchers
import static org.hamcrest.CoreMatchers.notNullValue
import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertThat
class FancyControllerTests extends ControllerSpec {
@ck1125
ck1125 / cuke4duke-selenium-pom.xml
Created March 1, 2011 19:09
pom.xml for selenium and cuke4duke integration
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.in3k8</groupId>
<artifactId>cuke4duke-selenium-sample</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
@ck1125
ck1125 / brandhub.feature
Created March 1, 2011 19:11
Feature file with scenarios for hub page selenium tests
Feature: Sample Page loading test
On /programmes want to see if Cucumber can be used to make a selenium testing DSL
Scenario: A brand hub page can be loaded
When I open '/programmes/skins'
Then the title should be 'Skins - Channel 4'
Then click an item with xpath '//html/body/div/div[3]/div/div[3]/div/ul/li[2]/h3/a'
Then browser location should be 'http://www.e4.com/skins/quizzes.html'
@ck1125
ck1125 / BrandHubSteps.java
Created March 1, 2011 19:13
Step definitions used by features
package sample;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
import cuke4duke.annotation.Before;
import cuke4duke.annotation.I18n.EN.Then;
import cuke4duke.annotation.I18n.EN.When;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ck1125
ck1125 / Hack for GrailsPlugin
Created March 9, 2011 15:49
Attempt at improving the workings of the assemble task of the Gradle Grails Plugin
package org.grails.gradle.plugin
import grails.util.GrailsNameUtils
import org.codehaus.groovy.grails.cli.support.GrailsRootLoader
import org.codehaus.groovy.grails.cli.support.GrailsBuildHelper
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.codehaus.groovy.grails.resolve.IvyDependencyManager
import org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyFactory
@ck1125
ck1125 / linknodelookup.java
Created June 30, 2011 18:22
Abridged Link Text Node lookup StepDefinition
import cuke4duke.annotation.I18n.EN.Then;
import helpers.SeleniumWrapper;
import helpers.WebPageHelpers;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import static helpers.SeleniumFactory.getSelenium;
@ck1125
ck1125 / linknode.feature
Created June 30, 2011 18:30
Feature file for text node lookup
Feature: Extracting a text node from a link
Scenario: A link has text
When I open abitrary page
Then my link must have the following text BlahBlah
@ck1125
ck1125 / linknode.html
Created June 30, 2011 18:35
Page under test
<a href="blah-location">BlahBlah<span>arbitrary text</span></a>
@ck1125
ck1125 / gradle-grails-build.gradle
Created February 26, 2012 00:51
gradle grails plugin on grails 2.0.x
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
url "http://repo.grails.org/grails/core"
}
}
dependencies {
@ck1125
ck1125 / MySimpleFiltersSpec
Created June 9, 2012 17:37
Filters with dependencies mocking with Spock
package grails_filter_tests
import spock.lang.Specification
import org.springframework.beans.factory.config.MethodInvokingFactoryBean
import grails.test.mixin.*
import grails.test.mixin.support.GrailsUnitTestMixin
import grails.test.mixin.web.FiltersUnitTestMixin
@TestFor(SimpleController)
@TestMixin([GrailsUnitTestMixin,FiltersUnitTestMixin])
@Mock(MySimpleFilters)