We set the background and scale it to fit the page
We make use of the fonts that we downloaded with our assets
We place the relevant information on the page
Run all your specs now. If you want to actually have a look at one of the certificates, you need to use your debugger and set a break point on one of the specs in your certificate_spec.rb
# spec/certificate_spec.rb
...
it 'adds an identifier after create' do
expect(@certificate.identifier.size).to eq 64
end
...
The way we have set up the application and our testing frameworks, we will loose out generated certificates every time we run our test suite. That is not a behavior we desire. One way to fix that is to separate the folders in which we save the certificates depending on the environment we are in.
Go back to your certificate_generator.rb and add a Constant on top of the CertificateGenerator module and modify the output variable:
We need to modify the cleaning strategy we configured a while back so that only the pdf/test folder is cleaned:
# features/support/database_cleaner.rb
...
Around do |scenario, block|
DatabaseCleaner.cleaning(&block)
FileUtils.rm_rf Dir['pdf/test/**/*.pdf']
end
...
And we also need to update our after block in the certificate_spec.rb:
# spec/certificate_spec.rb
...
describe 'Creating a Certificate' do
...
after { FileUtils.rm_rf Dir['pdf/test/**/*.pdf'] }
...
Finally, we need to do a small refactoring in application_steps.rb, adding the subfolder /test to the path:
# features/step_definitions/application_steps.rb
...
Then(/^([^"]*) certificates should be generated$/) do |count|
pdf_count = Dir['pdf/test/**/*.pdf'].length
expect(pdf_count).to eq count.to_i
end
...
When you run your test now, the generated pdf's will be saved in the pdf/test folder. Your actual certificates will be saved in the pdf/development or the pdf/production folders, depending on what environment your server is running on.