For this project, we need to create a blank jekyll blog.
jekyll new my-blog
This will create the blank jekyll blog with the starting template. If you run ‘jekyll serve’ in the directory, you can open it up in the web browser and see this.
As you can see we have a blank page that can now use as a template for our integration tests. The first step after establishing our project is to install the gems we will be needing. Add this namespace to your gemfile. This will require these gems whenever you manually require the namespace, that way you are not slowing down your site build when you don’t need to.
After that just run ‘bundle install’ in the command line and it will install these gems in your project. Next we need to modify our _config.yaml file. This is the base config file for jekyll, and where we will be defining which pages we want to actually test. Since our testing framework is not linked to jekyll explicitly, we need to tell it which pages and where they are for it to test them. Add these lines to the bottom of the config file:
Finally we need to actually setup the tests themselves. Run ‘rspec — init’ in the console in the my-blog directory. This will create a spec folder and a test helper. Inside this folder, modify the spec helper to look like this below:
Next, inside the spec folder, create a feature folder that will tell rspec that this is a feature test. Inside this folder, create a file called ‘page_spec.rb’. Inside this file, paste the test from down below.
And now you have your tests! You can run rspec in the folder and it will now test your blog!