Merge pull request #772 from bhollis/binary

Add a spec for testing Middleman::Util#binary?
This commit is contained in:
Ben Hollis 2013-02-09 17:31:12 -08:00
commit f3750c7c01
16 changed files with 50 additions and 3 deletions

View file

@ -87,6 +87,13 @@ task :test do
end end
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" # desc "Rune cane for all middleman gems"
# task :cane do # task :cane do
# GEM_PATHS.each do |g| # GEM_PATHS.each do |g|

View file

@ -1,6 +1,5 @@
require 'rubygems' unless defined?(Gem) require 'rubygems' unless defined?(Gem)
require 'rake' require 'rake'
require 'cucumber/rake/task'
require 'yard' require 'yard'
require 'bundler' require 'bundler'
@ -16,7 +15,9 @@ class Bundler::GemHelper
end end
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 ~@wip"]
exempt_tags << "--tags ~@nojava" if RUBY_PLATFORM == "java" exempt_tags << "--tags ~@nojava" if RUBY_PLATFORM == "java"
exempt_tags << "--tags ~@encoding" unless Object.const_defined?(:Encoding) 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'}" t.cucumber_opts = "--color #{exempt_tags.join(" ")} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
end 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 YARD::Rake::YardocTask.new
task :default => :test task :default => :test

View file

@ -10,6 +10,9 @@ require "thor"
# Core Pathname library used for traversal # Core Pathname library used for traversal
require "pathname" require "pathname"
require "tilt"
require "rack/mime"
module Middleman module Middleman
module Util module Util

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View file

@ -0,0 +1 @@
Some plain text

View file

@ -0,0 +1 @@
明日がある。

View file

@ -0,0 +1 @@
明日がある。

View file

View file

View file

View file