Browse files

Write files as binary

  • Loading branch information...
1 parent 2f03355 commit fb4c466bed94ed721e89b262ce16f86416bed3ba @josh josh committed Jun 6, 2011
Showing with 12 additions and 1 deletion.
  1. +1 −1 lib/sprockets/static_compilation.rb
  2. +11 −0 test/test_environment.rb
View
2 lib/sprockets/static_compilation.rb
@@ -29,7 +29,7 @@ def precompile(*paths)
FileUtils.mkdir_p filename.dirname
- filename.open('w') do |f|
+ filename.open('wb') do |f|
f.write asset.to_s
end
end
View
11 test/test_environment.rb
@@ -250,6 +250,17 @@ def self.test(name, &block)
end
end
+ test "precompile static asset" do
+ filename = fixture_path("public/hello-f0ef7081e1539ac00ef5b761b4fb01b3.txt")
+ begin
+ assert !File.exist?(filename)
+ @env.precompile("hello.txt")
+ assert File.exist?(filename)
+ ensure
+ File.unlink(filename) if File.exist?(filename)
+ end
+ end
+
test "CoffeeScript files are compiled in a closure" do
script = @env["coffee"].to_s
assert_equal "undefined", ExecJS.exec(script)

0 comments on commit fb4c466

Please sign in to comment.