With the release of easyb 0.9.8, a new plugin has hit the streets that enables easyb to more easily verify Google App Engine applications running locally. That is, the easyb-gae plugin makes available all the local testing services provided by Google inside easyb stories; thus, verifying GAE applications just got a lot more fun, baby!
The easyb-gae plugin makes a number of services implicitly available in the binding of a story, for example, an instance of Google’s DatastoreService is available, thus making it possible to work with persist-able objects. For instance, with the easyb-gae plugin, you can now easily verify the proper behavior of say, Objectify-Appengine or Twig entities.
By specifying in my story that I wish to use the GAE plugin by the using phrase in easyb, I can then assume that an underlying services layer has been fired up, thus mimicking the App Engine in the real. This means, if I’m using Objectify for example, I can manipulate my domain objects as they would normally function live.
For example, the story below verifies the proper behavior of two domain objects managed by Objectify: Retweet and User. In this case, an instance of User holds a collection of Retweets — given that a User instance has more than one, I can ask a User instance for its most influential retweeter (that is, who has the most followers who has retweeted the current user).
import com.b50.gretweet.Retweet
import com.b50.gretweet.User
import com.googlecode.objectify.ObjectifyService
using "GAE"
extension "behaviorCategory" //enables shoulds in when phrases
scenario "user objects should return a list of retweets by influence", {
given "all domain objects have been registered", {
ObjectifyService.register(Retweet.class);
ObjectifyService.register(User.class);
}
when "a new user instance is created", {
new User("aglover", "token", "secret").save()
}
and "when a few retweets have been added", {
user = User.findByName("aglover")
user.shouldNotBe null
(0..4).each{
user.addRetweet(new Retweet("bobama_${it}", (1 + it),
new Date(), "blah blah blah ${it}", (300 + it)))
}
user.save()
}
then "a user most influential retweet should be first ", {
retweets = user.listAllRetweetsByInfluence()
retweets[0].influence.shouldBe 304
}
}
Note that by specifying Using "GAE" at the top of this story, I’ve implicitly made the local services of App Engine available — thus, when I issue a save on my domain objects (which intern uses Objectify to persist the underlying object) they are persisted into the local datastore that mimics Bigtable (as exposed via GAE). That’s why I can then find my User instance (by the way, this User type is distinctly different than the one provided by default in GAE).
As you can see, the easyb-gae plugin makes working with GAE, well, easy! For more information, see the easyb-gae plugin page on the easyb wiki. Or just download it today and see for yourself!
