Reorganize tests for plugins.
This commit is contained in:
parent
34de676713
commit
0ad2c338c4
|
@ -0,0 +1,34 @@
|
||||||
|
Feature: Configuring and using plugins
|
||||||
|
As a hacker
|
||||||
|
I want to specify my own plugins that can modify Jekyll's behaviour
|
||||||
|
|
||||||
|
Scenario: Add a gem-based plugin
|
||||||
|
Given I have an "index.html" file that contains "Whatever"
|
||||||
|
And I have a configuration file with "gems" set to "[jekyll_test_plugin]"
|
||||||
|
When I run jekyll build
|
||||||
|
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 build --safe
|
||||||
|
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 build --safe
|
||||||
|
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"
|
|
@ -243,37 +243,6 @@ Feature: Site configuration
|
||||||
And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
|
And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
|
||||||
And I should see "Post Layout: <p>content for entry2.</p>" in "_site/2020/01/31/entry2.html"
|
And I should see "Post Layout: <p>content for entry2.</p>" in "_site/2020/01/31/entry2.html"
|
||||||
|
|
||||||
Scenario: Add a gem-based plugin
|
|
||||||
Given I have an "index.html" file that contains "Whatever"
|
|
||||||
And I have a configuration file with "gems" set to "[jekyll_test_plugin]"
|
|
||||||
When I run jekyll build
|
|
||||||
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 build --safe
|
|
||||||
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 build --safe
|
|
||||||
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"
|
|
||||||
|
|
||||||
Scenario: arbitrary file reads via layouts
|
Scenario: arbitrary file reads via layouts
|
||||||
Given I have an "index.html" page with layout "page" that contains "FOO"
|
Given I have an "index.html" page with layout "page" that contains "FOO"
|
||||||
And I have a "_config.yml" file that contains "layouts: '../../../../../../../../../../../../../../usr/include'"
|
And I have a "_config.yml" file that contains "layouts: '../../../../../../../../../../../../../../usr/include'"
|
||||||
|
|
|
@ -146,6 +146,13 @@ When /^I run jekyll(.*)$/ do |args|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I run bundle(.*)$/ do |args|
|
||||||
|
status = run_bundle(args)
|
||||||
|
if args.include?("--verbose") || ENV['DEBUG']
|
||||||
|
puts jekyll_run_output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
|
When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
|
||||||
File.open(file, 'a') do |f|
|
File.open(file, 'a') do |f|
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
|
@ -21,11 +21,19 @@ def jekyll_run_output
|
||||||
File.read(jekyll_output_file) if File.file?(jekyll_output_file)
|
File.read(jekyll_output_file) if File.file?(jekyll_output_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def run_bundle(args)
|
||||||
|
child = run_in_shell('bundle', *args.strip.split(' '))
|
||||||
|
end
|
||||||
|
|
||||||
def run_jekyll(args)
|
def run_jekyll(args)
|
||||||
child = POSIX::Spawn::Child.new JEKYLL_PATH, *args.strip.split(' '), "--trace", :out => [JEKYLL_COMMAND_OUTPUT_FILE, "w"]
|
child = run_in_shell(JEKYLL_PATH, *args.strip.split(' '), "--trace")
|
||||||
child.status.exitstatus == 0
|
child.status.exitstatus == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def run_in_shell(args, options)
|
||||||
|
POSIX::Spawn::Child.new *args, :out => [JEKYLL_COMMAND_OUTPUT_FILE, "w"])
|
||||||
|
end
|
||||||
|
|
||||||
def slug(title)
|
def slug(title)
|
||||||
if title
|
if title
|
||||||
title.downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
|
title.downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
|
||||||
|
|
Loading…
Reference in New Issue