Create online specifications

Most of the specifications we write are known up front because this is precisely what guides the construction of our systems. But sometimes data comes first and drives what we can do with the system. For example we want to check that:

  1. all the Wikipedia pages mentioning the term “BDD” are referencing specs2
  2. if there is a specs2 link on the page, the linked page must exist

More precisely we want to create one example for 1. and if it succeeds, create as many examples as there are links in 2.. This can be done with the org.specs2.specification.dsl.Online trait and the continueWith method:

// fill in the definitions below
    object Wikipedia:
      def getPages(searchTerm: String): Seq[Page] = ???

    trait Page:
      def getLinks: Seq[HtmlLink] = ???

    trait HtmlLink:
      def contains(name: String): Boolean = ???
      def getName: String = ???
      def getLinkedPage: Page = ???

In the specification above, if we succeed in checking each BDD page then we continue with the creation of individual examples for each encountered link.