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
|
|
|
|
|
2016-09-26 05:23:06 +10:00
|
|
|
Given /^I have copied my site to "(.+)"$/ do |path|
|
|
|
|
new_site_dir = File.join(TEST_DIR, path)
|
|
|
|
|
|
|
|
FileUtils.mkdir_p(new_site_dir)
|
|
|
|
|
|
|
|
Dir.glob(File.join(TEST_DIR, '*'))
|
|
|
|
.reject { |f| File.basename(f) == File.dirname(path) }
|
|
|
|
.each { |f| FileUtils.mv(f, new_site_dir) }
|
|
|
|
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|
|
2016-09-26 06:37:10 +10:00
|
|
|
contents = File.open(file).readlines.join
|
|
|
|
assert contents.inspect.include?(text), "Expected to find #{text.inspect} in #{contents.inspect}"
|
2014-12-06 03:26:50 +11:00
|
|
|
end
|
|
|
|
|
2016-10-12 07:21:11 +11:00
|
|
|
Then /^the file "(.+)" should contain:$/ do |file, contents|
|
|
|
|
assert_equal contents.strip, File.open(file).readlines.join.strip
|
|
|
|
end
|
|
|
|
|
2014-12-06 10:55:10 +11:00
|
|
|
Then /^the file "(.+)" should exist$/ do |path|
|
2016-06-06 07:32:13 +10:00
|
|
|
assert File.exist?(path)
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^the file "(.+)" should not exist$/ do |path|
|
|
|
|
assert !File.exist?(path)
|
2014-12-06 10:55:10 +11:00
|
|
|
end
|
|
|
|
|
2015-12-27 05:11:05 +11:00
|
|
|
Then /^the image "(.+)" should have the dimensions "(\d+)x(\d+)"$/ do |path, width, height|
|
|
|
|
img = Magick::Image::read(path).first
|
|
|
|
assert_equal "#{width}x#{height}", "#{img.columns}x#{img.rows}"
|
|
|
|
img.destroy!
|
|
|
|
end
|
|
|
|
|
2016-12-28 21:14:13 +11:00
|
|
|
Then /^the image "(.+)" should be interlaced$/ do |path|
|
|
|
|
img = Magick::Image::read(path).first
|
|
|
|
assert_equal Magick::JPEGInterlace, img.interlace
|
|
|
|
img.destroy!
|
|
|
|
end
|
|
|
|
|
2018-01-19 12:13:21 +11:00
|
|
|
Then /^the image "(.+)" should have an EXIF orientation$/ do |path|
|
|
|
|
img = Magick::Image::read(path).first
|
|
|
|
assert_not_equal img.orientation.to_i, 0
|
|
|
|
img.destroy!
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^the image "(.+)" should have no EXIF orientation$/ do |path|
|
|
|
|
img = Magick::Image::read(path).first
|
|
|
|
assert_equal img.orientation.to_i, 0
|
|
|
|
img.destroy!
|
|
|
|
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
|