How can I create a test file with a given size and upload a test file to rspec? I want to generate a file.
I currently have files in files / files and use the fixture_file_upload file as a test file. I want to eliminate the need for this sample file.
You can use factory_girl or fabrication to make fun of the downloaded file.
An example configuration for factory_girlwould look like this:
factory_girl
factory :attachment do supporting_documentation_file_name { 'test.pdf' } supporting_documentation_content_type { 'application/pdf' } supporting_documentation_file_size { 1024 } end
, factory girl
, , . , ( , , ), .
Mocking Rails 3.1
- , :
file = Rack::Test::UploadedFile.new(File.join(Rails.root, 'app', 'assets', 'images', 'test-file.jpg'), 'image/jpg') allow_any_instance_of(Model).to receive(:photo_obj).and_return file
Source: https://habr.com/ru/post/1541074/More articles:Jasmine.js v2.0.0 - TypeError: Cannot read the "stopPropagation" property from undefined - javascriptName the view / action "View" in ASP.NET MVC without changing routes - c #Can we use scala to debug Java programs - javaclass templates and virtual functions - c ++ConcurrentDictionary and atomic operations - Lock sometimes required? - multithreadingUsing the "this" keyword inside an object method - javascriptShould I use BCMath for values with 1,2 or 3 decimal places? - phpCreating a jpa session for background threads - javaWhat is the accuracy for the bcmath PHP library? - phpИдентификатор элемента меню не отображается - primefacesAll Articles