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/gem_rake_helper.rb b/gem_rake_helper.rb index 6353f05b..f9585479 100644 --- a/gem_rake_helper.rb +++ b/gem_rake_helper.rb @@ -1,6 +1,5 @@ require 'rubygems' unless defined?(Gem) require 'rake' -require 'cucumber/rake/task' require 'yard' require 'bundler' @@ -16,7 +15,9 @@ class Bundler::GemHelper end end -Cucumber::Rake::Task.new(:test, 'Run features that should pass') do |t| +require 'cucumber/rake/task' + +Cucumber::Rake::Task.new do |t| exempt_tags = ["--tags ~@wip"] exempt_tags << "--tags ~@nojava" if RUBY_PLATFORM == "java" exempt_tags << "--tags ~@encoding" unless Object.const_defined?(:Encoding) @@ -25,6 +26,24 @@ Cucumber::Rake::Task.new(:test, 'Run features that should pass') do |t| t.cucumber_opts = "--color #{exempt_tags.join(" ")} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}" end +Cucumber::Rake::Task.new(:cucumber_wip) do |t| + exempt_tags = ["--tags @wip"] + exempt_tags << "--tags ~@nojava" if RUBY_PLATFORM == "java" + exempt_tags << "--tags ~@encoding" unless Object.const_defined?(:Encoding) + + t.cucumber_opts = "--color #{exempt_tags.join(" ")} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}" +end + +require 'rspec/core/rake_task' +desc "Run RSpec" +RSpec::Core::RakeTask.new do |spec| + spec.pattern = 'spec/**/*_spec.rb' + spec.rspec_opts = ['--color', '--format nested'] +end + +desc "Run tests, both RSpec and Cucumber" +task :test => [:spec, :cucumber] + YARD::Rake::YardocTask.new 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 @@ +明日がある。 diff --git a/middleman-core/spec/middleman-core/sitemap_spec.rb b/middleman-core/spec/middleman-core/sitemap_spec.rb new file mode 100644 index 00000000..e69de29b diff --git a/middleman-core/spec/spec_helper.rb b/middleman-core/spec/spec_helper.rb new file mode 100644 index 00000000..e69de29b diff --git a/middleman-more/spec/middleman-more/future_spec.rb b/middleman-more/spec/middleman-more/future_spec.rb new file mode 100644 index 00000000..e69de29b diff --git a/middleman-more/spec/spec_helper.rb b/middleman-more/spec/spec_helper.rb new file mode 100644 index 00000000..e69de29b diff --git a/middleman/spec/middleman/future_spec.rb b/middleman/spec/middleman/future_spec.rb new file mode 100644 index 00000000..e69de29b diff --git a/middleman/spec/spec_helper.rb b/middleman/spec/spec_helper.rb new file mode 100644 index 00000000..e69de29b