Permalink
Browse files

Added tests with actual javascript compilation.

  • Loading branch information...
1 parent 156582b commit eb313120caa8c91c13ef936d474e4b49b1db4b9f @dblock dblock committed Aug 18, 2011
Showing with 43 additions and 1 deletion.
  1. +3 −1 .gitignore
  2. +3 −0 spec/assets/alert.coffee
  3. +37 −0 spec/barista_spec.rb
View
4 .gitignore
@@ -20,4 +20,6 @@ pkg
## PROJECT::SPECIFIC
-.rvmrc
+.rvmrc
+public
+
View
3 spec/assets/alert.coffee
@@ -0,0 +1,3 @@
+hello ->
+ alert 'hello world'
+
View
37 spec/barista_spec.rb
@@ -18,13 +18,50 @@
Barista::app_root.to_s.should == new_path
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 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
lambda { Barista::compile_all! false, false }.should_not raise_error
end
+ it "produces alert.js" do
+ Barista::compile_all!
+ File.exist?(File.join(@public_path, "alert.js")).should be_true
+ end
end
end

0 comments on commit eb31312

Please sign in to comment.