All green for create sites feature
This commit is contained in:
parent
c22cd84153
commit
0d78cb7063
|
@ -20,7 +20,7 @@ Feature: Create sites
|
|||
|
||||
Scenario: Basic site with layout and a page
|
||||
Given I have a _layouts directory
|
||||
And I have an "index.html" file with layout "default" that contains "Basic Site with Layout"
|
||||
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
|
||||
Then the _site directory should exist
|
||||
|
@ -31,16 +31,16 @@ Feature: Create sites
|
|||
And I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Wargames | 3/27/2009 | default | Would you like to play a game?" |
|
||||
| Wargames | 3/27/2009 | default | The only winning move is not to play. |
|
||||
And I have a default layout that contains "Post Layout: {{ content }}"
|
||||
When I run jekyll
|
||||
Then the _site directory should exist
|
||||
And I should see "Post Layout: Would you like to play a game?" in "_site/2009/03/27/wargames.html"
|
||||
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
|
||||
|
||||
Scenario: Basic site with include tag
|
||||
Given I have a _includes directory
|
||||
And I have an "index.html" file that contains "Basic Site with include tag: {% include about.html %}"
|
||||
And I have an "_includes/about.html" file that contains "Generated by Jekyll"
|
||||
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
|
||||
Then the _site directory should exist
|
||||
And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html"
|
||||
|
|
|
@ -8,23 +8,28 @@ After do
|
|||
FileUtils.rm_rf(TEST_DIR)
|
||||
end
|
||||
|
||||
Given /^I have an "(.*)" file(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
|
||||
Given /^I have an "(.*)" page(?: with layout "(.*)")? that contains "(.*)"$/ do |file, layout, text|
|
||||
File.open(file, 'w') do |f|
|
||||
if key && value
|
||||
f.write <<EOF
|
||||
---
|
||||
#{key}: #{value}
|
||||
layout: #{layout || 'nil'}
|
||||
---
|
||||
EOF
|
||||
end
|
||||
|
||||
f.write(text)
|
||||
f.close
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have an "(.*)" file that contains "(.*)"$/ do |file, text|
|
||||
File.open(file, 'w') do |f|
|
||||
f.write(text)
|
||||
f.close
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a (.*) layout that contains "(.*)"$/ do |layout, text|
|
||||
File.open(layout, 'w') do |f|
|
||||
File.open(File.join('_layouts', layout + '.html'), 'w') do |f|
|
||||
f.write(text)
|
||||
f.close
|
||||
end
|
||||
|
@ -34,8 +39,25 @@ Given /^I have a (.*) directory$/ do |dir|
|
|||
FileUtils.mkdir(dir)
|
||||
end
|
||||
|
||||
Given /^I have the following posts?(?: in "(.*)")?:$/ do |table, dir|
|
||||
pending
|
||||
Given /^I have the following posts?(?: in "(.*)")?:$/ do |dir, table|
|
||||
table.hashes.each do |post|
|
||||
date = Date.parse(post['date']).strftime('%Y-%m-%d')
|
||||
path = File.join("_posts", "#{date}-#{post['title'].downcase}.textile")
|
||||
|
||||
matter_hash = {'title' => post['title']}
|
||||
matter_hash['layout'] = post['layout'] if post['layout']
|
||||
matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }
|
||||
|
||||
File.open(path, 'w') do |f|
|
||||
f.write <<EOF
|
||||
---
|
||||
#{matter}
|
||||
---
|
||||
#{post['content']}
|
||||
EOF
|
||||
f.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a configuration file(?: in "(.*)")? with "(.*)" set to "(.*)"$/ do |dir, key, value|
|
||||
|
@ -43,7 +65,7 @@ Given /^I have a configuration file(?: in "(.*)")? with "(.*)" set to "(.*)"$/ d
|
|||
end
|
||||
|
||||
When /^I run jekyll$/ do
|
||||
`#{File.join(ENV['PWD'], 'bin', 'jekyll')} >> /dev/null`
|
||||
`#{File.join(ENV['PWD'], 'bin', 'jekyll')}`
|
||||
end
|
||||
|
||||
When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
|
||||
|
@ -55,11 +77,11 @@ When /^I go to "(.*)"$/ do |address|
|
|||
end
|
||||
|
||||
Then /^the (.*) directory should exist$/ do |dir|
|
||||
pending
|
||||
assert File.directory?(dir)
|
||||
end
|
||||
|
||||
Then /^I should see "(.*)"(?: in "(.*)")?$/ do |text, file|
|
||||
pending
|
||||
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
|
||||
assert_match Regexp.new(text), File.open(file).readlines.join
|
||||
end
|
||||
|
||||
Then /^the "(.*)" file should not exist$/ do |file|
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
require 'fileutils'
|
||||
require 'rr'
|
||||
require 'test/unit'
|
||||
|
||||
World do
|
||||
include Test::Unit::Assertions
|
||||
end
|
||||
|
||||
TEST_DIR = File.join('/', 'tmp', 'jekyll')
|
||||
|
|
Loading…
Reference in New Issue