One of the legacy aspects of Bridgetown as carried over from the original Jekyll fork in 2020 is the Cucumber feature integration tests, written in Gherkin. Now I don’t have the slightest idea why this was ever considered good practice…I hate writing and supporting tests in Gherkin with a passion. We’d whittled the number of tests down a bit over the years, but now I’m very happy to say…

…I am in the process of rewriting all feature tests using our Minitest-based test suite instead! I’ve come up with a small set of helpers and a new BridgetownFeatureTest superclass, and now it’s working like a dream. Some example test code:

context "slotted content" do
  setup do
    create_directory "_layouts"
    create_directory "_posts"
  end

  should "render" do
    create_page "_posts/star-wars.md", <<~ERB, title: "Star Wars", date: "2009-03-27", layout: "simple"
      _Luke_, <%= ["I", "am"].join(" ") %> your father<% slot :subtitle, "V: ", transform: false %><% slot :subtitle, "The Empire Strikes Back", transform: false %>.
    ERB

    create_file "_layouts/simple.html", '<h1><%= page.data.title %> <%= slotted :subtitle, "[BLANK]" %></h1> <%= yield %>'

    create_configuration template_engine: "erb"

    run_bridgetown "build"

    assert_file_contains "<p><em>Luke</em>, I am your father.</p>", "output/2009/03/27/star-wars/index.html"
    assert_file_contains "<h1>Star Wars V: The Empire Strikes Back</h1>", "output/2009/03/27/star-wars/index.html"
  end
end

This will make it much easier to write new feature tests in the future, and thus improve our test coverage for complex configuration scenarios and cross-framework concerns. Note that it’s not really any faster than using Cucumber, because it’s still running an entire Bridgetown CLI build process for each test case, so we don’t want to go nuts writing new feature tests when much faster unit tests would suffice.