spec/compiler_spec.rb in genit-2.0 vs spec/compiler_spec.rb in genit-2.1
- old
+ new
@@ -3,11 +3,11 @@
require './spec/helper'
describe Compiler do
before :each do
- @project = ProjectCreator.new('spec/project-name', false)
+ @project = ProjectCreator.new('spec/project-name', false, false)
@project.create
@compiler = Compiler.new test_project_path
end
after :each do
@@ -18,50 +18,54 @@
File.open(File.join('spec/project-name', name), "w") do |file|
file.puts content
end
end
- it "should build an index.html page" do
- @compiler.compile
- File.exist?('spec/project-name/index.html').should be_true
+ context "after compilation" do
+ before :each do
+ @compiler.compile
+ end
+
+ it "should build an index.html page" do
+ File.exist?('spec/project-name/index.html').should be_true
+ end
+
+ it "should set the menu in index page" do
+ doc = Nokogiri::HTML(File.open("spec/project-name/index.html"))
+ doc.at_css("ul#menu a#selected")['href'].should == 'index.html'
+ end
+
+ describe "RSS feed" do
+ it "should build the rss.xml file" do
+ File.exist?('spec/project-name/rss.xml').should be_true
+ end
+ end
+
end
it "should build two pages" do
write_file 'src/pages/doc.html', '<h1>documentation</h1>'
@compiler.compile
File.exist?('spec/project-name/index.html').should be_true
File.exist?('spec/project-name/doc.html').should be_true
end
- it "should set the menu in index page" do
- @compiler.compile
- doc = Nokogiri::HTML(File.open("spec/project-name/index.html"))
- doc.at_css("ul#menu a#selected")['href'].should == 'index.html'
- end
-
context "with no '.genit' file" do
it "should exit" do
$stdout.should_receive(:puts).with(/Not a genit project folder/i)
lambda{Compiler.new File.expand_path('.')}.should raise_error(SystemExit)
end
end
-
+
context "with no 'config' file" do
it "should exit" do
$stdout.should_receive(:puts).with(/Missing config file/i)
FileUtils.rm 'spec/project-name/config'
lambda{Compiler.new test_project_path}.should raise_error(SystemExit)
end
end
-
- describe "RSS feed" do
- it "should build the rss.xml file" do
- @compiler.compile
- File.exist?('spec/project-name/rss.xml').should be_true
- end
- end
-
+
describe "Sitemap XML" do
it "should build the 'sitemap.xml'" do
a_news = %q{<h1>title</h1>}
File.open('spec/project-name/src/news/2011-10-01.html', "w") do |out|
out.puts a_news
@@ -69,10 +73,58 @@
@compiler.compile
File.exist?('spec/project-name/sitemap.xml').should be_true
end
end
+ context "with sass as stylesheet" do
+ before :each do
+ # remove screen.css
+ FileUtils.rm "spec/project-name/styles/screen.css"
+ # create screen.sass
+ file = %q{
+.content-navigation
+ border-color: blue
+ }
+ File.open('spec/project-name/styles/screen.sass', "w") do |out|
+ out.puts file
+ end
+ @compiler.compile
+ end
+
+ it "should produce css file" do
+ File.exists?("spec/project-name/styles/screen.css").should be_true
+ end
+
+ it "should not remove sass file" do
+ File.exists?("spec/project-name/styles/screen.sass").should be_true
+ end
+ end
+
+ context "with scss as stylesheet" do
+ before :each do
+ # remove screen.css
+ FileUtils.rm "spec/project-name/styles/screen.css"
+ # create screen.scss
+ file = "
+ .content-navigation {
+ border-color: blue;
+ color: darken(blue, 9%); }"
+ File.open('spec/project-name/styles/screen.scss', "w") do |out|
+ out.puts file
+ end
+ @compiler.compile
+ end
+
+ it "should produce css file" do
+ File.exists?("spec/project-name/styles/screen.css").should be_true
+ end
+
+ it "should not remove scss file" do
+ File.exists?("spec/project-name/styles/screen.scss").should be_true
+ end
+ end
+
context "with bad tag syntax" do
context "with unknown class into template" do
it "should exit" do
# replace main.html
main = %q{
@@ -186,10 +238,9 @@
it "should warn" do
# replace main.html
main = %q{
<html>
<body>
-
<genit class="pages"/>
<genit here="foo"/>
</body>
</html>
}