/
mountable_spec.rb
39 lines (31 loc) · 1.03 KB
/
mountable_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'spec_helper'
describe CarrierWave::Uploader do
let(:uploader_class) { Class.new(CarrierWave::Uploader::Base) }
let(:uploader) { uploader_class.new }
after { FileUtils.rm_rf(public_path) }
describe '#model' do
let(:model) { double('a model object') }
let(:uploader) { uploader_class.new(model) }
it "is remembered from initialization" do
expect(uploader.model).to eq(model)
end
end
describe '#mounted_as' do
let(:model) { double('a model object') }
let(:uploader) { uploader_class.new(model, :llama) }
it "is remembered from initialization" do
expect(uploader.mounted_as).to eq(:llama)
end
end
describe '#index' do
let(:model) { Class.new.send(:extend, CarrierWave::Mount) }
let(:instance) { model.new }
before do
model.mount_uploaders(:images, uploader_class)
instance.images = [stub_file('test.jpg'), stub_file('bork.txt')]
end
it "returns the current index in uploaders" do
expect(instance.images.map(&:index)).to eq [0, 1]
end
end
end