csso-rails 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +0 -1
- data/csso-rails.gemspec +13 -3
- data/lib/csso/compressor.rb +6 -6
- data/lib/csso/version.rb +1 -1
- data/vendor/csso/csso.js +8 -8
- metadata +18 -31
- data/.gitignore +0 -15
- data/.rspec +0 -1
- data/.travis.yml +0 -37
- data/Appraisals +0 -37
- data/Gemfile +0 -3
- data/Rakefile +0 -59
- data/gemfiles/rails_3.2.gemfile +0 -7
- data/gemfiles/rails_4.2.gemfile +0 -7
- data/gemfiles/rails_5.0.gemfile +0 -7
- data/gemfiles/rails_5.1.gemfile +0 -7
- data/gemfiles/sprockets_2.gemfile +0 -7
- data/gemfiles/sprockets_3.gemfile +0 -7
- data/gemfiles/sprockets_4.gemfile +0 -8
- data/gemfiles/therubyracer.gemfile +0 -5
- data/spec/csso/csso_spec.rb +0 -39
- data/spec/csso/sprockets_integration_spec.rb +0 -130
- data/spec/fixtures/test.css +0 -5
- data/spec/fixtures/test2.css +0 -7
- data/spec/fixtures/test3.scss +0 -3
- data/spec/fixtures/test4.scss +0 -10
@@ -1,130 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'csso'
|
6
|
-
require 'mocha/mini_test'
|
7
|
-
|
8
|
-
# Encoding.default_external = Encoding::UTF_8
|
9
|
-
|
10
|
-
describe Csso do
|
11
|
-
|
12
|
-
subject { Csso }
|
13
|
-
let(:sprockets_env_without_csso){
|
14
|
-
begin
|
15
|
-
require 'sprockets'
|
16
|
-
rescue LoadError
|
17
|
-
skip "Skipping sprockets integration, as there's no sprockets in this env"
|
18
|
-
end
|
19
|
-
e = Sprockets::Environment.new(File.expand_path('../', File.dirname(__FILE__)))
|
20
|
-
e.append_path 'fixtures'
|
21
|
-
e.config = e.config.merge(gzip_enabled: false).freeze if e.respond_to? :config
|
22
|
-
# e.logger = Logger.new STDOUT
|
23
|
-
e
|
24
|
-
}
|
25
|
-
let(:fixtures_dir){
|
26
|
-
File.expand_path('../fixtures', File.dirname(__FILE__))
|
27
|
-
}
|
28
|
-
let(:result_dir){
|
29
|
-
d = File.expand_path('res', fixtures_dir)
|
30
|
-
FileUtils.mkdir_p(d)
|
31
|
-
d
|
32
|
-
}
|
33
|
-
let(:manifest_file){
|
34
|
-
File.expand_path('manifest.json', result_dir)
|
35
|
-
}
|
36
|
-
let(:manifest){
|
37
|
-
sprockets_env
|
38
|
-
# unless Sprockets::VERSION <= '2.99'
|
39
|
-
# Sprockets::Manifest.new(sprockets_env, result_dir, manifest_file)
|
40
|
-
# else
|
41
|
-
Sprockets::Manifest.new(sprockets_env, manifest_file)
|
42
|
-
# end
|
43
|
-
}
|
44
|
-
let(:sprockets_env){
|
45
|
-
subject.install(sprockets_env_without_csso)
|
46
|
-
sprockets_env_without_csso
|
47
|
-
}
|
48
|
-
|
49
|
-
it "installs" do
|
50
|
-
# sprockets_env.css_compressor.must_equal Csso::Compressor
|
51
|
-
|
52
|
-
manifest.environment.must_equal(sprockets_env)
|
53
|
-
manifest.clobber
|
54
|
-
res = manifest.compile('test.css')
|
55
|
-
res.size.must_equal 1
|
56
|
-
[File.expand_path('../../fixtures/test.css', __FILE__), 'test.css'].must_include res.first
|
57
|
-
File.read(manifest_file).wont_equal '{}'
|
58
|
-
sprockets_env['test.css'].source.must_equal '.class{color:red}'
|
59
|
-
manifest.clobber
|
60
|
-
end
|
61
|
-
|
62
|
-
it "compiles with sourcemap" do
|
63
|
-
manifest.clobber
|
64
|
-
begin
|
65
|
-
require 'sass'
|
66
|
-
rescue LoadError
|
67
|
-
skip 'No sass in this env, skipping'
|
68
|
-
end
|
69
|
-
manifest.compile('test2.css')
|
70
|
-
manifest.compile('test2.css.map')
|
71
|
-
json = JSON.load File.read(manifest_file)
|
72
|
-
json["assets"]["test2.css"].must_match(/\.css$/)
|
73
|
-
sprockets_env['test2.css'].source.must_equal '.class,.class .other_class{color:red}.something{color:#000}.test2{color:#00f}'
|
74
|
-
map = JSON.load(sprockets_env['test2.css.map'].source)
|
75
|
-
map["sources"].size.must_equal 4
|
76
|
-
manifest.clobber
|
77
|
-
end
|
78
|
-
|
79
|
-
it "loads into rails" do
|
80
|
-
begin
|
81
|
-
require "rails"
|
82
|
-
rescue LoadError
|
83
|
-
skip "no rails in this env"
|
84
|
-
end
|
85
|
-
require "sprockets/railtie"
|
86
|
-
require 'csso/railtie'
|
87
|
-
|
88
|
-
fd = fixtures_dir
|
89
|
-
app = Class.new(Rails::Application) do
|
90
|
-
config.eager_load = false
|
91
|
-
config.assets.enabled = true
|
92
|
-
|
93
|
-
config.paths['public'] = fd
|
94
|
-
config.assets.paths = [ fd ]
|
95
|
-
config.assets.prefix = 'res'
|
96
|
-
|
97
|
-
config.assets.precompile = ['test.css']
|
98
|
-
config.active_support.deprecation = :log
|
99
|
-
end
|
100
|
-
app.initialize!
|
101
|
-
|
102
|
-
app.config.assets.css_compressor.must_equal :csso
|
103
|
-
if Sprockets::VERSION >= '3'
|
104
|
-
app.assets.css_compressor.must_equal Csso::Compressor
|
105
|
-
end
|
106
|
-
|
107
|
-
Csso::Compressor.expects(:call).returns({data: 'foo_this_is_mock'})
|
108
|
-
|
109
|
-
require 'rake'
|
110
|
-
res_dir = "#{fd}/res"
|
111
|
-
if File.exist?(res_dir)
|
112
|
-
puts "Unclean from previous run"
|
113
|
-
FileUtils.rm_rf(res_dir)
|
114
|
-
end
|
115
|
-
if File.exist?('tmp/cache')
|
116
|
-
# we need clean cache, so rails will precompile for real
|
117
|
-
puts "Unclean cache from previous run"
|
118
|
-
FileUtils.rm_rf('tmp/cache')
|
119
|
-
end
|
120
|
-
Rails.application.load_tasks
|
121
|
-
ENV['RAILS_GROUPS'] ||= "assets"
|
122
|
-
ENV['RAILS_ENV'] ||= "test"
|
123
|
-
Rake::Task['assets:precompile'].invoke
|
124
|
-
|
125
|
-
Rails.application.assets['test.css'].source.must_equal 'foo_this_is_mock'
|
126
|
-
|
127
|
-
FileUtils.rm_r(res_dir)
|
128
|
-
FileUtils.rm_rf('tmp/cache') if File.exist?('tmp/cache')
|
129
|
-
end
|
130
|
-
end
|
data/spec/fixtures/test.css
DELETED
data/spec/fixtures/test2.css
DELETED
data/spec/fixtures/test3.scss
DELETED