require 'spec_helper' describe FontAwesome5Rails do include RSpecHtmlMatchers include ActionView::Context describe 'files' do it 'should have correct dirs' do expect(Dir.exists?('./app/assets/images')).to be_truthy expect(Dir.exists?('./app/assets/images/fa5/brands')).to be_truthy expect(Dir.exists?('./app/assets/images/fa5/regular')).to be_truthy expect(Dir.exists?('./app/assets/images/fa5/solid')).to be_truthy expect(Dir.exists?('./app/assets/javascripts')).to be_truthy expect(Dir.exists?('./app/assets/stylesheets')).to be_truthy expect(Dir.exists?('./app/helpers/font_awesome5/rails')).to be_truthy end it 'should have correct files' do expect(File.exists?('./app/helpers/font_awesome5/rails/icon_helper.rb')).to be_truthy expect(File.exists?('./app/assets/javascripts/font_awesome5.js')).to be_truthy expect(File.exists?('./app/assets/javascripts/fontawesome-all.min.js')).to be_truthy expect(File.exists?('./app/assets/stylesheets/fa-svg-with-js.css')).to be_truthy expect(File.exists?('./app/assets/stylesheets/font_awesome5.css')).to be_truthy expect(File.exists?('./app/assets/stylesheets/fontawesome-all.css.scss')).to be_truthy expect(File.exists?('./app/assets/stylesheets/font_awesome5_webfont.css')).to be_truthy expect(File.exists?('./lib/font_awesome5_rails/engine.rb')).to be_truthy expect(File.exists?('./lib/font_awesome5_rails/version.rb')).to be_truthy expect(File.exists?('./lib/font_awesome5_rails/parsers/fa_icon_parser.rb')).to be_truthy expect(File.exists?('./lib/font_awesome5_rails/parsers/fa_layered_icon_parser.rb')).to be_truthy expect(File.exists?('./lib/font_awesome5_rails/parsers/fa_stacked_icon_parser.rb')).to be_truthy expect(File.exists?('./lib/font_awesome5_rails/parsers/parse_methods.rb')).to be_truthy end end describe 'fa_icon tags' do it 'should return correct type tags' do expect(fa_icon 'camera-retro').to eq '' expect(fa_icon 'camera-retro fw').to eq '' expect(fa_icon 'camera-retro', type: :fas).to eq '' expect(fa_icon 'camera-retro', type: :far).to eq '' expect(fa_icon 'camera-retro', type: :fal).to eq '' expect(fa_icon 'camera-retro', type: :fab).to eq '' expect(fa_icon 'camera-retro', type: :solid).to eq '' expect(fa_icon 'camera-retro', type: :regular).to eq '' expect(fa_icon 'camera-retro', type: :light).to eq '' expect(fa_icon 'camera-retro', type: :brand).to eq '' end it 'should return correct class tags' do expect(fa_icon 'camera-retro').to eq '' expect(fa_icon('camera-retro', class: 'test')).to eq '' expect(fa_icon('camera-retro', class: 'fa-camera-retro')).to eq '' end it 'should return correct size tags' do expect(fa_icon 'camera-retro', size: '3x').to eq '' expect(fa_icon 'camera-retro', class: 'fa-3x', size: '3x').to eq '' expect(fa_icon 'camera-retro', size: '3x 2x').to eq '' end it 'should return correct animation tags' do expect(fa_icon 'camera-retro', animation: 'spin').to eq '' expect(fa_icon 'camera-retro', class: 'fa-spin', animation: 'spin').to eq '' expect(fa_icon 'camera-retro', animation: 'spin cog').to eq '' end it 'should return correct style tags' do expect(fa_icon 'camera-retro', style: 'color: Tomato;').to eq '' end it 'should return correct data tags' do expect(fa_icon 'camera-retro', data: {'fa-transform': 'rotate-90'}).to eq '' expect(fa_icon 'camera-retro', data: {fa_transform: 'rotate-90'}).to eq '' end it 'should return correct text tags' do expect(fa_icon 'camera-retro', text: 'Camera').to have_tag('i', with: { class: 'fas fa-camera-retro'}) expect(fa_icon 'camera-retro', text: 'Camera').to have_tag('span', text: 'Camera') expect(fa_icon 'camera-retro', text: 'Camera', style: 'color: Tomato;').to have_tag('span', text: 'Camera', with: {style: 'color: Tomato;'}) expect(fa_icon 'camera-retro', text: 'Camera', size: '3x').to have_tag('span', text: 'Camera', with: {class: 'fa5-text fa-3x'}) end it 'should return correct tags with symbols' do expect(fa_icon :facebook, type: :brand).to eq '' expect(fa_icon :camera_retro).to eq '' expect(fa_icon [:camera_retro, :circle]).to eq '' end it 'should return correct title tags' do expect(fa_icon 'camera-retro', title: 'camera-title').to eq '' expect(fa_icon 'camera-retro', text: 'Camera', title: 'camera-title').to eq 'Camera' end end describe 'fa_stacked_icon tags' do it 'should return correct tags' do expect(fa_stacked_icon 'camera', base: 'circle') .to eq '' expect(fa_stacked_icon 'camera inverse', base: 'circle') .to eq '' expect(fa_stacked_icon 'camera inverse', base: 'circle inverse') .to eq '' expect(fa_stacked_icon 'camera', base: 'circle', type: :far, reverse: false) .to eq '' expect(fa_stacked_icon 'camera', base: 'circle', reverse: true) .to eq '' expect(fa_stacked_icon 'camera', base: 'circle', text: 'Text!') .to eq 'Text!' expect(fa_stacked_icon 'camera', base: 'circle', type: :fas, base_type: :far, reverse: true) .to eq '' expect(fa_stacked_icon 'camera', base: 'circle', type: :far, base_type: :fas, reverse: true) .to eq '' end it 'should return correct tags with symbols' do expect(fa_stacked_icon [:camera, :inverse], base: :circle) .to eq '' expect(fa_stacked_icon :camera, base: :circle, type: :far, reverse: false) .to eq '' end it 'should return correct tags with title' do expect(fa_stacked_icon [:camera, :inverse], base: :circle, title: 'Camera') .to eq '' end end describe 'fa_layered_icon tags' do it 'should return correct tags' do expect(fa_layered_icon{ fa_icon 'circle'}).to eq '' expect(fa_layered_icon(aligned: true){ fa_icon 'circle' }).to eq '' expect(fa_layered_icon(aligned: false){ fa_icon 'circle' }).to eq '' expect(fa_layered_icon(class: 'test'){ fa_icon 'circle' }).to eq '' expect(fa_layered_icon(size: '3x'){ fa_icon 'circle' }) .to eq '