Merge pull request #5384 from ashmaroli/theme-gem-feature

Merge pull request 5384
This commit is contained in:
jekyllbot 2016-11-28 21:38:16 -08:00 committed by GitHub
commit a2367900fc
3 changed files with 86 additions and 0 deletions

View File

@ -156,6 +156,32 @@ 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", ".", "--verbose")
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")
File.new("assets/blank.scss", "w")
end
#
When(%r!^I change "(.*)" to contain "(.*)"$!) do |file, text|
File.open(file, "a") do |f|
f.write(text)
@ -265,6 +291,27 @@ end
#
Then(%r!^I should get an updated git index$!) do
index = %w(
.gitignore
Gemfile
LICENSE.txt
README.md
_includes/blank.html
_layouts/default.html
_layouts/page.html
_layouts/post.html
_sass/blank.scss
assets/blank.scss
my-cool-theme.gemspec
)
index.each do |file|
expect(jekyll_run_output).to match file
end
end
#
Then(%r!^I should get a zero exit(?:\-| )status$!) do
step %(I should see "EXIT STATUS: 0" in the build output)
end

View File

@ -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")

View File

@ -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 the my-cool-theme directory should exist
When I decide to build the theme gem
Then the "_includes/blank.html" file should exist
Then the "_sass/blank.scss" file should exist
Then the "assets/blank.scss" file should exist
When I run git add .
Then I should get an updated git index
When I run gem build my-cool-theme.gemspec
Then the "./my-cool-theme-0.1.0.gem" file should exist
When I run gem unpack my-cool-theme-0.1.0.gem
Then 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/assets/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