2014-12-08 09:33:14 +11:00
|
|
|
include Test::Unit::Assertions
|
|
|
|
|
2014-12-06 03:26:50 +11:00
|
|
|
When /^I run Jekyll$/ do
|
|
|
|
run_jekyll
|
|
|
|
end
|
|
|
|
|
2014-12-08 09:33:14 +11:00
|
|
|
Then /^Jekyll should throw a "(.+)"$/ do |error_class|
|
|
|
|
assert_raise(Object.const_get(error_class)) { run_jekyll }
|
|
|
|
end
|
|
|
|
|
2015-11-05 20:02:16 +11:00
|
|
|
Given /^I have a configuration with:$/ do |config|
|
|
|
|
write_file('_config.yml', config)
|
|
|
|
end
|
|
|
|
|
2014-12-06 03:26:50 +11:00
|
|
|
Given /^I have a responsive_image configuration with:$/ do |config|
|
|
|
|
write_file('_config.yml', "responsive_image:\n#{config}")
|
|
|
|
end
|
|
|
|
|
2014-12-08 00:14:40 +11:00
|
|
|
Given /^I have a responsive_image configuration with "(.+)" set to "(.+)"$/ do |config, value|
|
|
|
|
write_file('_config.yml', "responsive_image:\n #{config}: #{value}")
|
|
|
|
end
|
|
|
|
|
2014-12-06 10:55:10 +11:00
|
|
|
Given /^I have a file "(.+)" with:$/ do |path, contents|
|
|
|
|
write_file(path, "---\n---\n#{contents}")
|
2014-12-06 03:26:50 +11:00
|
|
|
end
|
|
|
|
|
2014-12-08 00:14:40 +11:00
|
|
|
Given /^I have a file "(.+)" with "(.+)"$/ do |path, contents|
|
|
|
|
write_file(path, "---\n---\n#{contents}")
|
|
|
|
end
|
|
|
|
|
2014-12-06 10:55:10 +11:00
|
|
|
Then /^I should see "(.+)" in "(.*)"$/ do |text, file|
|
2014-12-06 03:26:50 +11:00
|
|
|
assert_match(Regexp.new(text), File.open(file).readlines.join)
|
|
|
|
end
|
|
|
|
|
2014-12-06 10:55:10 +11:00
|
|
|
Then /^the file "(.+)" should exist$/ do |path|
|
|
|
|
assert File.exists?(path)
|
|
|
|
end
|
|
|
|
|
2014-12-06 03:26:50 +11:00
|
|
|
def write_file(path, contents)
|
|
|
|
File.open(path, 'w') do |f|
|
|
|
|
f.write(contents)
|
|
|
|
f.close
|
|
|
|
end
|
|
|
|
end
|