add theme-gem feature for bonafide theme gems
this cucumber feature follows the likely steps a theme designer would take to build a Rubygem of his theme starting from the scaffolding generated by `jekyll new-theme` command and further checks if the gem built actually has the files he planned to include.
This commit is contained in:
parent
682c0fc98f
commit
1b4b51236a
|
@ -156,6 +156,31 @@ end
|
|||
|
||||
#
|
||||
|
||||
When(%r!^I run gem(.*)$!) do |args|
|
||||
run_rubygem(args)
|
||||
if args.include?("--verbose") || ENV["DEBUG"]
|
||||
$stderr.puts "\n#{jekyll_run_output}\n"
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
When(%r!^I run git add .$!) do
|
||||
run_in_shell("git", "add", ".")
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
When(%r!^I decide to build the theme gem$!) do
|
||||
Dir.chdir(Paths.theme_gem_dir)
|
||||
gemspec = "my-cool-theme.gemspec"
|
||||
File.write(gemspec, File.read(gemspec).sub("TODO: ", ""))
|
||||
File.new("_includes/blank.html", "w")
|
||||
File.new("_sass/blank.scss", "w")
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
When(%r!^I change "(.*)" to contain "(.*)"$!) do |file, text|
|
||||
File.open(file, "a") do |f|
|
||||
f.write(text)
|
||||
|
@ -179,6 +204,7 @@ Then(%r!^the (.*) directory should +(not )?exist$!) do |dir, negative|
|
|||
end
|
||||
|
||||
#
|
||||
|
||||
Then(%r!^I should (not )?see "(.*)" in "(.*)"$!) do |negative, text, file|
|
||||
step %(the "#{file}" file should exist)
|
||||
regexp = Regexp.new(text, Regexp::MULTILINE)
|
||||
|
|
|
@ -8,6 +8,8 @@ class Paths
|
|||
SOURCE_DIR = Pathname.new(File.expand_path("../..", __dir__))
|
||||
def self.test_dir; source_dir.join("tmp", "jekyll"); end
|
||||
|
||||
def self.theme_gem_dir; source_dir.join("tmp", "jekyll", "my-cool-theme"); end
|
||||
|
||||
def self.output_file; test_dir.join("jekyll_output.txt"); end
|
||||
|
||||
def self.status_file; test_dir.join("jekyll_status.txt"); end
|
||||
|
@ -88,6 +90,12 @@ end
|
|||
|
||||
#
|
||||
|
||||
def run_rubygem(args)
|
||||
run_in_shell("gem", *args.strip.split(" "))
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def run_jekyll(args)
|
||||
args = args.strip.split(" ") # Shellwords?
|
||||
process = run_in_shell("ruby", Paths.jekyll_bin.to_s, *args, "--trace")
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
Feature: Building Theme Gems
|
||||
As a hacker who likes to share my expertise
|
||||
I want to be able to make a bonafide rubygem off my theme
|
||||
In order to share my awesome style skillz with other Jekyllites
|
||||
|
||||
Scenario: Generating a new Jekyll Theme
|
||||
When I run jekyll new-theme my-cool-theme
|
||||
Then I should get a zero exit status
|
||||
And the my-cool-theme directory should exist
|
||||
|
||||
Scenario: Checking if a bonafide Theme gem will be built from generated scaffolding
|
||||
When I run jekyll new-theme my-cool-theme
|
||||
Then I should get a zero exit status
|
||||
And the my-cool-theme directory should exist
|
||||
When I decide to build the theme gem
|
||||
Then I should get a zero exit status
|
||||
When I run git add .
|
||||
Then I should get a zero exit status
|
||||
When I run gem build my-cool-theme.gemspec
|
||||
Then I should get a zero exit status
|
||||
And the "./my-cool-theme-0.1.0.gem" file should exist
|
||||
When I run gem unpack my-cool-theme-0.1.0.gem
|
||||
Then I should get a zero exit status
|
||||
And the my-cool-theme-0.1.0 directory should exist
|
||||
And the "my-cool-theme-0.1.0/_layouts/default.html" file should exist
|
||||
And the "my-cool-theme-0.1.0/_includes/blank.html" file should exist
|
||||
And the "my-cool-theme-0.1.0/_sass/blank.scss" file should exist
|
||||
And the my-cool-theme-0.1.0/.git directory should not exist
|
||||
And the "my-cool-theme-0.1.0/.gitignore" file should not exist
|
||||
And the "my-cool-theme-0.1.0/Gemfile" file should not exist
|
||||
And the "my-cool-theme-0.1.0/my-cool-theme.gemspec" file should not exist
|
Loading…
Reference in New Issue