parent
43ac01af5c
commit
cf39b2e2cb
49 changed files with 1372 additions and 0 deletions
60
spec/builder_spec.rb
Normal file
60
spec/builder_spec.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
require 'fileutils'
|
||||
|
||||
describe "Builder" do
|
||||
def project_file(*parts)
|
||||
File.expand_path(File.join(File.dirname(__FILE__), "..", *parts))
|
||||
end
|
||||
|
||||
before :all do
|
||||
@root_dir = project_file("spec", "fixtures", "sample")
|
||||
end
|
||||
|
||||
before :each do
|
||||
build_cmd = project_file("bin", "mm-build")
|
||||
`cd #{@root_dir} && #{build_cmd}`
|
||||
end
|
||||
|
||||
after :each do
|
||||
FileUtils.rm_rf(File.join(@root_dir, "build"))
|
||||
end
|
||||
|
||||
it "should build haml files" do
|
||||
File.exists?("#{@root_dir}/build/index.html").should be_true
|
||||
File.read("#{@root_dir}/build/index.html").should include("<h1>Welcome</h1>")
|
||||
end
|
||||
|
||||
xit "should build maruku files" do
|
||||
File.exists?("#{@root_dir}/build/maruku.html").should be_true
|
||||
File.read("#{@root_dir}/build/maruku.html").should include("<h1 class='header' id='hello_maruku'>Hello Maruku</h1>")
|
||||
end
|
||||
|
||||
it "should build static files" do
|
||||
File.exists?("#{@root_dir}/build/static.html").should be_true
|
||||
File.read("#{@root_dir}/build/static.html").should include("Static, no code!")
|
||||
end
|
||||
|
||||
it "should build subdirectory files" do
|
||||
File.exists?("#{@root_dir}/build/services/index.html").should be_true
|
||||
end
|
||||
|
||||
it "should build sass files" do
|
||||
File.exists?("#{@root_dir}/build/stylesheets/site.css").should be_true
|
||||
File.read("#{@root_dir}/build/stylesheets/site.css").should include("html,body,div,span,applet,object,iframe")
|
||||
end
|
||||
|
||||
it "should build static css files" do
|
||||
File.exists?("#{@root_dir}/build/stylesheets/static.css").should be_true
|
||||
end
|
||||
|
||||
it "should not build partial files" do
|
||||
File.exists?("#{@root_dir}/build/_partial.html").should be_false
|
||||
end
|
||||
|
||||
it "should minify inline javascript" do
|
||||
File.readlines("#{@root_dir}/build/inline-js.html").length.should == 9
|
||||
end
|
||||
|
||||
it "should combine javascript" do
|
||||
File.read("#{@root_dir}/build/javascripts/empty-with-include.js").should include("combo")
|
||||
end
|
||||
end
|
18
spec/cache_buster_spec.rb
Normal file
18
spec/cache_buster_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require File.join(File.dirname(__FILE__), "spec_helper")
|
||||
|
||||
base = ::Middleman::Base
|
||||
base.set :root, File.join(File.dirname(__FILE__), "fixtures", "sample")
|
||||
|
||||
describe "Cache Buster Feature" do
|
||||
it "should not append query string if off" do
|
||||
base.disable :cache_buster
|
||||
base.new
|
||||
base.asset_url("stylesheets/static.css").should_not include("?")
|
||||
end
|
||||
|
||||
it "should append query string if on" do
|
||||
base.enable :cache_buster
|
||||
base.new
|
||||
base.asset_url("stylesheets/static.css").should include("?")
|
||||
end
|
||||
end
|
1
spec/fixtures/sample/init.rb
vendored
Normal file
1
spec/fixtures/sample/init.rb
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
enable :maruku
|
1
spec/fixtures/sample/public/javascripts/to-be-included.js
vendored
Normal file
1
spec/fixtures/sample/public/javascripts/to-be-included.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
function() { return "combo"; };
|
1
spec/fixtures/sample/public/static.html
vendored
Normal file
1
spec/fixtures/sample/public/static.html
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Static, no code!
|
2
spec/fixtures/sample/public/stylesheets/static.css
vendored
Normal file
2
spec/fixtures/sample/public/stylesheets/static.css
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
body {
|
||||
font-size: 12px; }
|
1
spec/fixtures/sample/views/_partial.haml
vendored
Normal file
1
spec/fixtures/sample/views/_partial.haml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
%p Test
|
1
spec/fixtures/sample/views/index.html.haml
vendored
Normal file
1
spec/fixtures/sample/views/index.html.haml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
%h1 Welcome
|
7
spec/fixtures/sample/views/inline-js.html.haml
vendored
Normal file
7
spec/fixtures/sample/views/inline-js.html.haml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
:javascript
|
||||
;(function() {
|
||||
this;
|
||||
should();
|
||||
all.be();
|
||||
on = { one: line };
|
||||
});
|
1
spec/fixtures/sample/views/javascripts/empty-with-include.js
vendored
Normal file
1
spec/fixtures/sample/views/javascripts/empty-with-include.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
//= require <to-be-included>
|
6
spec/fixtures/sample/views/layout.haml
vendored
Normal file
6
spec/fixtures/sample/views/layout.haml
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
%html
|
||||
%head
|
||||
%link{ :href => "/stylesheets/site.css", :rel => "stylesheet", :type => "text/css" }
|
||||
%title My Sample Site
|
||||
%body
|
||||
= yield
|
1
spec/fixtures/sample/views/maruku.html.maruku
vendored
Normal file
1
spec/fixtures/sample/views/maruku.html.maruku
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
# Hello Maruku {.header}
|
1
spec/fixtures/sample/views/services/index.html.haml
vendored
Normal file
1
spec/fixtures/sample/views/services/index.html.haml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
%h2 Services
|
1
spec/fixtures/sample/views/stylesheets/site.css.sass
vendored
Normal file
1
spec/fixtures/sample/views/stylesheets/site.css.sass
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
@import compass/reset.sass
|
34
spec/generator_spec.rb
Normal file
34
spec/generator_spec.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
require 'fileutils'
|
||||
|
||||
describe "Generator" do
|
||||
def project_file(*parts)
|
||||
File.expand_path(File.join(File.dirname(__FILE__), "..", *parts))
|
||||
end
|
||||
|
||||
before :all do
|
||||
@root_dir = project_file("spec", "fixtures", "generator-test")
|
||||
end
|
||||
|
||||
before :each do
|
||||
init_cmd = project_file("bin", "mm-init")
|
||||
`cd #{File.dirname(@root_dir)} && #{init_cmd} #{File.basename(@root_dir)}`
|
||||
end
|
||||
|
||||
after :each do
|
||||
FileUtils.rm_rf(@root_dir)
|
||||
end
|
||||
|
||||
it "should copy template files" do
|
||||
template_dir = project_file("lib", "template", "**/*")
|
||||
Dir[template_dir].each do |f|
|
||||
next if File.directory?(f)
|
||||
File.exists?("#{@root_dir}/#{f.split('template/')[1]}").should be_true
|
||||
end
|
||||
end
|
||||
|
||||
it "should create empty directories" do
|
||||
%w(views/stylesheets public/stylesheets public/javascripts public/images).each do |d|
|
||||
File.exists?("#{@root_dir}/#{d}").should be_true
|
||||
end
|
||||
end
|
||||
end
|
28
spec/relative_assets_spec.rb
Normal file
28
spec/relative_assets_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# require File.join(File.dirname(__FILE__), "spec_helper")
|
||||
#
|
||||
# base = ::Middleman::Base
|
||||
# base.set :root, File.join(File.dirname(__FILE__), "fixtures", "sample")
|
||||
#
|
||||
# describe "Relative Assets Feature" do
|
||||
# before do
|
||||
# base.disable :relative_assets
|
||||
# base.init!
|
||||
# @app = base.new
|
||||
# end
|
||||
#
|
||||
# it "should not contain ../ if off" do
|
||||
# @app.asset_url("stylesheets/static.css").should_not include("?")
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# describe "Relative Assets Feature" do
|
||||
# before do
|
||||
# base.enable :relative_assets
|
||||
# base.init!
|
||||
# @app = base.new
|
||||
# end
|
||||
#
|
||||
# it "should contain ../ if on" do
|
||||
# @app.asset_url("stylesheets/static.css").should include("?")
|
||||
# end
|
||||
# end
|
10
spec/spec_helper.rb
Normal file
10
spec/spec_helper.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
require 'rubygems'
|
||||
require 'spec'
|
||||
|
||||
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
require 'middleman'
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue