btakita-jelly 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/jelly/jelly_helper.rb +3 -2
- data/spec/helpers/jelly_helper_spec.rb +16 -5
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/jelly/jelly_helper.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module JellyHelper
|
2
2
|
|
3
3
|
def application_jelly_files(jelly_files_path_from_javascripts = '', rails_root = RAILS_ROOT)
|
4
|
+
rails_root = File.expand_path(rails_root)
|
4
5
|
(
|
5
|
-
Dir["#{rails_root}/public/javascripts/#{jelly_files_path_from_javascripts}/components/**/*.js"] +
|
6
|
-
Dir["#{rails_root}/public/javascripts/#{jelly_files_path_from_javascripts}/pages/**/*.js"]
|
6
|
+
Dir[File.expand_path("#{rails_root}/public/javascripts/#{jelly_files_path_from_javascripts}/components/**/*.js")] +
|
7
|
+
Dir[File.expand_path("#{rails_root}/public/javascripts/#{jelly_files_path_from_javascripts}/pages/**/*.js")]
|
7
8
|
).map do |path|
|
8
9
|
path.gsub("#{rails_root}/public/javascripts/", "").gsub(/\.js$/, "")
|
9
10
|
end
|
@@ -14,11 +14,22 @@ describe JellyHelper do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#application_jelly_files" do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
context "when passing in a jelly path" do
|
18
|
+
it "returns the javascript files in /javascipts/:jelly_path/pages and /javascipts/:jelly_path/components" do
|
19
|
+
my_rails_root = File.join(File.dirname(__FILE__), '/../fixtures')
|
20
|
+
files = helper.application_jelly_files("foo", my_rails_root)
|
21
|
+
files.should_not be_empty
|
22
|
+
files.should =~ ['foo/components/paw', 'foo/components/teeth', 'foo/pages/lions', 'foo/pages/tigers', 'foo/pages/bears']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when not passing in a jelly path" do
|
27
|
+
it "returns the javascript files in /javascipts/pages and /javascipts/components" do
|
28
|
+
my_rails_root = File.join(File.dirname(__FILE__), '/../fixtures')
|
29
|
+
files = helper.application_jelly_files("", my_rails_root)
|
30
|
+
files.should_not be_empty
|
31
|
+
files.should =~ ['components/component1', 'pages/page1']
|
32
|
+
end
|
22
33
|
end
|
23
34
|
end
|
24
35
|
|