thumblemonks-chicago 0.1.2 → 0.1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/chicago.gemspec +1 -1
- data/lib/chicago/helpers.rb +8 -2
- data/test/helpers_test.rb +8 -0
- metadata +1 -1
data/chicago.gemspec
CHANGED
data/lib/chicago/helpers.rb
CHANGED
@@ -8,18 +8,24 @@ module Thumblemonks
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def stylesheet_include(name, options={})
|
11
|
-
|
11
|
+
name = "/stylesheets/#{name}.css" unless remote_asset?(name)
|
12
|
+
defaults = {:href => name, :media => "screen",
|
12
13
|
:rel => "stylesheet", :type => "text/css"}
|
13
14
|
options_str = hash_to_attributes(defaults.merge(options))
|
14
15
|
%Q[<link #{options_str}/>]
|
15
16
|
end
|
16
17
|
|
17
18
|
def javascript_include(name, options={})
|
18
|
-
|
19
|
+
name = "/javascripts/#{name}.js" unless remote_asset?(name)
|
20
|
+
defaults = {:src => name, :type => "text/javascript"}
|
19
21
|
options_str = hash_to_attributes(defaults.merge(options))
|
20
22
|
%Q[<script #{options_str}></script>]
|
21
23
|
end
|
22
24
|
private
|
25
|
+
def remote_asset?(uri)
|
26
|
+
uri =~ %r[^\w+://.+]
|
27
|
+
end
|
28
|
+
|
23
29
|
def hash_to_attributes(options)
|
24
30
|
options.map {|k,v| "#{k}=\"#{v}\""}.join(' ')
|
25
31
|
end
|
data/test/helpers_test.rb
CHANGED
@@ -18,6 +18,10 @@ class HelpersTest < Test::Unit::TestCase
|
|
18
18
|
assert_match %r[type="text/css"], @response.body
|
19
19
|
assert_match %r[baz="boo"], @response.body
|
20
20
|
end
|
21
|
+
|
22
|
+
should_invoke_helper(:stylesheet_include, 'http://example.com') do
|
23
|
+
assert_match %r[href="http://example.com"], @response.body
|
24
|
+
end
|
21
25
|
end # including stylesheets
|
22
26
|
|
23
27
|
context "including javascript" do
|
@@ -33,6 +37,10 @@ class HelpersTest < Test::Unit::TestCase
|
|
33
37
|
assert_match %r[type="text/blarg"], @response.body
|
34
38
|
assert_match %r[gus="nice"], @response.body
|
35
39
|
end
|
40
|
+
|
41
|
+
should_invoke_helper(:javascript_include, 'http://example.com') do
|
42
|
+
assert_match %r[src="http://example.com"], @response.body
|
43
|
+
end
|
36
44
|
end # including javascript
|
37
45
|
|
38
46
|
context "using an anchor" do
|