rack-less 2.0.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -4
- data/Gemfile +3 -0
- data/Gemfile.lock +15 -19
- data/README.rdoc +9 -7
- data/Rakefile +3 -3
- data/lib/rack/less/base.rb +1 -1
- data/lib/rack/less/config.rb +1 -1
- data/lib/rack/less/response.rb +4 -4
- data/lib/rack/less/source.rb +6 -1
- data/lib/rack/less/version.rb +2 -2
- data/rack-less.gemspec +4 -3
- data/test/app_helper.rb +3 -3
- data/test/bootstrap_test.rb +26 -0
- data/test/config_test.rb +112 -150
- data/test/fixtures/bootstrap_v1.1.0/bootstrap-1.1.0.css +1894 -0
- data/test/fixtures/bootstrap_v1.1.0/bootstrap.less +23 -0
- data/test/fixtures/bootstrap_v1.1.0/forms.less +369 -0
- data/test/fixtures/bootstrap_v1.1.0/patterns.less +683 -0
- data/test/fixtures/bootstrap_v1.1.0/preboot.less +267 -0
- data/test/fixtures/bootstrap_v1.1.0/reset.less +21 -0
- data/test/fixtures/bootstrap_v1.1.0/scaffolding.less +174 -0
- data/test/fixtures/bootstrap_v1.1.0/tables.less +148 -0
- data/test/fixtures/bootstrap_v1.1.0/type.less +185 -0
- data/test/fixtures/sinatra/app/stylesheets/all_compiled.css +7 -3
- data/test/fixtures/sinatra/app/stylesheets/nested/file_compiled.css +6 -2
- data/test/fixtures/sinatra/app/stylesheets/nested/nested_import.less +3 -0
- data/test/fixtures/sinatra/app/stylesheets/nested/really/really.less +5 -3
- data/test/fixtures/sinatra/app/stylesheets/nested/really/really_compiled.css +7 -2
- data/test/fixtures/sinatra/app/stylesheets/nested/really/really_nested_import.less +4 -0
- data/test/fixtures/sinatra/app/stylesheets/normal.less +1 -1
- data/test/fixtures/sinatra/app/stylesheets/normal_compiled.css +6 -2
- data/test/helper.rb +35 -38
- data/test/irb.rb +9 -0
- data/test/options_test.rb +25 -22
- data/test/request_test.rb +86 -74
- data/test/response_test.rb +6 -4
- data/test/sinatra_test.rb +38 -37
- data/test/source_test.rb +128 -114
- metadata +57 -34
- data/.bundle/config +0 -2
- data/test/env.rb +0 -9
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,37 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rack-less (
|
5
|
-
less (~>
|
4
|
+
rack-less (3.0.0)
|
5
|
+
less (~> 2.0)
|
6
6
|
rack (~> 1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
less (
|
16
|
-
|
17
|
-
|
18
|
-
mutter (0.5.3)
|
11
|
+
ansi (1.3.0)
|
12
|
+
assert (0.3.0)
|
13
|
+
ansi (~> 1.3)
|
14
|
+
differ (0.1.2)
|
15
|
+
less (2.0.6)
|
16
|
+
therubyracer (~> 0.9.2)
|
17
|
+
libv8 (3.3.10.2)
|
19
18
|
nokogiri (1.4.4)
|
20
|
-
polyglot (0.3.1)
|
21
19
|
rack (1.2.2)
|
22
20
|
rack-test (0.5.7)
|
23
21
|
rack (>= 1.0)
|
24
|
-
|
22
|
+
rake (0.9.2)
|
25
23
|
sinatra (1.2.1)
|
26
24
|
rack (~> 1.1)
|
27
25
|
tilt (>= 1.2.2, < 2.0)
|
28
|
-
|
29
|
-
|
30
|
-
leftright (~> 0.9.0)
|
31
|
-
shoulda (~> 2.11)
|
26
|
+
therubyracer (0.9.4)
|
27
|
+
libv8 (~> 3.3.10)
|
32
28
|
tilt (1.2.2)
|
33
|
-
treetop (1.4.9)
|
34
|
-
polyglot (>= 0.3.1)
|
35
29
|
webrat (0.7.3)
|
36
30
|
nokogiri (>= 1.2.0)
|
37
31
|
rack (>= 1.0)
|
@@ -42,10 +36,12 @@ PLATFORMS
|
|
42
36
|
ruby
|
43
37
|
|
44
38
|
DEPENDENCIES
|
39
|
+
assert (~> 0.3.0)
|
45
40
|
bundler (~> 1.0)
|
41
|
+
differ
|
46
42
|
rack-less!
|
47
43
|
rack-test (>= 0.5.3)
|
44
|
+
rake (~> 0.9.2)
|
48
45
|
sinatra (>= 0.9.4)
|
49
|
-
test-belt (= 0.2.1)
|
50
46
|
webrat (>= 0.6.0)
|
51
47
|
yui-compressor (>= 0.9.1)
|
data/README.rdoc
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
A better way to use LESS CSS in Ruby web apps.
|
6
6
|
|
7
|
+
* Update: rack-less as of v3.x.x \ uses the latest version of the ruby less parser, https://github.com/cowboyd/less.rb (based on less.js). To use the older ruby based parse, require rack-less ~> 2.0.
|
8
|
+
|
7
9
|
== Installation
|
8
10
|
|
9
11
|
$ gem install rack-less
|
@@ -16,7 +18,7 @@ or uses Rack::Builder to construct the application pipeline, simply require
|
|
16
18
|
and use as follows:
|
17
19
|
|
18
20
|
require 'rack/less'
|
19
|
-
|
21
|
+
|
20
22
|
# optional - use as necessary
|
21
23
|
Rack::Less.configure do |config|
|
22
24
|
config.compress = true
|
@@ -49,7 +51,7 @@ Add any configs in an initializer (optional - use as necessary):
|
|
49
51
|
You should now see `Rack::Less` listed in the middleware pipeline:
|
50
52
|
|
51
53
|
rake middleware
|
52
|
-
|
54
|
+
|
53
55
|
== Available Configurations
|
54
56
|
|
55
57
|
* .*cache* [false]
|
@@ -69,7 +71,7 @@ You should now see `Rack::Less` listed in the middleware pipeline:
|
|
69
71
|
- :*true* - use Time.now.to_i as the explicit value (will never cache)
|
70
72
|
- :*nil* - change cache bust value if the file is modified (similar to Rails' stylesheet_link_tag)
|
71
73
|
- :*<any other value>* - add the value as "foo.css?<value>"
|
72
|
-
|
74
|
+
|
73
75
|
== Available Options
|
74
76
|
|
75
77
|
* :*root* ["."]
|
@@ -101,7 +103,7 @@ At times, it is useful to combine multiple stylesheets and serve them as one res
|
|
101
103
|
|
102
104
|
stylesheet_link_tag 'reset', 'common', 'app_web', :cache => 'web'
|
103
105
|
stylesheet_link_tag 'reset', 'common', 'iui', 'app_mobile', :cache => 'mobile'
|
104
|
-
|
106
|
+
|
105
107
|
Rack::Less uses combinations, in conjunction with the :cache config setting, to provide this function. Combinations are configured using a hash, where the key is the resource name and the value is an array of names corresponding to stylesheets to combine as the named resource. For the above example, use a configuration like this:
|
106
108
|
|
107
109
|
Rack::Less.configure do |config|
|
@@ -115,14 +117,14 @@ and stylesheet link tags like this:
|
|
115
117
|
|
116
118
|
# equivalent to: stylesheet_link_tag 'reset', 'common', 'app_web'
|
117
119
|
stylesheet_link_tag Rack::Less.stylesheet('web')
|
118
|
-
|
120
|
+
|
119
121
|
# equivalent to: stylesheet_link_tag 'reset', 'common', 'iui', 'app_mobile'
|
120
122
|
stylesheet_link_tag Rack::Less.stylesheet('mobile')
|
121
|
-
|
123
|
+
|
122
124
|
If you configure Rack::Less to cache, with something like this:
|
123
125
|
|
124
126
|
Rack::Less.config.cache = true
|
125
|
-
|
127
|
+
|
126
128
|
then the same stylesheet link tags behave like they have the :cache option set, respectively:
|
127
129
|
|
128
130
|
# equivalent to: stylesheet_link_tag 'reset', 'common', 'app_web', :cache => 'web'
|
data/Rakefile
CHANGED
data/lib/rack/less/base.rb
CHANGED
data/lib/rack/less/config.rb
CHANGED
data/lib/rack/less/response.rb
CHANGED
@@ -11,7 +11,7 @@ module Rack::Less
|
|
11
11
|
|
12
12
|
# Rack response tuple accessors.
|
13
13
|
attr_accessor :status, :headers, :body
|
14
|
-
|
14
|
+
|
15
15
|
class << self
|
16
16
|
|
17
17
|
# Calculate appropriate content_length
|
@@ -22,7 +22,7 @@ module Rack::Less
|
|
22
22
|
body.size
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
end
|
27
27
|
|
28
28
|
# Create a Response instance given the env
|
@@ -36,10 +36,10 @@ module Rack::Less
|
|
36
36
|
headers["Content-Type"] = Rack::Less::MIME_TYPE
|
37
37
|
headers["Content-Length"] = self.class.content_length(body).to_s
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def to_rack
|
41
41
|
[status, headers.to_hash, body]
|
42
42
|
end
|
43
43
|
|
44
44
|
end
|
45
|
-
end
|
45
|
+
end
|
data/lib/rack/less/source.rb
CHANGED
@@ -48,7 +48,12 @@ module Rack::Less
|
|
48
48
|
def compiled
|
49
49
|
@compiled ||= begin
|
50
50
|
compiled_css = files.collect do |file_path|
|
51
|
-
|
51
|
+
opts = {
|
52
|
+
:paths => [ File.dirname(file_path) ],
|
53
|
+
:filename => File.basename(file_path)
|
54
|
+
}
|
55
|
+
less = File.send(File.respond_to?(:binread) ? :binread : :read, file_path.to_s)
|
56
|
+
Less::Parser.new(opts).parse(less).to_css(:compress => !!@compress)
|
52
57
|
end.join("\n")
|
53
58
|
|
54
59
|
compiled_css = case @compress
|
data/lib/rack/less/version.rb
CHANGED
data/rack-less.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ["kelly@kelredd.com"]
|
11
11
|
s.homepage = "http://github.com/kelredd/rack-less"
|
12
12
|
s.summary = %q{LESS CSS preprocessing for Rack apps.}
|
13
|
-
s.description = %q{
|
13
|
+
s.description = %q{LESS CSS preprocessing for Rack apps.}
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -18,12 +18,13 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
20
|
s.add_development_dependency("bundler", ["~> 1.0"])
|
21
|
-
s.add_development_dependency("
|
21
|
+
s.add_development_dependency("assert", ["~>0.3.0"])
|
22
|
+
|
22
23
|
s.add_development_dependency("sinatra", [">= 0.9.4"])
|
23
24
|
s.add_development_dependency("rack-test", [">= 0.5.3"])
|
24
25
|
s.add_development_dependency("webrat", [">= 0.6.0"])
|
25
26
|
s.add_development_dependency("yui-compressor", [">=0.9.1"])
|
26
27
|
|
27
28
|
s.add_dependency("rack", ["~> 1.0"])
|
28
|
-
s.add_dependency("less", ["~>
|
29
|
+
s.add_dependency("less", ["~> 2.0"])
|
29
30
|
end
|
data/test/app_helper.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'rack/test'
|
2
2
|
require 'webrat'
|
3
3
|
|
4
|
-
class
|
4
|
+
class Assert::Context
|
5
5
|
include Rack::Test::Methods
|
6
6
|
include Webrat::Methods
|
7
7
|
include Webrat::Matchers
|
8
|
-
|
8
|
+
|
9
9
|
Webrat.configure do |config|
|
10
10
|
config.mode = :rack
|
11
|
-
end
|
11
|
+
end
|
12
12
|
|
13
13
|
class << self
|
14
14
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "assert"
|
2
|
+
require 'rack/less/source'
|
3
|
+
|
4
|
+
require 'differ'
|
5
|
+
|
6
|
+
module Rack::Less
|
7
|
+
|
8
|
+
class BootstrapSourceTests < Assert::Context
|
9
|
+
desc 'the bootstrap less source'
|
10
|
+
setup do
|
11
|
+
@source_folder = file_path('test','fixtures', 'bootstrap_v1.1.0')
|
12
|
+
@compiled = File.read(File.join(@source_folder, "bootstrap-1.1.0.css"))
|
13
|
+
@source = Source.new('bootstrap', :folder => @source_folder)
|
14
|
+
end
|
15
|
+
|
16
|
+
should "compile correctly" do
|
17
|
+
assert_equal @compiled.strip, @source.compiled.strip, '.compiled is incorrect'
|
18
|
+
assert_equal @compiled.strip, @source.to_css.strip, '.to_css is incorrect'
|
19
|
+
assert_equal @compiled.strip, @source.css.strip, '.css is incorrect'
|
20
|
+
|
21
|
+
puts Differ.diff_by_line(@source.compiled.strip, @compiled.strip).format_as(:color)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/test/config_test.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
-
require "
|
1
|
+
require "assert"
|
2
2
|
require 'rack/less/config'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
module Rack::Less
|
5
|
+
|
6
|
+
class ConfigTests < Assert::Context
|
7
|
+
desc 'the rack-less config'
|
8
|
+
setup { @config = Config.new }
|
9
|
+
subject { @config }
|
10
|
+
|
11
|
+
should have_accessors :cache, :compress, :combinations, :cache_bust
|
12
|
+
should have_readers :cache?, :compress?
|
9
13
|
|
10
14
|
{ :cache => false,
|
11
15
|
:compress => false,
|
@@ -15,17 +19,10 @@ class ConfigTest < Test::Unit::TestCase
|
|
15
19
|
should "default #{k} correctly" do
|
16
20
|
assert_equal v, @config.send(k)
|
17
21
|
end
|
18
|
-
|
19
|
-
should "have an accessor for #{k}" do
|
20
|
-
assert_respond_to @config, k, "no reader for #{k}"
|
21
|
-
assert_respond_to @config, "#{k}=".to_sym, "no writer for #{k}"
|
22
|
-
end
|
23
22
|
end
|
24
23
|
|
25
24
|
should "provide boolean readers" do
|
26
|
-
assert_respond_to @config, :cache?, "no reader for :cache?"
|
27
25
|
assert_equal !!@config.cache, @config.cache?
|
28
|
-
assert_respond_to @config, :compress?, "no reader for :compress?"
|
29
26
|
assert_equal !!@config.compress, @config.compress?
|
30
27
|
end
|
31
28
|
|
@@ -47,169 +44,134 @@ class ConfigTest < Test::Unit::TestCase
|
|
47
44
|
end
|
48
45
|
|
49
46
|
should "be accessible at Rack::Less class level" do
|
50
|
-
assert_respond_to Rack::Less
|
51
|
-
assert_respond_to Rack::Less
|
52
|
-
assert_respond_to Rack::Less
|
53
|
-
assert_respond_to Rack::Less
|
54
|
-
assert_respond_to Rack::Less
|
55
|
-
assert_respond_to Rack::Less
|
56
|
-
end
|
57
|
-
|
58
|
-
context "given a new configuration" do
|
59
|
-
setup do
|
60
|
-
@old_config = Rack::Less.config
|
61
|
-
@settings = {
|
62
|
-
:cache => true,
|
63
|
-
:compress => true,
|
64
|
-
:combinations => {
|
65
|
-
'all' => ['one', 'two']
|
66
|
-
},
|
67
|
-
:cache_bust => false
|
68
|
-
}
|
69
|
-
@traditional_config = Rack::Less::Config.new @settings
|
70
|
-
end
|
71
|
-
teardown do
|
72
|
-
Rack::Less.config = @old_config
|
73
|
-
end
|
74
|
-
|
75
|
-
should "allow Rack::Less to directly apply settings" do
|
76
|
-
Rack::Less.config = @traditional_config.dup
|
77
|
-
|
78
|
-
assert_equal @traditional_config.cache, Rack::Less.config.cache
|
79
|
-
assert_equal @traditional_config.compress, Rack::Less.config.compress
|
80
|
-
assert_equal @traditional_config.combinations, Rack::Less.config.combinations
|
81
|
-
assert_equal @traditional_config.cache_bust, Rack::Less.config.cache_bust
|
82
|
-
end
|
83
|
-
|
84
|
-
should "allow Rack::Less to apply settings using a block" do
|
85
|
-
Rack::Less.configure do |config|
|
86
|
-
config.cache = true
|
87
|
-
config.compress = true
|
88
|
-
config.combinations = {
|
89
|
-
'all' => ['one', 'two']
|
90
|
-
}
|
91
|
-
config.cache_bust = false
|
92
|
-
end
|
93
|
-
|
94
|
-
assert_equal @traditional_config.cache, Rack::Less.config.cache
|
95
|
-
assert_equal @traditional_config.compress, Rack::Less.config.compress
|
96
|
-
assert_equal @traditional_config.combinations, Rack::Less.config.combinations
|
97
|
-
assert_equal @traditional_config.cache_bust, Rack::Less.config.cache_bust
|
98
|
-
end
|
99
|
-
|
100
|
-
context "helpers" do
|
101
|
-
setup do
|
102
|
-
@settings = {
|
103
|
-
:combinations => {
|
104
|
-
'all' => ['one', 'two']
|
105
|
-
},
|
106
|
-
:cache_bust => false
|
107
|
-
}
|
108
|
-
end
|
109
|
-
|
110
|
-
context "#combinations" do
|
111
|
-
should "should be able to access it's values with a parameter" do
|
112
|
-
config = Rack::Less::Config.new @settings
|
113
|
-
|
114
|
-
assert_equal [], config.combinations('one')
|
115
|
-
assert_equal [], config.combinations('wtf')
|
116
|
-
assert_equal ['one.css', 'two.css'], config.combinations('all')
|
117
|
-
end
|
47
|
+
assert_respond_to :configure, Rack::Less
|
48
|
+
assert_respond_to :config, Rack::Less
|
49
|
+
assert_respond_to :config=, Rack::Less
|
50
|
+
assert_respond_to :combinations, Rack::Less
|
51
|
+
assert_respond_to :cache_bust, Rack::Less
|
52
|
+
assert_respond_to :stylesheet, Rack::Less
|
53
|
+
end
|
118
54
|
|
119
|
-
|
120
|
-
setup do
|
121
|
-
@settings[:cache] = true
|
122
|
-
end
|
55
|
+
end
|
123
56
|
|
124
|
-
|
125
|
-
|
57
|
+
class NewConfigTests < Assert::Context
|
58
|
+
desc "a new configuration"
|
59
|
+
setup do
|
60
|
+
@old_config = Rack::Less.config
|
61
|
+
@settings = {
|
62
|
+
:cache => true,
|
63
|
+
:compress => true,
|
64
|
+
:combinations => { 'all' => ['one', 'two'] },
|
65
|
+
:cache_bust => false
|
66
|
+
}
|
67
|
+
@traditional_config = Config.new @settings
|
68
|
+
end
|
69
|
+
teardown do
|
70
|
+
Rack::Less.config = @old_config
|
71
|
+
end
|
126
72
|
|
127
|
-
|
128
|
-
|
129
|
-
end
|
73
|
+
should "allow Rack::Less to directly apply settings" do
|
74
|
+
Rack::Less.config = @traditional_config.dup
|
130
75
|
|
131
|
-
|
76
|
+
assert_equal @traditional_config.cache, Rack::Less.config.cache
|
77
|
+
assert_equal @traditional_config.compress, Rack::Less.config.compress
|
78
|
+
assert_equal @traditional_config.combinations, Rack::Less.config.combinations
|
79
|
+
assert_equal @traditional_config.cache_bust, Rack::Less.config.cache_bust
|
80
|
+
end
|
132
81
|
|
133
|
-
|
134
|
-
|
135
|
-
|
82
|
+
should "allow Rack::Less to apply settings using a block" do
|
83
|
+
Rack::Less.configure do |config|
|
84
|
+
config.cache = true
|
85
|
+
config.compress = true
|
86
|
+
config.combinations = { 'all' => ['one', 'two'] }
|
87
|
+
config.cache_bust = false
|
88
|
+
end
|
136
89
|
|
137
|
-
|
138
|
-
|
139
|
-
|
90
|
+
assert_equal @traditional_config.cache, Rack::Less.config.cache
|
91
|
+
assert_equal @traditional_config.compress, Rack::Less.config.compress
|
92
|
+
assert_equal @traditional_config.combinations, Rack::Less.config.combinations
|
93
|
+
assert_equal @traditional_config.cache_bust, Rack::Less.config.cache_bust
|
94
|
+
end
|
140
95
|
|
141
|
-
|
142
|
-
config = Rack::Less::Config.new @settings
|
96
|
+
end
|
143
97
|
|
144
|
-
|
145
|
-
|
98
|
+
class ConfigCombinationStylesheetTests < ConfigTests
|
99
|
+
desc "a rack less config"
|
100
|
+
setup do
|
101
|
+
@settings = {
|
102
|
+
:combinations => { 'all' => ['one', 'two'] },
|
103
|
+
:cache_bust => false
|
104
|
+
}
|
105
|
+
@config = Rack::Less::Config.new @settings
|
106
|
+
end
|
146
107
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
108
|
+
should "access #combinations by name" do
|
109
|
+
assert_equal [], @config.combinations('one')
|
110
|
+
assert_equal [], @config.combinations('wtf')
|
111
|
+
assert_equal ['one.css', 'two.css'], @config.combinations('all')
|
112
|
+
end
|
151
113
|
|
152
|
-
|
153
|
-
|
114
|
+
should "generate #stylesheet references by name" do
|
115
|
+
assert_equal 'one.css', @config.stylesheet('one')
|
116
|
+
assert_equal 'wtf.css', @config.stylesheet('wtf')
|
117
|
+
assert_equal ['one.css', 'two.css'], @config.stylesheet('all')
|
118
|
+
end
|
154
119
|
|
155
|
-
|
156
|
-
assert_equal 'all.css', config.stylesheet('all')
|
157
|
-
end
|
158
|
-
end
|
120
|
+
end
|
159
121
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
122
|
+
class CachedConfigComboStylesheetTests < ConfigCombinationStylesheetTests
|
123
|
+
desc "when cache setting is true"
|
124
|
+
setup do
|
125
|
+
@settings[:cache] = true
|
126
|
+
@config = Rack::Less::Config.new @settings
|
127
|
+
end
|
164
128
|
|
165
|
-
|
166
|
-
|
129
|
+
should "use the lookup combos and stylesheets by the cache name" do
|
130
|
+
assert_equal 'all.css', @config.combinations('all')
|
167
131
|
|
168
|
-
|
169
|
-
|
170
|
-
|
132
|
+
assert_equal 'one.css', @config.stylesheet('one')
|
133
|
+
assert_equal 'all.css', @config.stylesheet('all')
|
134
|
+
end
|
171
135
|
|
172
|
-
|
173
|
-
setup do
|
174
|
-
@settings[:cache_bust] = nil
|
175
|
-
end
|
136
|
+
end
|
176
137
|
|
177
|
-
|
178
|
-
config = Rack::Less::Config.new @settings
|
138
|
+
class ConfigCacheBustTests < ConfigCombinationStylesheetTests
|
179
139
|
|
180
|
-
|
181
|
-
|
182
|
-
|
140
|
+
should "should not put in a cache bust value when cache_bust is false" do
|
141
|
+
@settings[:cache_bust] = false
|
142
|
+
config = Rack::Less::Config.new @settings
|
183
143
|
|
184
|
-
|
185
|
-
|
186
|
-
@settings[:cache_bust] = true
|
187
|
-
end
|
144
|
+
assert_equal 'one.css', config.stylesheet('one')
|
145
|
+
end
|
188
146
|
|
189
|
-
|
190
|
-
|
147
|
+
should "should not put in a cache bust value when cache_bust is nil" do
|
148
|
+
@settings[:cache_bust] = nil
|
149
|
+
config = Rack::Less::Config.new @settings
|
191
150
|
|
192
|
-
|
193
|
-
|
194
|
-
end
|
151
|
+
assert_equal 'one.css', config.stylesheet('one')
|
152
|
+
end
|
195
153
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
@settings[:cache_bust] = @stamp
|
200
|
-
end
|
154
|
+
should "always put a timestamp value on the end of the href when cache_bust is true" do
|
155
|
+
@settings[:cache_bust] = true
|
156
|
+
config = Rack::Less::Config.new @settings
|
201
157
|
|
202
|
-
|
203
|
-
|
158
|
+
assert_match /one.css\?[0-9]+/, config.stylesheet('one')
|
159
|
+
end
|
204
160
|
|
205
|
-
|
206
|
-
end
|
161
|
+
end
|
207
162
|
|
208
|
-
|
209
|
-
|
163
|
+
class ConfigTimeStampTests < ConfigCombinationStylesheetTests
|
164
|
+
desc "when timestamp specified"
|
165
|
+
setup do
|
166
|
+
@stamp = Time.now.to_i - 100_000
|
167
|
+
@settings[:cache_bust] = @stamp
|
168
|
+
@config = Rack::Less::Config.new @settings
|
169
|
+
end
|
210
170
|
|
211
|
-
|
171
|
+
should "always use that timestamp" do
|
172
|
+
assert_equal ["one.css?#{@stamp}", "two.css?#{@stamp}"], @config.stylesheet('all')
|
212
173
|
end
|
213
174
|
|
214
175
|
end
|
176
|
+
|
215
177
|
end
|