contao 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/contao.gemspec +2 -8
- data/lib/contao.rb +1 -54
- data/lib/contao/application.rb +13 -23
- data/lib/contao/commands/help.rb +1 -1
- data/lib/contao/generators/base.rb +1 -3
- data/lib/contao/notifier.rb +3 -3
- data/lib/contao/railtie.rb +11 -0
- data/lib/contao/ui.rb +219 -0
- data/lib/contao/version.rb +1 -1
- data/lib/{contao/tasks → tasks}/contao.rake +18 -19
- data/lib/{contao/tasks → tasks}/whitespace.rake +0 -0
- data/spec/lib/contao/application_spec.rb +6 -8
- data/spec/lib/contao/notifier_spec.rb +15 -15
- data/spec/spec_helper.rb +6 -14
- data/spec/support/filesystem_mock.rb +40 -11
- data/spec/support/stub_rails.rb +29 -0
- metadata +12 -128
- data/lib/contao/coffeescript_compiler.rb +0 -58
- data/lib/contao/compiler.rb +0 -128
- data/lib/contao/javascript_compiler.rb +0 -77
- data/lib/contao/stylesheet_compiler.rb +0 -56
- data/lib/contao/tasks/assets.rake +0 -22
- data/lib/contao/tasks/jasmine.rake +0 -8
- data/lib/guard/assets.rb +0 -117
- data/lib/monkey_patches.rb +0 -1
- data/lib/monkey_patches/compass/urls.rb +0 -81
- data/spec/lib/contao/coffeescript_compiler_spec.rb +0 -85
- data/spec/lib/contao/javascript_compiler_spec.rb +0 -91
- data/spec/lib/contao/stylesheet_compiler_spec.rb +0 -117
- data/spec/lib/contao_spec.rb +0 -62
- data/spec/lib/guard/assets_spec.rb +0 -220
- data/spec/support/compiler_shared_examples.rb +0 -292
- data/spec/support/config_shared_examples.rb +0 -29
data/lib/monkey_patches.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'monkey_patches/compass/urls'
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'compass'
|
2
|
-
|
3
|
-
module Compass::SassExtensions::Functions::Urls
|
4
|
-
module ImageUrl
|
5
|
-
def image_url(path, only_path = Sass::Script::Bool.new(false), cache_buster = Sass::Script::Bool.new(true))
|
6
|
-
path = path.value # get to the string value of the literal.
|
7
|
-
|
8
|
-
if path =~ %r{^#{Regexp.escape(Compass.configuration.http_images_path)}/(.*)}
|
9
|
-
# Treat root relative urls (without a protocol) like normal if they start with
|
10
|
-
# the images path.
|
11
|
-
path = $1
|
12
|
-
elsif absolute_path?(path)
|
13
|
-
# Short curcuit if they have provided an absolute url.
|
14
|
-
return Sass::Script::String.new("url(#{path})")
|
15
|
-
end
|
16
|
-
|
17
|
-
# Compute the path to the image, either root relative or stylesheet relative
|
18
|
-
# or nil if the http_images_path is not set in the configuration.
|
19
|
-
http_images_path = if relative?
|
20
|
-
compute_relative_path(Compass.configuration.images_path)
|
21
|
-
elsif Compass.configuration.http_images_path
|
22
|
-
Compass.configuration.http_images_path
|
23
|
-
else
|
24
|
-
Compass.configuration.http_root_relative(Compass.configuration.images_dir)
|
25
|
-
end
|
26
|
-
|
27
|
-
# Compute the real path to the image on the file stystem if the images_dir is set.
|
28
|
-
real_path = if Compass.configuration.images_dir
|
29
|
-
File.join(Compass.configuration.project_path, Compass.configuration.images_dir, path)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Generate the digested image (if production)
|
33
|
-
if ::TechnoGate::Contao.env == :production
|
34
|
-
digested_path = ::TechnoGate::Contao::Compiler.new.send(:create_digest_for_file, real_path)
|
35
|
-
real_path = File.join(Compass.configuration.project_path, Compass.configuration.css_dir, File.dirname(path), File.basename(digested_path))
|
36
|
-
FileUtils.mkdir_p File.dirname(real_path)
|
37
|
-
FileUtils.mv digested_path, real_path
|
38
|
-
else
|
39
|
-
non_digested_path = File.join(Compass.configuration.project_path, Compass.configuration.css_dir, path)
|
40
|
-
FileUtils.mkdir_p File.dirname(non_digested_path)
|
41
|
-
FileUtils.cp real_path, non_digested_path
|
42
|
-
|
43
|
-
real_path = non_digested_path
|
44
|
-
end
|
45
|
-
|
46
|
-
# prepend the path to the image if there's one
|
47
|
-
if http_images_path
|
48
|
-
http_images_path = "#{http_images_path}/" unless http_images_path[-1..-1] == "/"
|
49
|
-
path = "#{http_images_path}#{path}"
|
50
|
-
end
|
51
|
-
|
52
|
-
# Generate the digested image (if production)
|
53
|
-
if ::TechnoGate::Contao.env == :production
|
54
|
-
path = path.gsub(File.basename(path), File.basename(digested_path))
|
55
|
-
end
|
56
|
-
|
57
|
-
# Compute the asset host unless in relative mode.
|
58
|
-
asset_host = if !relative? && Compass.configuration.asset_host
|
59
|
-
Compass.configuration.asset_host.call(path)
|
60
|
-
end
|
61
|
-
|
62
|
-
# Compute and append the cache buster if there is one.
|
63
|
-
if cache_buster.to_bool
|
64
|
-
if cache_buster.is_a?(Sass::Script::String)
|
65
|
-
path += "?#{cache_buster.value}"
|
66
|
-
else
|
67
|
-
path = cache_busted_path(path, real_path)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# prepend the asset host if there is one.
|
72
|
-
path = "#{asset_host}#{'/' unless path[0..0] == "/"}#{path}" if asset_host
|
73
|
-
|
74
|
-
if only_path.to_bool
|
75
|
-
Sass::Script::String.new(clean_path(path))
|
76
|
-
else
|
77
|
-
clean_url(path)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CoffeeScript
|
4
|
-
def self.compile(contents, *args)
|
5
|
-
contents
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
module TechnoGate
|
10
|
-
module Contao
|
11
|
-
describe CoffeescriptCompiler do
|
12
|
-
it_should_behave_like "Compiler"
|
13
|
-
|
14
|
-
describe '#compile_assets', :fakefs do
|
15
|
-
before :each do
|
16
|
-
stub_filesystem!
|
17
|
-
|
18
|
-
[
|
19
|
-
'/root/my_awesome_project/app/assets/javascripts/simple_coffeescript_file.js.coffee',
|
20
|
-
'/root/my_awesome_project/app/assets/javascripts/simple_javascript_file.js',
|
21
|
-
'/root/my_awesome_project/app/assets/javascripts/nested/script.js.coffee',
|
22
|
-
'/root/my_awesome_project/lib/assets/javascripts/simple_coffeescript_file.js.coffee',
|
23
|
-
'/root/my_awesome_project/vendor/assets/javascripts/simple_coffeescript_file.js.coffee',
|
24
|
-
].each do |file|
|
25
|
-
FileUtils.mkdir_p File.dirname(file)
|
26
|
-
File.open(file, 'w') { |f| f.write "Asset File" }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should compile coffeescripts" do
|
31
|
-
subject.send :compile_assets
|
32
|
-
|
33
|
-
File.exists?('/root/my_awesome_project/tmp/compiled_javascript/app_assets_javascripts/simple_coffeescript_file.js').should be_true
|
34
|
-
File.exists?('/root/my_awesome_project/tmp/compiled_javascript/lib_assets_javascripts/simple_coffeescript_file.js').should be_true
|
35
|
-
File.exists?('/root/my_awesome_project/tmp/compiled_javascript/vendor_assets_javascripts/simple_coffeescript_file.js').should be_true
|
36
|
-
File.exists?('/root/my_awesome_project/tmp/compiled_javascript/app_assets_javascripts/simple_javascript_file').should be_false
|
37
|
-
File.exists?('/root/my_awesome_project/tmp/compiled_javascript/app_assets_javascripts/nested/script.js').should be_true
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should compile given a different output path" do
|
41
|
-
subject.should_receive(:output_from_options).at_least(:once).and_return('/root/wat')
|
42
|
-
|
43
|
-
subject.send :compile_assets
|
44
|
-
|
45
|
-
File.exists?('/root/wat/app_assets_javascripts/simple_coffeescript_file.js').should be_true
|
46
|
-
File.exists?('/root/wat/lib_assets_javascripts/simple_coffeescript_file.js').should be_true
|
47
|
-
File.exists?('/root/wat/vendor_assets_javascripts/simple_coffeescript_file.js').should be_true
|
48
|
-
File.exists?('/root/wat/app_assets_javascripts/simple_javascript_file').should be_false
|
49
|
-
File.exists?('/root/wat/app_assets_javascripts/nested/script.js').should be_true
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#compute_destination_filename" do
|
54
|
-
it "should be able to compute given a relative file" do
|
55
|
-
subject.send(:compute_destination_filename, "app/js", "app/js/file.js.coffee").should ==
|
56
|
-
"/root/my_awesome_project/tmp/compiled_javascript/app_js/file.js"
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should be able to compute given an absolute file" do
|
60
|
-
subject.send(:compute_destination_filename, "app/js", "/root/my_awesome_project/app/js/file.js.coffee").should ==
|
61
|
-
"/root/my_awesome_project/tmp/compiled_javascript/app_js/file.js"
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should add automaticallty .js extension" do
|
65
|
-
subject.send(:compute_destination_filename, "app/js", "app/js/file.coffee").should ==
|
66
|
-
"/root/my_awesome_project/tmp/compiled_javascript/app_js/file.js"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "#clean", :fakefs do
|
71
|
-
before :each do
|
72
|
-
stub_filesystem!
|
73
|
-
|
74
|
-
FileUtils.mkdir_p '/root/my_awesome_project/tmp/compiled_javascript'
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should remove the temporary javascript compiled files" do
|
78
|
-
subject.clean
|
79
|
-
|
80
|
-
File.exists?('/root/my_awesome_project/tmp/compiled_javascript').should be_false
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module TechnoGate
|
4
|
-
module Contao
|
5
|
-
describe JavascriptCompiler do
|
6
|
-
it_should_behave_like "Compiler"
|
7
|
-
|
8
|
-
describe "#compile_assets", :fakefs do
|
9
|
-
before :each do
|
10
|
-
Uglifier.any_instance.stub(:compile)
|
11
|
-
|
12
|
-
stub_filesystem!
|
13
|
-
|
14
|
-
@file_path = "/root/my_awesome_project/app/assets/javascripts/file.js"
|
15
|
-
@app_js_path = "/root/my_awesome_project/public/resources/application.js"
|
16
|
-
|
17
|
-
File.open(@file_path, 'w') do |file|
|
18
|
-
file.write("not compiled js")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should compile javascripts into #{@app_js_path}" do
|
23
|
-
subject.send :compile_assets
|
24
|
-
File.exists?(@app_js_path).should be_true
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should add the contents of file.js to app.js un-minified if env is development" do
|
28
|
-
subject.send :compile_assets
|
29
|
-
File.read(@app_js_path).should ==
|
30
|
-
"// #{@file_path}\n#{File.read(@file_path)}\n"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should add the contents of file.js to app.js minified if env is production" do
|
34
|
-
TechnoGate::Contao.env = :production
|
35
|
-
Uglifier.any_instance.should_receive(:compile).once.and_return("compiled js")
|
36
|
-
|
37
|
-
subject.send :compile_assets
|
38
|
-
File.read(@app_js_path).should == "compiled js"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "#javascripts_path" do
|
43
|
-
it "should return the configured path as well as the temporary javascript path" do
|
44
|
-
subject.send(:javascripts_path).should ==
|
45
|
-
[
|
46
|
-
'tmp/compiled_javascript/vendor_assets_javascripts',
|
47
|
-
'vendor/assets/javascripts',
|
48
|
-
'tmp/compiled_javascript/lib_assets_javascripts',
|
49
|
-
'lib/assets/javascripts',
|
50
|
-
'tmp/compiled_javascript/app_assets_javascripts',
|
51
|
-
'app/assets/javascripts',
|
52
|
-
]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "#create_hashed_assets", :fakefs do
|
57
|
-
before :each do
|
58
|
-
stub_filesystem!
|
59
|
-
|
60
|
-
@app_js_path = "/root/my_awesome_project/public/resources/application.js"
|
61
|
-
|
62
|
-
File.open(@app_js_path, 'w') do |file|
|
63
|
-
file.write('compiled js')
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should call :create_digest_for_file" do
|
68
|
-
subject.should_receive(:create_digest_for_file).with(Pathname.new(@app_js_path)).once
|
69
|
-
|
70
|
-
subject.send :create_hashed_assets
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "#generate_manifest" do
|
75
|
-
it "should call generate_manifest_for" do
|
76
|
-
subject.should_receive(:generate_manifest_for).with("javascripts", "js").once
|
77
|
-
|
78
|
-
subject.send :generate_manifest
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "#notify" do
|
83
|
-
it "should call Notifier.notify with the appropriate message" do
|
84
|
-
Notifier.should_receive(:notify).with("Javascript compiler finished successfully.", title: "JavascriptCompiler").once
|
85
|
-
|
86
|
-
subject.send :notify
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,117 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module TechnoGate
|
4
|
-
module Contao
|
5
|
-
describe StylesheetCompiler do
|
6
|
-
it_should_behave_like "Compiler"
|
7
|
-
|
8
|
-
describe "#compile_assets" do
|
9
|
-
before :each do
|
10
|
-
@updater = mock('updater')
|
11
|
-
@updater.stub(:execute)
|
12
|
-
|
13
|
-
Compass::Commands::UpdateProject.stub(:new).with(
|
14
|
-
Contao.root,
|
15
|
-
configuration_file: Contao.root.join('config', 'compass.rb')
|
16
|
-
).and_return(@updater)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should create a new updater" do
|
20
|
-
Compass::Commands::UpdateProject.should_receive(:new).with(
|
21
|
-
Contao.root,
|
22
|
-
configuration_file: Contao.root.join('config', 'compass.rb')
|
23
|
-
).once.and_return(@updater)
|
24
|
-
|
25
|
-
subject.send :compile_assets
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should cache the updater" do
|
29
|
-
Compass::Commands::UpdateProject.should_receive(:new).with(
|
30
|
-
Contao.root,
|
31
|
-
configuration_file: Contao.root.join('config', 'compass.rb')
|
32
|
-
).once.and_return(@updater)
|
33
|
-
|
34
|
-
subject.send :compile_assets
|
35
|
-
subject.send :compile_assets
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should call execute on the updater" do
|
39
|
-
@updater.should_receive(:execute).once
|
40
|
-
|
41
|
-
subject.send :compile_assets
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#generate_manifest" do
|
46
|
-
it "should call generate_manifest_for" do
|
47
|
-
subject.should_receive(:generate_manifest_for).with("stylesheets", "css").once
|
48
|
-
|
49
|
-
subject.send :generate_manifest
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#clean assets" do
|
54
|
-
before :each do
|
55
|
-
@cleaner = mock('cleaner')
|
56
|
-
@cleaner.stub(:execute)
|
57
|
-
|
58
|
-
Compass::Commands::CleanProject.stub(:new).with(
|
59
|
-
Contao.root,
|
60
|
-
configuration_file: Contao.root.join('config', 'compass.rb')
|
61
|
-
).and_return(@cleaner)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should create a new cleaner" do
|
65
|
-
Compass::Commands::CleanProject.should_receive(:new).with(
|
66
|
-
Contao.root,
|
67
|
-
configuration_file: Contao.root.join('config', 'compass.rb')
|
68
|
-
).once.and_return(@cleaner)
|
69
|
-
|
70
|
-
subject.clean
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should cache the cleaner" do
|
74
|
-
Compass::Commands::CleanProject.should_receive(:new).with(
|
75
|
-
Contao.root,
|
76
|
-
configuration_file: Contao.root.join('config', 'compass.rb')
|
77
|
-
).once.and_return(@cleaner)
|
78
|
-
|
79
|
-
subject.clean
|
80
|
-
subject.clean
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should call execute on the cleaner" do
|
84
|
-
@cleaner.should_receive(:execute).once
|
85
|
-
|
86
|
-
subject.send :clean
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe 'create_hashed_assets', :fakefs do
|
91
|
-
before :each do
|
92
|
-
stub_filesystem!
|
93
|
-
|
94
|
-
@app_css_path = "/root/my_awesome_project/public/resources/application.css"
|
95
|
-
|
96
|
-
File.open(@app_css_path, 'w') do |file|
|
97
|
-
file.write('compiled css')
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should call :create_digest_for_file" do
|
102
|
-
subject.should_receive(:create_digest_for_file).with(Pathname.new(@app_css_path)).once
|
103
|
-
|
104
|
-
subject.send :create_hashed_assets
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "#notify" do
|
109
|
-
it "should call Notifier.notify with the appropriate message" do
|
110
|
-
Notifier.should_receive(:notify).with("Stylesheet compiler finished successfully.", title: "StylesheetCompiler").once
|
111
|
-
|
112
|
-
subject.send :notify
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
data/spec/lib/contao_spec.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module TechnoGate
|
4
|
-
describe Contao do
|
5
|
-
describe "#env" do
|
6
|
-
it {should respond_to :env}
|
7
|
-
it {should respond_to :env=}
|
8
|
-
|
9
|
-
it "should return @@env" do
|
10
|
-
mock("env").tap do |env|
|
11
|
-
subject.class_variable_set(:@@env, env)
|
12
|
-
subject.env.should == env
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should set the @@env" do
|
17
|
-
mock("env").tap do |env|
|
18
|
-
subject.env = env
|
19
|
-
subject.class_variable_get(:@@env).should == env
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#root' do
|
25
|
-
it {should respond_to :root}
|
26
|
-
it {should respond_to :root=}
|
27
|
-
|
28
|
-
it "should return @@root" do
|
29
|
-
mock("root").tap do |root|
|
30
|
-
subject.class_variable_set(:@@root, root)
|
31
|
-
subject.root.should == root
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should set the @@root" do
|
36
|
-
subject.root = '~/Desktop'
|
37
|
-
subject.class_variable_get(:@@root).should == Pathname.new('~/Desktop').expand_path
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#expandify' do
|
42
|
-
before :each do
|
43
|
-
subject.root = '/root/my_awesome_project'
|
44
|
-
end
|
45
|
-
|
46
|
-
it {should respond_to :expandify}
|
47
|
-
|
48
|
-
it "should expand the path if it's relative" do
|
49
|
-
subject.expandify('app').to_s.should == '/root/my_awesome_project/app'
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should not expand an expanded path" do
|
53
|
-
subject.expandify('/test').to_s.should == '/test'
|
54
|
-
end
|
55
|
-
|
56
|
-
it "always return a Pathname" do
|
57
|
-
subject.expandify('app').should be_instance_of Pathname
|
58
|
-
subject.expandify('/app').should be_instance_of Pathname
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,220 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Guard
|
4
|
-
describe Assets do
|
5
|
-
before :each do
|
6
|
-
@stylesheet_compiler = mock('stylesheet_compiler', clean: true, compile: true)
|
7
|
-
@coffeescript_compiler = mock('coffeescript_compiler', clean: true, compile: true)
|
8
|
-
@javascript_compiler = mock('javascript_compiler', clean: true, compile: true)
|
9
|
-
@compilers =
|
10
|
-
[@stylesheet_compiler, @coffeescript_compiler, @javascript_compiler]
|
11
|
-
|
12
|
-
subject.instance_variable_set :@stylesheet_compiler, @stylesheet_compiler
|
13
|
-
subject.instance_variable_set :@coffeescript_compiler, @coffeescript_compiler
|
14
|
-
subject.instance_variable_set :@javascript_compiler, @javascript_compiler
|
15
|
-
subject.instance_variable_set :@compilers, @compilers
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should inherit from Guard" do
|
19
|
-
subject.class.superclass.should == ::Guard::Guard
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#init' do
|
23
|
-
before :each do
|
24
|
-
@assets = Assets.new
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should create @coffeescript_compiler" do
|
28
|
-
@assets.instance_variable_get(:@coffeescript_compiler).
|
29
|
-
should be_instance_of TechnoGate::Contao::CoffeescriptCompiler
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should create @javascript_compiler" do
|
33
|
-
@assets.instance_variable_get(:@javascript_compiler).
|
34
|
-
should be_instance_of TechnoGate::Contao::JavascriptCompiler
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should create @stylesheet_compiler" do
|
38
|
-
@assets.instance_variable_get(:@stylesheet_compiler).
|
39
|
-
should be_instance_of TechnoGate::Contao::StylesheetCompiler
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should create @compilers with a specific order with compilers specified" do
|
43
|
-
@assets = Assets.new([], compilers: [:javascript, :coffeescript, :stylesheet])
|
44
|
-
@assets.instance_variable_get(:@compilers).size.should == 3
|
45
|
-
@assets.instance_variable_get(:@compilers).should == [
|
46
|
-
@assets.instance_variable_get(:@stylesheet_compiler),
|
47
|
-
@assets.instance_variable_get(:@coffeescript_compiler),
|
48
|
-
@assets.instance_variable_get(:@javascript_compiler),
|
49
|
-
]
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should create @compilers with a specific order" do
|
53
|
-
subject.instance_variable_get(:@compilers).size.should == 3
|
54
|
-
subject.instance_variable_get(:@compilers).should == [
|
55
|
-
subject.instance_variable_get(:@stylesheet_compiler),
|
56
|
-
subject.instance_variable_get(:@coffeescript_compiler),
|
57
|
-
subject.instance_variable_get(:@javascript_compiler),
|
58
|
-
]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "#start" do
|
63
|
-
before :each do
|
64
|
-
subject.stub(:run_all)
|
65
|
-
end
|
66
|
-
|
67
|
-
it {should respond_to :start}
|
68
|
-
|
69
|
-
it "should call :run_all" do
|
70
|
-
subject.should_receive(:run_all).once
|
71
|
-
|
72
|
-
subject.start
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe '#run_all' do
|
77
|
-
it {should respond_to :run_all}
|
78
|
-
|
79
|
-
it "Should clean assets" do
|
80
|
-
@stylesheet_compiler.should_receive(:clean).once.ordered
|
81
|
-
@coffeescript_compiler.should_receive(:clean).once.ordered
|
82
|
-
@javascript_compiler.should_receive(:clean).once.ordered
|
83
|
-
|
84
|
-
subject.run_all
|
85
|
-
end
|
86
|
-
|
87
|
-
it "Should recompile assets" do
|
88
|
-
@stylesheet_compiler.should_receive(:compile).once.ordered
|
89
|
-
@coffeescript_compiler.should_receive(:compile).once.ordered
|
90
|
-
@javascript_compiler.should_receive(:compile).once.ordered
|
91
|
-
|
92
|
-
subject.run_all
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe '#run_on_changes' do
|
97
|
-
before :each do
|
98
|
-
@paths = mock('paths').as_null_object
|
99
|
-
end
|
100
|
-
|
101
|
-
it {should respond_to :run_on_changes}
|
102
|
-
|
103
|
-
it "should call #compile" do
|
104
|
-
subject.should_receive(:compile).with(@paths).once
|
105
|
-
|
106
|
-
subject.send(:run_on_changes, @paths)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe '#run_on_removals' do
|
111
|
-
before :each do
|
112
|
-
@paths = mock('paths').as_null_object
|
113
|
-
end
|
114
|
-
|
115
|
-
it {should respond_to :run_on_removals}
|
116
|
-
|
117
|
-
it "should call #compile" do
|
118
|
-
subject.should_receive(:compile).with(@paths).once
|
119
|
-
|
120
|
-
subject.send(:run_on_removals, @paths)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe '#compile' do
|
125
|
-
it "should call compile_stylesheet only if some stylesheet paths has changed" do
|
126
|
-
@stylesheet_compiler.should_receive(:compile).once
|
127
|
-
|
128
|
-
subject.send :compile, ["app/assets/stylesheets/file.css"]
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should call compile_coffeescript only if some coffeescript paths has changed" do
|
132
|
-
@coffeescript_compiler.should_receive(:compile).once
|
133
|
-
|
134
|
-
subject.send :compile, ["app/assets/javascripts/file.js.coffee"]
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should call compile_javascript only if some javascript paths has changed" do
|
138
|
-
@javascript_compiler.should_receive(:compile).once
|
139
|
-
|
140
|
-
subject.send :compile, ["app/assets/javascripts/file.js"]
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should compile stylesheets only once" do
|
144
|
-
@stylesheet_compiler.should_receive(:compile).once
|
145
|
-
|
146
|
-
subject.send :compile, ["app/assets/stylesheets/file.css", "app/assets/stylesheets/file2.css"]
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should compile coffeescripts only once" do
|
150
|
-
@coffeescript_compiler.should_receive(:compile).once
|
151
|
-
|
152
|
-
subject.send :compile, ["app/assets/javascripts/file.js.coffee", "app/assets/javascripts/file2.js.coffee"]
|
153
|
-
end
|
154
|
-
|
155
|
-
it "should compile javascripts only once" do
|
156
|
-
@javascript_compiler.should_receive(:compile).once
|
157
|
-
|
158
|
-
subject.send :compile, ["app/assets/javascripts/file.js", "app/assets/javascripts/file2.js"]
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should compile javascript if coffeescript was used" do
|
162
|
-
@coffeescript_compiler.should_receive(:compile).once
|
163
|
-
@javascript_compiler.should_receive(:compile).once
|
164
|
-
|
165
|
-
subject.send :compile, ["app/assets/javascripts/file.js.coffee"]
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should not try to compile javascript if compiler not available even if path is a js" do
|
169
|
-
@compilers = [@stylesheet_compiler, @coffeescript_compiler]
|
170
|
-
subject.instance_variable_set :@compilers, @compilers
|
171
|
-
@javascript_compiler.should_not_receive(:compile)
|
172
|
-
|
173
|
-
subject.send :compile, ["app/assets/javascripts/file.js"]
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
describe "#file_in_path?" do
|
178
|
-
it "should return true" do
|
179
|
-
subject.send(:file_in_path?, "app/file.js", "app").should be_true
|
180
|
-
subject.send(:file_in_path?, "app/file.js", ["app"]).should be_true
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should return false" do
|
184
|
-
subject.send(:file_in_path?, "app/file.js", "lib").should_not be_true
|
185
|
-
subject.send(:file_in_path?, "app/file.js", ["lib"]).should_not be_true
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
describe "#is_stylesheet?" do
|
190
|
-
it "should return true for stylesheet file" do
|
191
|
-
subject.send(:is_stylesheet?, "app/assets/stylesheets/file.css").should be_true
|
192
|
-
end
|
193
|
-
|
194
|
-
it "should return false for non-stylesheet files" do
|
195
|
-
subject.send(:is_stylesheet?, "app/assets/javascripts/file.css").should_not be_true
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
describe "#is_coffeescript?" do
|
200
|
-
it "should return true for coffeescript file" do
|
201
|
-
subject.send(:is_coffeescript?, "app/assets/javascripts/file.js.coffee").should be_true
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should return false for non-coffeescript files" do
|
205
|
-
subject.send(:is_coffeescript?, "app/assets/stylesheets/file.css").should_not be_true
|
206
|
-
subject.send(:is_coffeescript?, "app/assets/stylesheets/file.js").should_not be_true
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
describe "#is_javascript?" do
|
211
|
-
it "should return true for javascript file" do
|
212
|
-
subject.send(:is_javascript?, "app/assets/javascripts/file.js").should be_true
|
213
|
-
end
|
214
|
-
|
215
|
-
it "should return false for non-coffeescript files" do
|
216
|
-
subject.send(:is_javascript?, "app/assets/stylesheets/file.css").should_not be_true
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|