diff --git a/Rakefile b/Rakefile index 630c02ff..1801ea15 100644 --- a/Rakefile +++ b/Rakefile @@ -87,6 +87,13 @@ task :test do end end +desc "Run specs for all middleman gems" +task :spec do + GEM_PATHS.each do |g| + sh "cd #{File.join(ROOT, g)} && #{Gem.ruby} -S rake spec" + end +end + # desc "Rune cane for all middleman gems" # task :cane do # GEM_PATHS.each do |g| @@ -95,4 +102,4 @@ end # end desc "Run tests for all middleman gems" -task :default => :test \ No newline at end of file +task :default => :test diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb index 00a28e2b..0bee9661 100644 --- a/middleman-core/lib/middleman-core/util.rb +++ b/middleman-core/lib/middleman-core/util.rb @@ -10,6 +10,9 @@ require "thor" # Core Pathname library used for traversal require "pathname" +require "tilt" +require "rack/mime" + module Middleman module Util diff --git a/middleman-core/spec/middleman-core/binary_spec.rb b/middleman-core/spec/middleman-core/binary_spec.rb new file mode 100644 index 00000000..ad04efb7 --- /dev/null +++ b/middleman-core/spec/middleman-core/binary_spec.rb @@ -0,0 +1,15 @@ +require 'middleman-core/util' + +describe "Middleman::Util#binary?" do + %w(plain.txt unicode.txt unicode stars.svgz).each do |file| + it "recognizes #{file} as not binary" do + Middleman::Util.binary?(File.join(File.dirname(__FILE__), "binary_spec/#{file}")).should be_false + end + end + + %w(middleman.png middleman).each do |file| + it "recognizes #{file} as binary" do + Middleman::Util.binary?(File.join(File.dirname(__FILE__), "binary_spec/#{file}")).should be_true + end + end +end diff --git a/middleman-core/spec/middleman-core/binary_spec/middleman b/middleman-core/spec/middleman-core/binary_spec/middleman new file mode 100644 index 00000000..c685e564 Binary files /dev/null and b/middleman-core/spec/middleman-core/binary_spec/middleman differ diff --git a/middleman-core/spec/middleman-core/binary_spec/middleman.png b/middleman-core/spec/middleman-core/binary_spec/middleman.png new file mode 100644 index 00000000..c685e564 Binary files /dev/null and b/middleman-core/spec/middleman-core/binary_spec/middleman.png differ diff --git a/middleman-core/spec/middleman-core/binary_spec/plain.txt b/middleman-core/spec/middleman-core/binary_spec/plain.txt new file mode 100644 index 00000000..649adbeb --- /dev/null +++ b/middleman-core/spec/middleman-core/binary_spec/plain.txt @@ -0,0 +1 @@ +Some plain text diff --git a/middleman-core/spec/middleman-core/binary_spec/stars.svgz b/middleman-core/spec/middleman-core/binary_spec/stars.svgz new file mode 100644 index 00000000..a54ce7ff Binary files /dev/null and b/middleman-core/spec/middleman-core/binary_spec/stars.svgz differ diff --git a/middleman-core/spec/middleman-core/binary_spec/unicode b/middleman-core/spec/middleman-core/binary_spec/unicode new file mode 100644 index 00000000..13dc1361 --- /dev/null +++ b/middleman-core/spec/middleman-core/binary_spec/unicode @@ -0,0 +1 @@ +明日がある。 diff --git a/middleman-core/spec/middleman-core/binary_spec/unicode.txt b/middleman-core/spec/middleman-core/binary_spec/unicode.txt new file mode 100644 index 00000000..13dc1361 --- /dev/null +++ b/middleman-core/spec/middleman-core/binary_spec/unicode.txt @@ -0,0 +1 @@ +明日がある。