tests working, building working

This commit is contained in:
tdreyno 2009-07-28 11:06:45 -07:00
parent 7e4916169c
commit 338430f2d5
8 changed files with 31 additions and 19 deletions

2
.gitignore vendored
View file

@ -3,3 +3,5 @@
coverage
rdoc
pkg
.sass-cache
*.gemspec

3
.gitmodules vendored
View file

@ -4,3 +4,6 @@
[submodule "vendor/sinatra-maruku"]
path = vendor/sinatra-maruku
url = git://github.com/wbzyl/sinatra-maruku.git
[submodule "vendor/rack-test"]
path = vendor/rack-test
url = git://github.com/brynary/rack-test.git

View file

@ -3,8 +3,8 @@
# Require app
require 'rubygems'
require 'templater'
require 'open-uri'
require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')
require File.join(File.dirname(__FILE__), '..', 'vendor', 'rack-test', 'lib', 'rack', 'test')
module Generators
extend Templater::Manifold
@ -19,7 +19,7 @@ module Generators
def self.template(name, *args, &block)
return if args.first.include?('layout')
return if File.basename(args.first)[0,1] == '_'
if (args[0] === args[1])
newext = case File.extname(args.first)
when '.haml', '.mab', '.maruku'
@ -31,11 +31,12 @@ module Generators
end
args[1] = args[0].gsub(File.extname(args.first), newext).gsub('views/', '')
end
super(name, *args, &block)
end
def self.file(name, *args, &block)
puts args.inspect
args[1] = args[0].gsub('views/', '') if (args[0] === args[1])
super(name, *args, &block)
end
@ -53,16 +54,16 @@ module Generators
add :build, Builder
end
# Monkey-patch to use a dynamic renderer, not just ERb
Middleman.set :root, Dir.pwd
# Monkey-patch to use a dynamic renderer
class Templater::Actions::Template
def render
return ""
#request_path = destination.gsub(File.join(Dir.pwd, 'build'), "")
#Rack Handler
request_path = destination.gsub(File.join(Dir.pwd, 'build'), "")
browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman))
browser.get(request_path)
browser.last_response.body
end
end
# Start app
#Middleman.run!(:root => Dir.pwd) do
Generators.run_cli(Dir.pwd, 'mm-build', 1, %w(build --force).concat(ARGV))
#end
Generators.run_cli(Dir.pwd, 'mm-build', 1, %w(build --force).concat(ARGV))

View file

@ -56,8 +56,10 @@ class Middleman < Sinatra::Base
haml(template)
elsif File.exists? File.join(options.views, "#{template}.maruku")
maruku(template)
else
elsif File.exists? File.join(options.views, "#{template}.mab")
markaby(template)
else
pass
end
elsif path.match /.css$/
content_type 'text/css', :charset => 'utf-8'

View file

@ -20,18 +20,22 @@ describe "Builder" do
it "should build markaby files" do
File.exists?("#{@root_dir}/build/markaby.html").should be_true
File.read("#{@root_dir}/build/markaby.html").should include("<title>Hi Markaby</title>")
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
it "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
@ -40,6 +44,7 @@ describe "Builder" do
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

View file

@ -0,0 +1,5 @@
mab.html do
head do
title "Hi Markaby"
end
end

View file

@ -1,7 +0,0 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Middleman" do
it "fails" do
fail "hey buddy, you should probably rename this file and start specing for real"
end
end

1
vendor/rack-test vendored Submodule

@ -0,0 +1 @@
Subproject commit 6d8c25af8592faf2efb3f5ab73b0219eadf30ea4