font-awesome-propshaft 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ f5a6671f3c4200f3955b4f3666f3db05908b83666334dcdbf3e54a137db688a98a2d37cb45bb5b47df9e70c197ef6179beded3c4d167f707cfda4f576fba53da
@@ -0,0 +1,93 @@
1
+ require 'test_helper'
2
+ require "propshaft/asset"
3
+ require "propshaft/load_path"
4
+
5
+ class FontAwesomePropshaftRailsTest < ActionDispatch::IntegrationTest
6
+
7
+ test "engine is loaded" do
8
+ assert_equal ::Rails::Engine, FontAwesomePropshaft::Rails::Engine.superclass
9
+ end
10
+
11
+ test "fonts are available in propshaft" do
12
+ %w[
13
+ fa-brands-400.ttf
14
+ fa-brands-400.woff2
15
+ fa-regular-400.ttf
16
+ fa-regular-400.woff2
17
+ fa-solid-900.ttf
18
+ fa-solid-900.woff2
19
+ fa-v4compatibility.ttf
20
+ fa-v4compatibility.woff2
21
+ ].each do |font_file|
22
+ asset = Rails.application.assets.load_path.find(font_file)
23
+ assert asset, "#{font_file} not found in Propshaft load path"
24
+ end
25
+ end
26
+
27
+ test "stylesheets contain asset pipeline references to fonts" do
28
+ asset = Rails.application.assets.load_path.find("font-awesome-propshaft.css")
29
+ assert asset, "font-awesome-propshaft.css not found in Propshaft load path"
30
+
31
+ css = File.read(asset.path)
32
+
33
+ %w[
34
+ fa-brands-400
35
+ fa-regular-400
36
+ fa-solid-900
37
+ fa-v4compatibility
38
+ ].each do |font|
39
+ %w[.ttf .woff2].each do |ext|
40
+ assert_match %r{/#{font}(-\w+)?#{ext}}, css, "CSS does not reference #{font}#{ext}"
41
+ end
42
+ end
43
+ end
44
+
45
+ test "stylesheets are served" do
46
+ asset = Rails.application.assets.load_path.find("font-awesome-propshaft.css")
47
+ assert asset, "font-awesome-propshaft.css not found in Propshaft load path"
48
+
49
+ css = File.read(asset.path)
50
+ assert_match(/font-family:\s*'FontAwesome';/, css)
51
+ end
52
+
53
+ test "sass import compiles correctly" do
54
+ asset = Rails.application.assets.load_path.find("sass-import.css.sass")
55
+ assert asset, "sass-import.css.sass not found in Propshaft load path"
56
+
57
+ source = File.read(asset.path)
58
+ engine = SassC::Engine.new(
59
+ source,
60
+ syntax: :sass,
61
+ load_paths: Rails.application.config.assets.paths
62
+ )
63
+
64
+ css = engine.render
65
+ assert_match(/font-family:\s*'FontAwesome';/, css, "sass-import.css.sass missing FontAwesome styles")
66
+ rescue SassC::SyntaxError => e
67
+ flunk "sass-import.css.sass failed to compile: #{e.message}"
68
+ end
69
+
70
+ test "scss import compiles correctly" do
71
+ asset = Rails.application.assets.load_path.find("scss-import.css.scss")
72
+ assert asset, "scss-import.css.scss not found in Propshaft load path"
73
+
74
+ source = File.read(asset.path)
75
+ engine = SassC::Engine.new(
76
+ source,
77
+ syntax: :scss,
78
+ load_paths: Rails.application.config.assets.paths
79
+ )
80
+
81
+ css = engine.render
82
+ assert_match(/font-family:\s*'FontAwesome';/, css, "scss-import.css.scss missing FontAwesome styles")
83
+ rescue SassC::SyntaxError => e
84
+ flunk "scss-import.css.scss failed to compile: #{e.message}"
85
+ end
86
+
87
+ test "helpers should be available in the view" do
88
+ get "/icons"
89
+ assert_response :success
90
+ assert_select "i.fa.fa-flag"
91
+ assert_select "span.fa-stack"
92
+ end
93
+ end
@@ -0,0 +1,138 @@
1
+ require 'test_helper'
2
+
3
+ class FontAwesomePropshaft::Rails::IconHelperTest < ActionView::TestCase
4
+
5
+ test "#fa_icon with no args should render a flag icon" do
6
+ assert_icon i("fa fa-flag")
7
+ end
8
+
9
+ test "#fa_icon should render different individual icons" do
10
+ assert_icon i("fa fa-flag"), "flag"
11
+ assert_icon i("fa fa-camera-retro"), "camera-retro"
12
+ assert_icon i("fa fa-cog"), "cog"
13
+ assert_icon i("fa fa-github"), "github"
14
+ end
15
+
16
+ test "#fa_icon should render icons with multiple modifiers" do
17
+ assert_icon i("fa fa-pencil fa-fixed-width"), "pencil fixed-width"
18
+ assert_icon i("fa fa-flag fa-4x"), "flag 4x"
19
+ assert_icon i("fa fa-refresh fa-2x fa-spin"), "refresh 2x spin"
20
+ end
21
+
22
+ test "#fa_icon should render icons with array modifiers" do
23
+ assert_icon i("fa fa-flag"), ["flag"]
24
+ assert_icon i("fa fa-check fa-li"), ["check", "li"]
25
+ assert_icon i("fa fa-flag fa-4x"), ["flag", "4x"]
26
+ assert_icon i("fa fa-refresh fa-2x fa-spin"), ["refresh", "2x", "spin"]
27
+ end
28
+
29
+ test "#fa_icon should incorporate additional class styles" do
30
+ assert_icon i("fa fa-flag pull-right"), "flag", :class => "pull-right"
31
+ assert_icon i("fa fa-flag fa-2x pull-right"), ["flag", "2x"], :class => ["pull-right"]
32
+ assert_icon i("fa fa-check fa-li pull-right special"), "check li", :class => "pull-right special"
33
+ assert_icon i("fa fa-check pull-right special"), "check", :class => ["pull-right", "special"]
34
+ end
35
+
36
+ test "#fa_icon should incorporate a text suffix" do
37
+ assert_icon "#{i("fa fa-camera-retro")} Take a photo", "camera-retro", :text => "Take a photo"
38
+ end
39
+
40
+ test "#fa_icon should be able to put the icon on the right" do
41
+ assert_icon "Submit #{i("fa fa-chevron-right")}", "chevron-right", :text => "Submit", :right => true
42
+ end
43
+
44
+ test "#fa_icon should html escape text" do
45
+ assert_icon "#{i("fa fa-camera-retro")} &lt;script&gt;&lt;/script&gt;", "camera-retro", :text => "<script></script>"
46
+ end
47
+
48
+ test "#fa_icon should not html escape safe text" do
49
+ assert_icon "#{i("fa fa-camera-retro")} <script></script>", "camera-retro", :text => "<script></script>".html_safe
50
+ end
51
+
52
+ test "#fa_icon should pull it all together" do
53
+ assert_icon "#{i("fa fa-camera-retro pull-right")} Take a photo", "camera-retro", :text => "Take a photo", :class => "pull-right"
54
+ end
55
+
56
+ test "#fa_icon should pass all other options through" do
57
+ assert_icon %(<i class="fa fa-user" data-id="123"></i>), "user", :data => { :id => 123 }
58
+ end
59
+
60
+ test '#fa_icon does not modify options' do
61
+ icon_options = { :class => 'foo', :data => { :id => 123 }, :text => 'bar' }
62
+ assert_icon %(<i class="fa fa-user foo" data-id="123"></i> bar), "user", icon_options
63
+ assert_includes icon_options, :class
64
+ assert_includes icon_options, :text
65
+ assert_includes icon_options, :data
66
+ end
67
+
68
+ test "#fa_stacked_icon with no args should render a flag icon" do
69
+ expected = %(<span class="fa-stack">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-flag fa-stack-1x")}</span>)
70
+ assert_stacked_icon expected
71
+ end
72
+
73
+ test "#fa_stacked_icon should render a stacked icon" do
74
+ expected = %(<span class="fa-stack">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span>)
75
+ assert_stacked_icon expected, "twitter", :base => "square-o"
76
+ expected = %(<span class="fa-stack">#{i("fa fa-square fa-stack-2x")}#{i("fa fa-terminal fa-inverse fa-stack-1x")}</span>)
77
+ assert_stacked_icon expected, ["terminal", "inverse"], :base => ["square"]
78
+ end
79
+
80
+ test "#fa_stacked_icon should incorporate additional class styles" do
81
+ expected = %(<span class="fa-stack pull-right">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span>)
82
+ assert_stacked_icon expected, "twitter", :base => "square-o", :class => "pull-right"
83
+ end
84
+
85
+ test "#fa_stacked_icon should reverse the stack" do
86
+ expected = %(<span class="fa-stack">#{i("fa fa-facebook fa-stack-1x")}#{i("fa fa-ban fa-stack-2x")}</span>)
87
+ assert_stacked_icon expected, "facebook", :base => "ban", :reverse => "true"
88
+ end
89
+
90
+ test "#fa_stacked_icon should be able to put the icon on the right" do
91
+ expected = %(Go <span class="fa-stack">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-exclamation fa-stack-1x")}</span>)
92
+ assert_stacked_icon expected, "exclamation", :text => "Go", :right => true
93
+ end
94
+
95
+ test "#fa_stacked_icon should html escape text" do
96
+ expected = %(<span class="fa-stack">#{i("fa fa-check-empty fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span> &lt;script&gt;)
97
+ assert_stacked_icon expected, "twitter", :base => "check-empty", :text => "<script>"
98
+ end
99
+
100
+ test "#fa_stacked_icon should not html escape safe text" do
101
+ expected = %(<span class="fa-stack">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span> <script>)
102
+ assert_stacked_icon expected, "twitter", :base => "square-o", :text => "<script>".html_safe
103
+ end
104
+
105
+ test "#fa_stacked_icon should accept options for base and main icons" do
106
+ expected = %(<span class="fa-stack">#{i("fa fa-camera fa-stack-1x text-info")}#{i("fa fa-ban fa-stack-2x text-error")}</span>)
107
+ assert_stacked_icon expected, "camera", :base => "ban", :reverse => true, :base_options => { :class => "text-error" }, :icon_options => { :class => "text-info" }
108
+ end
109
+
110
+ test "#fa_stacked_icon should pass all other options through" do
111
+ expected = %(<span class="fa-stack" data-id="123">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-user fa-stack-1x")}</span>)
112
+ assert_stacked_icon expected, "user", :base => "square-o", :data => { :id => 123 }
113
+ end
114
+
115
+ test '#fa_stacked_icon does not modify options' do
116
+ icon_options = { :class => 'foo', :base => "square-o", :data => { :id => 123 } }
117
+ expected = %(<span class="fa-stack foo" data-id="123">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-user fa-stack-1x")}</span>)
118
+ assert_stacked_icon expected, "user", icon_options
119
+ assert_includes icon_options, :class
120
+ assert_includes icon_options, :data
121
+ end
122
+
123
+ private
124
+
125
+ def assert_icon(expected, *args)
126
+ message = "`fa_icon(#{args.inspect[1...-1]})` should return `#{expected}`"
127
+ assert_dom_equal expected, fa_icon(*args), message
128
+ end
129
+
130
+ def assert_stacked_icon(expected, *args)
131
+ message = "`fa_stacked_icon(#{args.inspect[1...-1]})` should return `#{expected}`"
132
+ assert_dom_equal expected, fa_stacked_icon(*args), message
133
+ end
134
+
135
+ def i(classes)
136
+ %(<i class="#{classes}"></i>)
137
+ end
138
+ end
@@ -0,0 +1,7 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: font-awesome-propshaft
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - greenslonik10
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-10-06 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: railties
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '7.0'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '8.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '7.0'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '8.0'
32
+ - !ruby/object:Gem::Dependency
33
+ name: propshaft
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0.8'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0.8'
46
+ - !ruby/object:Gem::Dependency
47
+ name: sassc
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '2.4'
53
+ type: :runtime
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '2.4'
60
+ - !ruby/object:Gem::Dependency
61
+ name: activesupport
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '8.1'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '8.1'
74
+ description: font-awesome-propshaft provides the Font-Awesome web fonts and stylesheets
75
+ as a Rails engine for use with the asset pipeline.
76
+ email:
77
+ - zazulinnikk@gmail.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - LICENSE
83
+ - README.md
84
+ - Rakefile
85
+ - app/assets/fonts/fa-brands-400.ttf
86
+ - app/assets/fonts/fa-brands-400.woff2
87
+ - app/assets/fonts/fa-regular-400.ttf
88
+ - app/assets/fonts/fa-regular-400.woff2
89
+ - app/assets/fonts/fa-solid-900.ttf
90
+ - app/assets/fonts/fa-solid-900.woff2
91
+ - app/assets/fonts/fa-v4compatibility.ttf
92
+ - app/assets/fonts/fa-v4compatibility.woff2
93
+ - app/assets/stylesheets/font-awesome-propshaft.css
94
+ - app/helpers/font_awesome_propshaft/rails/icon_helper.rb
95
+ - lib/font-awesome-propshaft.rb
96
+ - lib/font-awesome-propshaft/engine.rb
97
+ - lib/font-awesome-propshaft/version.rb
98
+ - test/dummy/app/assets/stylesheets/sass-import.css.sass
99
+ - test/dummy/app/assets/stylesheets/scss-import.css.scss
100
+ - test/dummy/app/controllers/pages_controller.rb
101
+ - test/dummy/app/views/pages/icons.html.erb
102
+ - test/dummy/config.ru
103
+ - test/dummy/config/application.rb
104
+ - test/dummy/config/boot.rb
105
+ - test/dummy/config/environment.rb
106
+ - test/dummy/config/initializers/secret_token.rb
107
+ - test/dummy/config/routes.rb
108
+ - test/dummy/log/test.log
109
+ - test/dummy/tmp/local_secret.txt
110
+ - test/font_awesome_propshaft_rails_test.rb
111
+ - test/icon_helper_test.rb
112
+ - test/test_helper.rb
113
+ homepage: https://github.com/greenslonik10/font-awesome-propshaft
114
+ licenses:
115
+ - MIT
116
+ - Apache-2.0
117
+ metadata: {}
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: 1.9.3
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubygems_version: 3.6.2
133
+ specification_version: 4
134
+ summary: an asset gemification of the font-awesome icon font library
135
+ test_files: []