font-awesome-rails 3.2.1.2 → 3.2.1.3
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.
- checksums.yaml +4 -4
- data/README.md +35 -0
- data/app/helpers/font_awesome/rails/icon_helper.rb +89 -0
- data/lib/font-awesome-rails/version.rb +1 -1
- data/test/dummy/app/controllers/pages_controller.rb +2 -0
- data/test/dummy/app/views/pages/icons.html.erb +3 -0
- data/test/dummy/config/routes.rb +1 -0
- data/test/dummy/log/test.log +4612 -9427
- data/test/font_awesome_rails_test.rb +7 -0
- data/test/icon_helper_test.rb +113 -0
- metadata +9 -2
@@ -49,6 +49,13 @@ class FontAwesomeRailsTest < ActionDispatch::IntegrationTest
|
|
49
49
|
assert_font_awesome(response)
|
50
50
|
end
|
51
51
|
|
52
|
+
test "helpers should be available in the view" do
|
53
|
+
get "/icons"
|
54
|
+
assert_response :success
|
55
|
+
assert_select "i.icon-flag"
|
56
|
+
assert_select "span.icon-stack"
|
57
|
+
end
|
58
|
+
|
52
59
|
private
|
53
60
|
|
54
61
|
def clean_sprockets_cache
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class FontAwesome::Rails::IconHelperTest < ActionView::TestCase
|
4
|
+
|
5
|
+
test "#fa_icon with no args should render a flag icon" do
|
6
|
+
assert_icon i("icon-flag")
|
7
|
+
end
|
8
|
+
|
9
|
+
test "#fa_icon should render different individual icons" do
|
10
|
+
assert_icon i("icon-flag"), "flag"
|
11
|
+
assert_icon i("icon-camera-retro"), "camera-retro"
|
12
|
+
assert_icon i("icon-cog"), "cog"
|
13
|
+
assert_icon i("icon-github"), "github"
|
14
|
+
end
|
15
|
+
|
16
|
+
test "#fa_icon should render icons with multiple modifiers" do
|
17
|
+
assert_icon i("icon-pencil icon-fixed-width"), "pencil fixed-width"
|
18
|
+
assert_icon i("icon-flag icon-4x"), "flag 4x"
|
19
|
+
assert_icon i("icon-refresh icon-2x icon-spin"), "refresh 2x spin"
|
20
|
+
end
|
21
|
+
|
22
|
+
test "#fa_icon should render icons with array modifiers" do
|
23
|
+
assert_icon i("icon-flag"), ["flag"]
|
24
|
+
assert_icon i("icon-ok icon-li"), ["ok", "li"]
|
25
|
+
assert_icon i("icon-flag icon-4x"), ["flag", "4x"]
|
26
|
+
assert_icon i("icon-refresh icon-2x icon-spin"), ["refresh", "2x", "spin"]
|
27
|
+
end
|
28
|
+
|
29
|
+
test "#fa_icon should incorporate additional class styles" do
|
30
|
+
assert_icon i("icon-flag pull-right"), "flag", :class => "pull-right"
|
31
|
+
assert_icon i("icon-flag icon-2x pull-right"), ["flag", "2x"], :class => ["pull-right"]
|
32
|
+
assert_icon i("icon-ok icon-li pull-right special"), "ok li", :class => "pull-right special"
|
33
|
+
assert_icon i("icon-ok pull-right special"), "ok", :class => ["pull-right", "special"]
|
34
|
+
end
|
35
|
+
|
36
|
+
test "#fa_icon should incorporate a text suffix" do
|
37
|
+
assert_icon "#{i("icon-camera-retro")} Take a photo", "camera-retro", :text => "Take a photo"
|
38
|
+
end
|
39
|
+
|
40
|
+
test "#fa_icon should html escape text" do
|
41
|
+
assert_icon "#{i("icon-camera-retro")} <script></script>", "camera-retro", :text => "<script></script>"
|
42
|
+
end
|
43
|
+
|
44
|
+
test "#fa_icon should not html escape safe text" do
|
45
|
+
assert_icon "#{i("icon-camera-retro")} <script></script>", "camera-retro", :text => "<script></script>".html_safe
|
46
|
+
end
|
47
|
+
|
48
|
+
test "#fa_icon should pull it all together" do
|
49
|
+
assert_icon "#{i("icon-camera-retro pull-right")} Take a photo", "camera-retro", :text => "Take a photo", :class => "pull-right"
|
50
|
+
end
|
51
|
+
|
52
|
+
test "#fa_icon should pass all other options through" do
|
53
|
+
assert_icon %(<i class="icon-user" data-id="123"></i>), "user", :data => { :id => 123 }
|
54
|
+
end
|
55
|
+
|
56
|
+
test "#fa_stacked_icon with no args should render a flag icon" do
|
57
|
+
expected = %(<span class="icon-stack">#{i("icon-stack-base")}#{i("icon-flag")}</span>)
|
58
|
+
assert_stacked_icon expected
|
59
|
+
end
|
60
|
+
|
61
|
+
test "#fa_stacked_icon should render a stacked icon" do
|
62
|
+
expected = %(<span class="icon-stack">#{i("icon-check-empty icon-stack-base")}#{i("icon-twitter")}</span>)
|
63
|
+
assert_stacked_icon expected, "twitter", :base => "check-empty"
|
64
|
+
expected = %(<span class="icon-stack">#{i("icon-sign-blank icon-stack-base")}#{i("icon-terminal icon-light")}</span>)
|
65
|
+
assert_stacked_icon expected, ["terminal", "light"], :base => ["sign-blank"]
|
66
|
+
end
|
67
|
+
|
68
|
+
test "#fa_stacked_icon should incorporate additional class styles" do
|
69
|
+
expected = %(<span class="icon-stack pull-right">#{i("icon-check-empty icon-stack-base")}#{i("icon-twitter")}</span>)
|
70
|
+
assert_stacked_icon expected, "twitter", :base => "check-empty", :class => "pull-right"
|
71
|
+
end
|
72
|
+
|
73
|
+
test "#fa_stacked_icon should reverse the stack" do
|
74
|
+
expected = %(<span class="icon-stack">#{i("icon-facebook")}#{i("icon-ban-circle icon-stack-base")}</span>)
|
75
|
+
assert_stacked_icon expected, "facebook", :base => "ban-circle", :reverse => "true"
|
76
|
+
end
|
77
|
+
|
78
|
+
test "#fa_stacked_icon should html escape text" do
|
79
|
+
expected = %(<span class="icon-stack">#{i("icon-check-empty icon-stack-base")}#{i("icon-twitter")}</span> <script>)
|
80
|
+
assert_stacked_icon expected, "twitter", :base => "check-empty", :text => "<script>"
|
81
|
+
end
|
82
|
+
|
83
|
+
test "#fa_stacked_icon should not html escape safe text" do
|
84
|
+
expected = %(<span class="icon-stack">#{i("icon-check-empty icon-stack-base")}#{i("icon-twitter")}</span> <script>)
|
85
|
+
assert_stacked_icon expected, "twitter", :base => "check-empty", :text => "<script>".html_safe
|
86
|
+
end
|
87
|
+
|
88
|
+
test "#fa_stacked_icon should accept options for base and main icons" do
|
89
|
+
expected = %(<span class="icon-stack">#{i("icon-camera text-info")}#{i("icon-ban-circle icon-stack-base text-error")}</span>)
|
90
|
+
assert_stacked_icon expected, "camera", :base => "ban-circle", :reverse => true, :base_options => { :class => "text-error" }, :icon_options => { :class => "text-info" }
|
91
|
+
end
|
92
|
+
|
93
|
+
test "#fa_stacked_icon should pass all other options through" do
|
94
|
+
expected = %(<span class="icon-stack" data-id="123">#{i("icon-check-empty icon-stack-base")}#{i("icon-user")}</span>)
|
95
|
+
assert_stacked_icon expected, "user", :base => "check-empty", :data => { :id => 123 }
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def assert_icon(expected, *args)
|
101
|
+
message = "`fa_icon(#{args.inspect[1...-1]})` should return `#{expected}`"
|
102
|
+
assert_dom_equal expected, fa_icon(*args), message
|
103
|
+
end
|
104
|
+
|
105
|
+
def assert_stacked_icon(expected, *args)
|
106
|
+
message = "`fa_stacked_icon(#{args.inspect[1...-1]})` should return `#{expected}`"
|
107
|
+
assert_dom_equal expected, fa_stacked_icon(*args), message
|
108
|
+
end
|
109
|
+
|
110
|
+
def i(classes)
|
111
|
+
%(<i class="#{classes}"></i>)
|
112
|
+
end
|
113
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: font-awesome-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.1.
|
4
|
+
version: 3.2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bokmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- app/assets/stylesheets/font-awesome-ie7.css
|
89
89
|
- app/assets/stylesheets/font-awesome-ie7.min.css
|
90
90
|
- app/assets/stylesheets/font-awesome.css.erb
|
91
|
+
- app/helpers/font_awesome/rails/icon_helper.rb
|
91
92
|
- lib/font-awesome-rails/engine.rb
|
92
93
|
- lib/font-awesome-rails/version.rb
|
93
94
|
- lib/font-awesome-rails.rb
|
@@ -97,6 +98,8 @@ files:
|
|
97
98
|
- test/dummy/app/assets/stylesheets/sass-import.css.sass
|
98
99
|
- test/dummy/app/assets/stylesheets/scss-import.css.scss
|
99
100
|
- test/dummy/app/assets/stylesheets/sprockets-require.css
|
101
|
+
- test/dummy/app/controllers/pages_controller.rb
|
102
|
+
- test/dummy/app/views/pages/icons.html.erb
|
100
103
|
- test/dummy/config/application.rb
|
101
104
|
- test/dummy/config/boot.rb
|
102
105
|
- test/dummy/config/environment.rb
|
@@ -105,6 +108,7 @@ files:
|
|
105
108
|
- test/dummy/config.ru
|
106
109
|
- test/dummy/log/test.log
|
107
110
|
- test/font_awesome_rails_test.rb
|
111
|
+
- test/icon_helper_test.rb
|
108
112
|
- test/test_helper.rb
|
109
113
|
homepage: https://github.com/bokmann/font-awesome-rails
|
110
114
|
licenses:
|
@@ -135,6 +139,8 @@ test_files:
|
|
135
139
|
- test/dummy/app/assets/stylesheets/sass-import.css.sass
|
136
140
|
- test/dummy/app/assets/stylesheets/scss-import.css.scss
|
137
141
|
- test/dummy/app/assets/stylesheets/sprockets-require.css
|
142
|
+
- test/dummy/app/controllers/pages_controller.rb
|
143
|
+
- test/dummy/app/views/pages/icons.html.erb
|
138
144
|
- test/dummy/config/application.rb
|
139
145
|
- test/dummy/config/boot.rb
|
140
146
|
- test/dummy/config/environment.rb
|
@@ -143,4 +149,5 @@ test_files:
|
|
143
149
|
- test/dummy/config.ru
|
144
150
|
- test/dummy/log/test.log
|
145
151
|
- test/font_awesome_rails_test.rb
|
152
|
+
- test/icon_helper_test.rb
|
146
153
|
- test/test_helper.rb
|