Skip to content

Commit

Permalink
Added tests with actual javascript compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Aug 18, 2011
1 parent 156582b commit eb31312
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -20,4 +20,6 @@ pkg


## PROJECT::SPECIFIC ## PROJECT::SPECIFIC


.rvmrc .rvmrc
public

3 changes: 3 additions & 0 deletions spec/assets/alert.coffee
@@ -0,0 +1,3 @@
hello ->
alert 'hello world'

37 changes: 37 additions & 0 deletions spec/barista_spec.rb
Expand Up @@ -18,13 +18,50 @@
Barista::app_root.to_s.should == new_path Barista::app_root.to_s.should == new_path
end end
end end

context 'preamble' do
before(:each) do
@assets_path = File.expand_path("../assets", __FILE__)
@public_path = File.expand_path("../public", __FILE__)
Barista.configure do |c|
c.root = @assets_path
c.output_root = @public_path
end
FileUtils.rm_rf @public_path if Dir.exist?(@public_path)
end
it "is written by default" do
Barista.add_preamble = true
Barista::compile_all!
alert_js = IO.read(File.join(@public_path, "alert.js"))
alert_js.should include "DO NOT MODIFY"
end
it "can be disabled" do
Barista.add_preamble = false
Barista::compile_all!
alert_js = IO.read(File.join(@public_path, "alert.js"))
alert_js.should_not include "DO NOT MODIFY"
end
end


context 'compiling files' context 'compiling files'


context 'compiling all' do context 'compiling all' do
before(:each) do
@assets_path = File.expand_path("../assets", __FILE__)
@public_path = File.expand_path("../public", __FILE__)
Barista.configure do |c|
c.root = @assets_path
c.output_root = @public_path
end
FileUtils.rm_rf @public_path if Dir.exist?(@public_path)
end
it "compiles nothing" do it "compiles nothing" do
lambda { Barista::compile_all! false, false }.should_not raise_error lambda { Barista::compile_all! false, false }.should_not raise_error
end end
it "produces alert.js" do
Barista::compile_all!
File.exist?(File.join(@public_path, "alert.js")).should be_true
end
end end


end end

0 comments on commit eb31312

Please sign in to comment.