DummyMagick
Generate a dummy image file for development
Installation
Add this line to your application's Gemfile:
group :development, :test do
gem 'dummy_magick'
end
And then execute:
$ bundle
Usage
##
# Generate a dummy image file
#
# @param width [Integer] The width of the image.
# @param height [Integer] The height of the image.
# @param format [String] The file extension of the image format. Like 'jpg', 'png', 'gif' etc.
# @return [File]
DummyMagick.dummy_image_file(100, 100, :png)
with CarrierWave
class User < ActiveRecord::Base
mount_uploader :avatar, AvatarUploader
end
User.new
User.avator = DummyMagick.dummy_image_file(100, 100, :png)
User.save!
on RSpec Controller Test
image_file = DummyMagick.dummy_image_file(100, 100, :png)
post :create, avatar: fixture_file_upload(image_file.path, 'image/png')
on Capybara
image_file = DummyMagick.dummy_image_file(100, 100, :png)
attach_file 'Upload file', image_file.path
Contributing
- Fork it ( https://github.com/unosk/dummy_magick/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request