require File.dirname(__FILE__) + '/helper' describe Frank::Compile do include Rack::Test::Methods context 'default output' do before :all do bin_dir = File.join(File.dirname(File.dirname(__FILE__)), 'bin', 'frank export') proj_dir = File.join(File.dirname(__FILE__), 'template') output_dir = File.join(proj_dir, 'output') Dir.chdir proj_dir do system "#{bin_dir} #{output_dir} > /dev/null" end end it 'creates the output folder' do File.exist?(File.join(File.dirname(__FILE__), 'template/output')).should be_true end it 'creates index.html' do output = File.join(File.dirname(__FILE__), 'template/output/index.html') File.read(output).should == "
/
\n
\n

hello worlds

\n

/

\n
\n" end it 'creates partial_test.html' do output = File.join(File.dirname(__FILE__), 'template/output/partial_test.html') File.read(output).should == "
/partial_test
\n
\n

hello worlds

\n

/partial_test

\n

hello from partial

\n
\n" end it 'creates partial_locals_test.html' do output = File.join(File.dirname(__FILE__), 'template/output/partial_locals_test.html') File.read(output).should == "
/partial_locals_test
\n
\n

hello worlds

\n

/partial_locals_test

\n

hello from local

\n
\n" end it 'creates child.html' do output = File.join(File.dirname(__FILE__), 'template/output/nested/child.html') File.read(output).should == "
\n

hello from child

\n
\n" end it 'creates deep.html' do output = File.join(File.dirname(__FILE__), 'template/output/nested/deeper/deep.html') File.read(output).should == "
\n

really deep

\n
\n" end it 'creates no_layout.html' do output = File.join(File.dirname(__FILE__), 'template/output/no_layout.html') File.read(output).should == "

i have no layout

\n" end it 'creates erb.html' do output = File.join(File.dirname(__FILE__), 'template/output/erb.html') File.read(output).should == "
/erb
\n
\n

hello worlds

\n
\n" end it 'creates redcloth.html' do output = File.join(File.dirname(__FILE__), 'template/output/redcloth.html') File.read(output).should == "
/redcloth
\n
\n

hello worlds

\n
\n" end it 'creates markdown.html' do output = File.join(File.dirname(__FILE__), 'template/output/markdown.html') File.read(output).should == "
/markdown
\n
\n

hello worlds

\n
\n" end it 'creates liquid.html' do output = File.join(File.dirname(__FILE__), 'template/output/liquid.html') File.read(output).should == "
/liquid
\n
\n

hello worlds

\n
\n" end it 'creates builder.html' do output = File.join(File.dirname(__FILE__), 'template/output/builder.html') File.read(output).should == "
/builder
\n
\n

hello worlds

\n
\n" end it 'copies static.html' do output = File.join(File.dirname(__FILE__), 'template/output/files/static.html') File.read(output).should == "hello from static" end it "doesn't create partials" do File.exist?(File.join(File.dirname(__FILE__), 'template/output/_partial.html')).should be_false end it 'handles lorem replacement fields' do output = File.join(File.dirname(__FILE__), 'template/output/lorem_test.html') File.read(output).should include("

replace-this

") File.read(output).should include("

replace-this

") File.read(output).should include("

replace-this

") File.read(output).should include("

replace-this

") File.read(output).should include("

replace-this

") File.read(output).should include("

replace-this

") File.read(output).should include("") end it 'should not render the refresh js' do output = File.join(File.dirname(__FILE__), 'template/output/refresh.html') File.read(output).should == "
/refresh
\n
\n \n
\n" end after(:all) do FileUtils.rm_r File.join(File.dirname(__FILE__), 'template/output') end end context 'productions output' do before :all do bin_dir = File.join(File.dirname(File.dirname(__FILE__)), 'bin', 'frank export') proj_dir = File.join(File.dirname(__FILE__), 'template') output_dir = File.join(proj_dir, 'output') Dir.chdir proj_dir do system "#{bin_dir} #{output_dir} --production > /dev/null" end end it 'creates the output folder' do File.exist?(File.join(File.dirname(__FILE__), 'template/output')).should be_true end it 'creates index.html' do output = File.join(File.dirname(__FILE__), 'template/output/index.html') File.read(output).should == "
/
\n
\n

hello worlds

\n

/

\n
\n" end it 'creates partial_test.html' do output = File.join(File.dirname(__FILE__), 'template/output/partial_test/index.html') File.read(output).should == "
/partial_test
\n
\n

hello worlds

\n

/partial_test

\n

hello from partial

\n
\n" end it 'creates partial_locals_test.html' do output = File.join(File.dirname(__FILE__), 'template/output/partial_locals_test/index.html') File.read(output).should == "
/partial_locals_test
\n
\n

hello worlds

\n

/partial_locals_test

\n

hello from local

\n
\n" end it 'creates child.html' do output = File.join(File.dirname(__FILE__), 'template/output/nested/child/index.html') File.read(output).should == "
\n

hello from child

\n
\n" end it 'creates deep.html' do output = File.join(File.dirname(__FILE__), 'template/output/nested/deeper/deep/index.html') File.read(output).should == "
\n

really deep

\n
\n" end it 'creates no_layout.html' do output = File.join(File.dirname(__FILE__), 'template/output/no_layout/index.html') File.read(output).should == "

i have no layout

\n" end it 'creates erb.html' do output = File.join(File.dirname(__FILE__), 'template/output/erb/index.html') File.read(output).should == "
/erb
\n
\n

hello worlds

\n
\n" end it 'creates redcloth.html' do output = File.join(File.dirname(__FILE__), 'template/output/redcloth/index.html') File.read(output).should == "
/redcloth
\n
\n

hello worlds

\n
\n" end it 'creates markdown.html' do output = File.join(File.dirname(__FILE__), 'template/output/markdown/index.html') File.read(output).should == "
/markdown
\n
\n

hello worlds

\n
\n" end it 'creates liquid.html' do output = File.join(File.dirname(__FILE__), 'template/output/liquid/index.html') File.read(output).should == "
/liquid
\n
\n

hello worlds

\n
\n" end it 'creates builder.html' do output = File.join(File.dirname(__FILE__), 'template/output/builder/index.html') File.read(output).should == "
/builder
\n
\n

hello worlds

\n
\n" end it 'copies static.html' do output = File.join(File.dirname(__FILE__), 'template/output/files/static.html') File.read(output).should == "hello from static" end it "doesn't create partials" do File.exist?(File.join(File.dirname(__FILE__), 'template/output/_partial/index.html')).should be_false end it 'handles lorem replacement fields' do output = File.join(File.dirname(__FILE__), 'template/output/lorem_test/index.html') File.read(output).should include("

replace-this

") File.read(output).should include("

replace-this

") File.read(output).should include("

replace-this

") File.read(output).should include("

replace-this

") File.read(output).should include("

replace-this

") File.read(output).should include("

replace-this

") File.read(output).should include("") end it 'should not render the refresh js' do output = File.join(File.dirname(__FILE__), 'template/output/refresh/index.html') File.read(output).should == "
/refresh
\n
\n \n
\n" end after(:all) do FileUtils.rm_r File.join(File.dirname(__FILE__), 'template/output') end end end