When I have added client verification to beats in https://github.com/logstash-plugins/logstash-input-beats/pull/56, I have created a small rspec helper to work with files. This is handy since a lot of library requires physical certificate and key to work correctly.
Theses helpers make sure the file is created in a temporary file and the file is deleted when the test finished to run so it doesn't pollute your local file system.
You can use it like this in your code:
let_tmp_file(:mysuperfile_path) { "Hello world" )
# The variable :mysuperfile_path will now return a full path to the temporary file with the content passed as the block.
When I have added client verification to beats in https://github.com/logstash-plugins/logstash-input-beats/pull/56, I have created a small rspec helper to work with files. This is handy since a lot of library requires physical certificate and key to work correctly.
Theses helpers make sure the file is created in a temporary file and the file is deleted when the test finished to run so it doesn't pollute your local file system.
You can use it like this in your code: