require 'spec_helper' require 'dummy/app/models/dummy' describe Hermitage::ViewHelpers, type: :helper do # Reset Hermitage configs because they should not be shared among specs before(:each) { Hermitage.configs = { default: Hermitage::Defaults.to_hash() } } let(:template) { ActionView::Base.new } describe '#render_gallery_for' do let(:images) { Array.new(2) { |i| DummyImage.new(i.to_s) } } let(:expected) { '' } context 'no options' do subject { template.render_gallery_for images } it { should == expected } end context 'with options' do context 'original and thumbnail' do subject { template.render_gallery_for images, original: 'photo', thumbnail: 'photo(:thumbnail)' } let(:images) { Array.new(2) { |i| DummyPhoto.new(i.to_s) } } it { should == expected } end context 'title' do subject { template.render_gallery_for images, title: 'description' } let(:expected) { '' } it { should == expected } end context 'list_tag and item_tag' do subject { template.render_gallery_for images, list_tag: :div, item_tag: :div } let(:expected) { '
0 thumbnail
1 thumbnail
' } it { should == expected } end context 'list_class, item_class, link_class and image_class' do subject { template.render_gallery_for images, list_class: nil, item_class: nil, link_class: 'thumb link', image_class: 'thumb' } let(:expected) { '' } it { should == expected } end context 'each_slice' do subject { template.render_gallery_for images, each_slice: 1 } let(:expected) { '' } it { should == expected } end end context 'with configs' do before(:each) { Hermitage.configs[:dummy_images] = { list_class: 'images-thumbnails' } } let(:expected) { '' } subject { template.render_gallery_for images } it { should == expected } context 'with overwritten defaults' do before(:each) do Hermitage.configs[:default].merge!({ list_class: 'default-thumbnails', item_class: 'span3' }) end let(:expected) { '' } it { should == expected } context 'and with options' do subject { template.render_gallery_for images, list_class: 'custom-thumbnails' } let(:expected) { '' } it { should == expected } end end end end end