assets_booster 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ module AssetsBooster
13
13
 
14
14
  def view_helper(view, options)
15
15
  if options[:inline]
16
- view.javascript_tag(read)
16
+ view.javascript_tag(read, options.except(:inline))
17
17
  else
18
18
  view.javascript_include_tag(view_helper_sources, options)
19
19
  end
@@ -13,7 +13,7 @@ module AssetsBooster
13
13
 
14
14
  def view_helper(view, options)
15
15
  if options[:inline]
16
- view.style_tag(read)
16
+ view.style_tag(read, options.except(:inline))
17
17
  else
18
18
  view.stylesheet_link_tag(view_helper_sources, options)
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module AssetsBooster
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module AssetsBooster
2
2
  module ViewHelper
3
- def style_tag(css)
4
- content_tag(:style, css, :type => Mime::CSS)
3
+ def style_tag(css, options = {})
4
+ content_tag(:style, css, options.merge(:type => Mime::CSS))
5
5
  end
6
6
 
7
7
  def assets_booster_tag(type, *names)
@@ -15,21 +15,34 @@ module AssetsBooster
15
15
  @view = double("View")
16
16
  end
17
17
 
18
- describe "with the inline option enabled" do
18
+ describe "with the inline option" do
19
+ before do
20
+ @options = {:a => "b", :inline => true}
21
+ end
22
+
19
23
  it "should return a javascript tag with inline javascript" do
20
- subject.should_receive(:read).with().and_return("javascript code")
21
- @view.should_receive(:javascript_tag).with("javascript code")
22
- subject.view_helper(@view, :inline => true)
24
+ subject.should_receive(:read).with()
25
+ @view.should_receive(:javascript_tag).and_return("<script>javascript</script>")
26
+ subject.view_helper(@view, @options).should == "<script>javascript</script>"
27
+ end
28
+
29
+ it "should not pass the inline option to the tag generator" do
30
+ subject.should_receive(:read).and_return("js code")
31
+ @view.should_receive(:javascript_tag).with("js code", @options.except(:inline))
32
+ subject.view_helper(@view, @options)
23
33
  end
24
34
  end
25
35
 
26
- describe "with no options" do
36
+ describe "with no special options" do
37
+ before do
38
+ @options = {:a => "b"}
39
+ end
40
+
27
41
  it "should return html tags" do
28
- options = {}
29
42
  sources = ["source1.js", "source2.js"]
30
43
  subject.should_receive(:view_helper_sources).and_return(sources)
31
- @view.should_receive(:javascript_include_tag).with(sources, options)
32
- subject.view_helper(@view, options)
44
+ @view.should_receive(:javascript_include_tag).with(sources, @options)
45
+ subject.view_helper(@view, @options)
33
46
  end
34
47
  end
35
48
  end
@@ -15,21 +15,34 @@ module AssetsBooster
15
15
  @view = double("View")
16
16
  end
17
17
 
18
- describe "with the inline option enabled" do
18
+ describe "with the inline option" do
19
+ before do
20
+ @options = {:a => "b", :inline => true}
21
+ end
22
+
19
23
  it "should return a style tag with inline css" do
20
- subject.should_receive(:read).with().and_return("css code")
21
- @view.should_receive(:style_tag).with("css code")
22
- subject.view_helper(@view, :inline => true)
24
+ subject.should_receive(:read).with()
25
+ @view.should_receive(:style_tag).and_return("<style>css</style>")
26
+ subject.view_helper(@view, @options).should == "<style>css</style>"
27
+ end
28
+
29
+ it "should not pass the inline option to the tag generator" do
30
+ subject.should_receive(:read).and_return("css code")
31
+ @view.should_receive(:style_tag).with("css code", @options.except(:inline))
32
+ subject.view_helper(@view, @options)
23
33
  end
24
34
  end
25
35
 
26
- describe "with no options" do
36
+ describe "with no special options" do
37
+ before do
38
+ @options = {:a => "b"}
39
+ end
40
+
27
41
  it "should return html tags" do
28
- options = {}
29
42
  sources = ["source1.css", "source2.css"]
30
43
  subject.should_receive(:view_helper_sources).and_return(sources)
31
- @view.should_receive(:stylesheet_link_tag).with(sources, options)
32
- subject.view_helper(@view, options)
44
+ @view.should_receive(:stylesheet_link_tag).with(sources, @options)
45
+ subject.view_helper(@view, @options)
33
46
  end
34
47
  end
35
48
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
+
3
4
  require 'rails'
5
+ require 'active_support/all'
4
6
 
5
7
  require 'assets_booster'
6
8
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: assets_booster
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.8
5
+ version: 0.0.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Corin Langosch