I am struggling to start it. With Rails I can do an integration test to say click this button and then expect something.
Can I do something similar in ruby?
As in I want to be able to write the code and then start to make it work, or is it better to write out how I would do the commands on some paper and then test them?
for example I write all of this which none if it exists:
Product.brands.each do |brand|
images = Product.images(brand, "image1")
images.each do |image|
file = FileProcessor.new(image)
end
end
This would likely be a few ActiveRecord create! calls to get your data in the necessary state.
run_command
To run the command from within the test, you can call the shell command using the Ruby’s exec method.
verify_images_were_processed
Using Ruby’s file manipulation support, you could check that particular files exist, their sizes, extensions, etc. For example: expect(File.exist?("foo/bar.jpg")).to be(true)
clean_up_any_generated_files_and_db_records
The test should clean up after itself. (In Rails this is usually handled by wrapping everything in a transaction, or by the database_cleaner gem).