Generating images of certificates
We also want to generate images of certificates so that we can display them on the verification page.
Add the following step to your Generate a certificate
scenario in certificate_generation.feature
:
We are going to save the images of the certificates in a subfolder of our assets/img
folder, named usr
. For testing purposes we are going to use a folder named test
. We'll have separate folders for development
and production
environments.
Create the folders and the necessary .keep
files in your terminal:
Add the following step to your application_steps.rb
We also need to update our database_cleaner.rb
with a command that will purge the test
folder of images generated for test purposes:
Okay, that's our tests. Now we need to implement a solution to actually create an image of the certificate and save it. We are going to use a free software suite to create, edit, compose, or convert bitmap images, called ImageMagick
. You can read more about ImageMagick
on www.imagemagick.org.
The gem we are going to use is called RMagick
.
Add RMagick
to your Gemfile
and install it with bundle install
:
The actual implementation is not overly complicated. We are going to place the actual code that generates the image inside the CertificateGenerator
module:
Running cucumber
now should show all tests passing.
The next step is to create a verification page.
Last updated