Add unit and cucumber tests
This commit is contained in:
parent
8a257aca6b
commit
02f281eef3
|
@ -0,0 +1,60 @@
|
|||
Feature: Incremental rebuild
|
||||
As an impatient hacker who likes to blog
|
||||
I want to be able to make a static site
|
||||
Without waiting too long for it to build
|
||||
|
||||
Scenario: Produce correct output site
|
||||
Given I have a _layouts directory
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| Wargames | 2009-03-27 | default | The only winning move is not to play. |
|
||||
And I have a default layout that contains "Post Layout: {{ content }}"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
|
||||
|
||||
Scenario: Generate a metadata file
|
||||
Given I have an "index.html" file that contains "Basic Site"
|
||||
When I run jekyll build
|
||||
Then the ".jekyll-metadata" file should exist
|
||||
|
||||
Scenario: Rebuild when content is changed
|
||||
Given I have an "index.html" file that contains "Basic Site"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Basic Site" in "_site/index.html"
|
||||
When I wait 1 second
|
||||
Then I have an "index.html" file that contains "Bacon Site"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Bacon Site" in "_site/index.html"
|
||||
|
||||
Scenario: Rebuild when layout is changed
|
||||
Given I have a _layouts directory
|
||||
And I have an "index.html" page with layout "default" that contains "Basic Site with Layout"
|
||||
And I have a default layout that contains "Page Layout: {{ content }}"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Page Layout: Basic Site with Layout" in "_site/index.html"
|
||||
When I wait 1 second
|
||||
Then I have a default layout that contains "Page Layout Changed: {{ content }}"
|
||||
When I run jekyll build --full-rebuild
|
||||
Then the _site directory should exist
|
||||
And I should see "Page Layout Changed: Basic Site with Layout" in "_site/index.html"
|
||||
|
||||
Scenario: Rebuild when an include is changed
|
||||
Given I have a _includes directory
|
||||
And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}"
|
||||
And I have an "_includes/about.textile" file that contains "Generated by Jekyll"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html"
|
||||
When I wait 1 second
|
||||
Then I have an "_includes/about.textile" file that contains "Regenerated by Jekyll"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Basic Site with include tag: Regenerated by Jekyll" in "_site/index.html"
|
|
@ -133,6 +133,10 @@ Given /^I have fixture collections$/ do
|
|||
FileUtils.cp_r File.join(JEKYLL_SOURCE_DIR, "test", "source", "_methods"), source_dir
|
||||
end
|
||||
|
||||
Given /^I wait (\d+) second(s?)$/ do |time, plural|
|
||||
sleep(time.to_f)
|
||||
end
|
||||
|
||||
##################
|
||||
#
|
||||
# Changing stuff
|
||||
|
|
|
@ -36,8 +36,8 @@ module Jekyll
|
|||
#
|
||||
# Returns nothing
|
||||
def clear
|
||||
metadata = {}
|
||||
cache = {}
|
||||
@metadata = {}
|
||||
@cache = {}
|
||||
end
|
||||
|
||||
# Checks if a path should be regenerated
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
require 'helper'
|
||||
|
||||
class TestMetadata < Test::Unit::TestCase
|
||||
context "The site metadata" do
|
||||
setup do
|
||||
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
|
||||
|
||||
@site = Site.new(Jekyll.configuration({
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir
|
||||
}))
|
||||
|
||||
@site.process
|
||||
@path = @site.in_source_dir(@site.pages.first.path)
|
||||
@metadata = @site.metadata
|
||||
end
|
||||
|
||||
should "store modification times" do
|
||||
assert_equal @metadata.metadata[@path]["mtime"], File.mtime(@path)
|
||||
end
|
||||
|
||||
should "cache processed entries" do
|
||||
assert @metadata.cache[@path]
|
||||
end
|
||||
|
||||
should "write to the metadata file" do
|
||||
@metadata.clear
|
||||
@metadata.add(@path)
|
||||
@metadata.write
|
||||
assert File.file?(source_dir(".jekyll-metadata"))
|
||||
end
|
||||
|
||||
should "read from the metadata file" do
|
||||
@metadata = Metadata.new(@site)
|
||||
assert_equal @metadata.metadata[@path]["mtime"], File.mtime(@path)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue