-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from jekyll/test-metadata
Add an integration test & test with github-pages gem
- Loading branch information
Showing
19 changed files
with
216 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.bundle | ||
Gemfile.lock | ||
pkg | ||
_site | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
source 'https://rubygems.org' | ||
gemspec | ||
|
||
group :test do | ||
gem "webmock" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/bin/bash | ||
bundle install | ||
bundle install --jobs=8 $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
curl_me() { | ||
(set -x; curl \ | ||
-H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-H "Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3" \ | ||
-H "Content-Type: application/json" \ | ||
-H "User-Agent: Octokit Ruby Gem 4.2.0" \ | ||
https://api.github.com${1} | gunzip > \ | ||
spec/webmock/api_get_${2}.json) | ||
} | ||
|
||
curl_me "/repos/jekyll/github-metadata?per_page=100" "repo" | ||
curl_me "/repos/jekyll/github-metadata/contributors?per_page=100" "repo_contributors" | ||
curl_me "/repos/jekyll/github-metadata/releases?per_page=100" "repo_releases" | ||
curl_me "/orgs/jekyll" "org" | ||
curl_me "/orgs/jekyll/public_members" "org_members" | ||
curl_me "/users/jekyll/repos?per_page=100&type=public" "owner_repos" | ||
curl_me "/repos/jekyll/github-metadata/pages" "repo_pages" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
require "spec_helper" | ||
require "jekyll" | ||
|
||
RSpec.describe("integration into a jekyll site") do | ||
SOURCE_DIR = Pathname.new(File.expand_path("../test-site", __FILE__)) | ||
DEST_DIR = Pathname.new(File.expand_path("../../tmp/test-site-build", __FILE__)) | ||
|
||
def dest_dir(*files) | ||
DEST_DIR.join(*files) | ||
end | ||
|
||
before(:all) do | ||
# Reset some stuffs | ||
ENV['NO_NETRC'] = "true" | ||
ENV['JEYKLL_GITHUB_TOKEN'] = "1234abc" | ||
|
||
# Stub Requests | ||
stub_api "/users/jekyll/repos?per_page=100&type=public", "owner_repos" | ||
stub_api "/repos/jekyll/github-metadata", "repo" | ||
stub_api "/repos/jekyll/github-metadata/releases?per_page=100", "repo_releases" | ||
stub_api "/orgs/jekyll", "org" | ||
stub_api "/orgs/jekyll/public_members?per_page=100", "org_members" | ||
stub_api "/repos/jekyll/github-metadata/pages", "repo_pages" | ||
stub_api "/repos/jekyll/github-metadata/contributors?per_page=100", "repo_contributors" | ||
|
||
# Run Jekyll | ||
Jekyll.logger.log_level = :error | ||
Jekyll::Commands::Build.process({ | ||
"source" => SOURCE_DIR.to_s, | ||
"destination" => DEST_DIR.to_s, | ||
"gems" => %w{jekyll-github-metadata}, | ||
"repository" => "jekyll/github-metadata" | ||
}) | ||
end | ||
subject { SafeYAML::load(dest_dir("rendered.txt").read) } | ||
|
||
{ | ||
"environment" => "development", | ||
"hostname" => "https://github.com", | ||
"pages_hostname" => "github.io", | ||
"api_url" => "https://api.github.com", | ||
"versions" => proc { | ||
begin | ||
require 'github-pages' | ||
GitHubPages.versions | ||
rescue LoadError | ||
{} | ||
end | ||
}.call, | ||
"public_repositories" => Regexp.new('"id"=>17261694, "name"=>"atom-jekyll"'), | ||
"organization_members" => Regexp.new('"login"=>"parkr", "id"=>237985'), | ||
"build_revision" => /[a-f0-9]{40}/, | ||
"project_title" => "github-metadata", | ||
"project_tagline" => ":octocat: `site.github`", | ||
"owner_name" => "jekyll", | ||
"owner_url" => "https://github.com/jekyll", | ||
"owner_gravatar_url" => "https://github.com/jekyll.png", | ||
"repository_url" => "https://github.com/jekyll/github-metadata", | ||
"repository_nwo" => "jekyll/github-metadata", | ||
"repository_name" => "github-metadata", | ||
"zip_url" => "https://github.com/jekyll/github-metadata/zipball/gh-pages", | ||
"tar_url" => "https://github.com/jekyll/github-metadata/tarball/gh-pages", | ||
"clone_url" => "https://github.com/jekyll/github-metadata.git", | ||
"releases_url" => "https://github.com/jekyll/github-metadata/releases", | ||
"issues_url" => "https://github.com/jekyll/github-metadata/issues", | ||
"wiki_url" => nil, # disabled | ||
"language" => "Ruby", | ||
"is_user_page" => false, | ||
"is_project_page" => true, | ||
"show_downloads" => true, | ||
"url" => "http://jekyll.github.io/github-metadata/", | ||
"contributors" => /"login"=>"parkr", "id"=>237985/, | ||
"releases" => /"tag_name"=>"v1.1.0"/, | ||
}.each do |key, value| | ||
it "contains the correct #{key}" do | ||
expect(subject).to have_key(key) | ||
if value.is_a? Regexp | ||
expect(subject[key].to_s).to match value | ||
else | ||
expect(subject[key]).to eql value | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
--- | ||
{{ site.github | jsonify }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"login":"jekyll","id":3083652,"url":"https://api.github.com/orgs/jekyll","repos_url":"https://api.github.com/orgs/jekyll/repos","events_url":"https://api.github.com/orgs/jekyll/events","hooks_url":"https://api.github.com/orgs/jekyll/hooks","issues_url":"https://api.github.com/orgs/jekyll/issues","members_url":"https://api.github.com/orgs/jekyll/members{/member}","public_members_url":"https://api.github.com/orgs/jekyll/public_members{/member}","avatar_url":"https://avatars.githubusercontent.com/u/3083652?v=3","description":"Jekyll is a blog-aware, static site generator in Ruby.","name":"Jekyll","company":null,"blog":"http://jekyllrb.com","location":"","email":"","public_repos":43,"public_gists":0,"followers":0,"following":0,"html_url":"https://github.com/jekyll","created_at":"2012-12-19T19:37:35Z","updated_at":"2016-01-26T20:22:17Z","type":"Organization","total_private_repos":3,"owned_private_repos":3,"private_gists":0,"disk_usage":110870,"collaborators":0,"billing_email":"[email protected]","plan":{"name":"bronze","space":976562499,"private_repos":10}} |
Oops, something went wrong.