Monthly Archives: July 2012

Preconditions with the Database Migration Plugin in Grails

We’ve been writing a few database migrations at the office lately, and have seen some issues regarding the syntax of HSQLDB used in development and test, and Postgres, used in production.

To solve some of these issues, we’ve resorted to using liquibase preconditions in some of our migrations.

In this post, I’ll give a brief rundown of the preconditions feature and how they look when used in combination with the database migration plugin and Grails.

Continue reading

Advertisements

Injecting additional javascript libraries into a page with Geb

Once in a while, we might want to add an additional library into an existing page with Geb.

The easy way to do so is to add a helper method called injectLibrary as follows:


def injectLibrary( library ){

     js.exec("document.body.appendChild(document.createElement('script')).src='$library'");

}

Then, whenever you want to add a new library, simply call

injectLibrary( 'http://sinonjs.org/releases/sinon-1.4.2.js' )

This would add the javascript library you have specified in your link into your page.

There are a few scenarios where I have found this to be useful:

  • Adding additional libraries in regression tests of your actual site.
  • Getting better drag and drop support using Syn.js.
  • Injecting Sinon.js to use the fakeTimer functionality when scraping websites.
  • Adding jQuery to a page to manipulate document elements to make them easier to find for scraping.

Using Cloudbees BuildHive to test Grails Plugins

Cloudbees provides a simple Cloud-based continuous integration environment called BuildHive. Buildhive is like a simpler version of Jenkins where you can send all your public projects to be tested on someone else’s iron. It’s the perfect setup to ensure that all your grails plugins are ran correctly.

In this post, I will show you how to quickly set up and test a grails plugin to run on BuildHive. Continue reading