Add test code for 'whitelist' option.

This commit is contained in:
Parker Moore 2013-12-06 00:21:34 -05:00
parent 615d49ed66
commit 6187861e91
3 changed files with 29 additions and 1 deletions

View File

@ -233,3 +233,26 @@ Feature: Site configuration
Then the _site directory should exist
And I should see "Whatever" in "_site/index.html"
And I should see "this is a test" in "_site/test.txt"
Scenario: Add an empty whitelist to restrict all gems
Given I have an "index.html" file that contains "Whatever"
And I have a configuration file with:
| key | value |
| gems | [jekyll_test_plugin] |
| whitelist | [] |
When I run jekyll in safe mode
Then the _site directory should exist
And I should see "Whatever" in "_site/index.html"
And the "_site/test.txt" file should not exist
Scenario: Add a whitelist to restrict some gems but allow others
Given I have an "index.html" file that contains "Whatever"
And I have a configuration file with:
| key | value |
| gems | [jekyll_test_plugin, jekyll_test_plugin_malicious] |
| whitelist | [jekyll_test_plugin] |
When I run jekyll in safe mode
Then the _site directory should exist
And I should see "Whatever" in "_site/index.html"
And the "_site/test.txt" file should exist
And I should see "this is a test" in "_site/test.txt"

View File

@ -126,6 +126,10 @@ When /^I run jekyll$/ do
run_jekyll
end
When /^I run jekyll in safe mode$/ do
run_jekyll(:safe => true)
end
When /^I run jekyll with drafts$/ do
run_jekyll(:drafts => true)
end

View File

@ -15,6 +15,7 @@ def run_jekyll(opts = {})
command = JEKYLL_PATH.clone
command << " build"
command << " --drafts" if opts[:drafts]
command << " --safe" if opts[:safe]
command << " >> /dev/null 2>&1" if opts[:debug].nil?
system command
end