1
0
mirror of https://github.com/github/choosealicense.com synced 2024-07-03 00:49:11 +02:00

Merge pull request #252 from github/tests

Add additional tests
This commit is contained in:
Ben Balter 2015-03-07 13:57:04 -05:00
commit 46de1939b5
19 changed files with 129 additions and 147 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ assets/vendor/zeroclipboard/test
assets/vendor/selectivizr/tests
assets/vendor/qtip2/basic
/vendor
Gemfile.lock

View File

@ -18,3 +18,6 @@ notifications:
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
sudo: false
cache: bundler

View File

@ -6,4 +6,5 @@ gem "github-pages"
group :test do
gem "html-proofer"
gem "rake"
gem "rspec"
end

View File

@ -1,132 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
RedCloth (4.2.9)
activesupport (4.1.5)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
blankslate (2.1.2.4)
celluloid (0.16.0)
timers (~> 4.0.0)
classifier-reborn (2.0.1)
fast-stemmer (~> 1.0)
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.8.0)
colorator (0.1)
colored (1.2)
ethon (0.7.1)
ffi (>= 1.3.0)
execjs (2.2.1)
fast-stemmer (1.0.2)
ffi (1.9.3)
gemoji (2.1.0)
github-pages (24)
RedCloth (= 4.2.9)
jekyll (= 2.3.0)
jekyll-coffeescript (= 1.0.0)
jekyll-mentions (= 0.1.3)
jekyll-redirect-from (= 0.6.0)
jekyll-sass-converter (= 1.2.0)
jekyll-sitemap (= 0.5.1)
jemoji (= 0.3.0)
kramdown (= 1.3.1)
liquid (= 2.6.1)
maruku (= 0.7.0)
pygments.rb (= 0.6.0)
rdiscount (= 2.1.7)
redcarpet (= 3.1.2)
hitimes (1.2.2)
html-pipeline (1.9.0)
activesupport (>= 2)
nokogiri (~> 1.4)
html-proofer (1.3.3)
colored (~> 1.2)
mercenary (~> 0.3.2)
nokogiri (~> 1.5)
typhoeus (~> 0.6.7)
yell (~> 2.0)
i18n (0.6.11)
jekyll (2.3.0)
classifier-reborn (~> 2.0)
colorator (~> 0.1)
jekyll-coffeescript (~> 1.0)
jekyll-gist (~> 1.0)
jekyll-paginate (~> 1.0)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 1.1)
kramdown (~> 1.3)
liquid (~> 2.6.1)
mercenary (~> 0.3.3)
pygments.rb (~> 0.6.0)
redcarpet (~> 3.1)
safe_yaml (~> 1.0)
toml (~> 0.1.0)
jekyll-coffeescript (1.0.0)
coffee-script (~> 2.2)
jekyll-gist (1.1.0)
jekyll-mentions (0.1.3)
html-pipeline (~> 1.9.0)
jekyll (~> 2.0)
jekyll-paginate (1.0.0)
jekyll-redirect-from (0.6.0)
jekyll (~> 2.0)
jekyll-sass-converter (1.2.0)
sass (~> 3.2)
jekyll-sitemap (0.5.1)
jekyll-watch (1.1.0)
listen (~> 2.7)
jemoji (0.3.0)
gemoji (~> 2.0)
html-pipeline (~> 1.9)
jekyll (~> 2.0)
json (1.8.1)
kramdown (1.3.1)
liquid (2.6.1)
listen (2.7.9)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
maruku (0.7.0)
mercenary (0.3.4)
mini_portile (0.6.0)
minitest (5.4.1)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
parslet (1.5.0)
blankslate (~> 2.0)
posix-spawn (0.3.9)
pygments.rb (0.6.0)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rake (10.3.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rdiscount (2.1.7)
redcarpet (3.1.2)
safe_yaml (1.0.3)
sass (3.4.3)
thread_safe (0.3.4)
timers (4.0.0)
hitimes
toml (0.1.1)
parslet (~> 1.5.0)
typhoeus (0.6.9)
ethon (>= 0.7.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
yajl-ruby (1.1.0)
yell (2.0.4)
PLATFORMS
ruby
DEPENDENCIES
github-pages
html-proofer
rake

View File

@ -1,7 +1,14 @@
require "html/proofer"
require 'rspec/core/rake_task'
desc "Run specs"
RSpec::Core::RakeTask.new do |t|
t.pattern = 'spec/**/*_spec.rb'
t.rspec_opts = ["--order", "rand", "--color"]
end
task :test do
sh "bundle exec jekyll build --trace"
# ignore href="#" for the "Copy to clipboard" button
HTML::Proofer.new("./_site").run
HTML::Proofer.new("./_site", :check_html => true).run
Rake::Task["spec"].invoke
end

View File

@ -1,5 +1,5 @@
---
title: GNU Affero GPL v3.0
title: GNU Affero General Public License v3.0
category: GPL
tab-slug: agpl-v3
hide-from-license-list: true

View File

@ -18,7 +18,7 @@ source: http://www.apache.org/licenses/LICENSE-2.0.html
required:
- include-copyright
- document-changes
permitted:
- commercial-use
- modifications

View File

@ -1,6 +1,6 @@
---
layout: license
title: Simplified BSD
title: BSD 2-clause "Simplified" License
category: BSD
tab-slug: bsd
hide-from-license-list: true

View File

@ -1,6 +1,6 @@
---
layout: license
title: New BSD
title: BSD 3-clause "New" or "Revised" License
category: BSD
tab-slug: bsd-3
hide-from-license-list: true

View File

@ -1,6 +1,6 @@
---
layout: license
title: CC0 1.0 Universal
title: Creative Commons Zero v1.0 Universal
category: Public Domain Dedication
tab-slug: cc0
permalink: /licenses/cc0/
@ -25,6 +25,8 @@ permitted:
forbidden:
- no-liability
required: []
---
CC0 1.0 Universal
@ -141,4 +143,4 @@ Affirmer's express Statement of Purpose.
CC0 or use of the Work.
For more information, please see
<http://creativecommons.org/publicdomain/zero/1.0/>
<http://creativecommons.org/publicdomain/zero/1.0/>

View File

@ -1,6 +1,6 @@
---
layout: license
title: Eclipse Public License v1.0
title: Eclipse Public License 1.0
category: Eclipse
redirect_from: /licenses/eclipse/
permalink: /licenses/epl-1.0/

View File

@ -1,5 +1,5 @@
---
title: GNU GPL v2.0
title: GNU General Public License v2.0
category: GPL
tab-slug: gpl-v2
hide-from-license-list: false

View File

@ -1,5 +1,5 @@
---
title: GNU GPL v3.0
title: GNU General Public License v3.0
category: GPL
tab-slug: gpl-v3
hide-from-license-list: true

View File

@ -1,6 +1,6 @@
---
layout: license
title: ISC license
title: ISC License
permalink: /licenses/isc/
source: http://opensource.org/licenses/isc-license
category: BSD

View File

@ -1,6 +1,6 @@
---
layout: license
title: GNU LGPL v2.1
title: GNU Lesser General Public License v2.1
category: LGPL
tab-slug: lgpl-v2_1
redirect_from: /licenses/lgpl-v2.1/

View File

@ -1,6 +1,6 @@
---
layout: license
title: GNU LGPL v3.0
title: GNU Lesser General Public License v3.0
category: LGPL
tab-slug: lgpl-v3
hide-from-license-list: true

View File

@ -1,6 +1,6 @@
---
layout: license
title: Public Domain (Unlicense)
title: The Unlicense
category: Public Domain Dedication
tab-slug: unlicense
permalink: /licenses/unlicense/
@ -25,6 +25,8 @@ permitted:
forbidden:
- no-liability
required: []
---
This is free and unencumbered software released into the public domain.

51
spec/license_spec.rb Normal file
View File

@ -0,0 +1,51 @@
require 'spec_helper'
licenses.each do |license|
describe "The #{license["title"]} license" do
it "should have a title" do
expect(license["title"]).to_not be_nil
end
it "should have a description" do
expect(license["description"]).to_not be_nil
end
describe "SPDX compliance" do
# "No license" isn't really a license, so no need to test
unless license["id"] == "no-license"
it "#{license["id"]} should be a valid SPDX ID" do
expect(find_spdx(license["id"])).to_not be_nil
end
it "should be the proper SPDX name" do
spdx = find_spdx(license["id"])
expect(spdx[1]["name"].gsub(/ only$/,"")).to eql(license["title"])
end
# CC0 and Unlicense are not OSI approved, but that's okay
unless license["id"] == "unlicense" || license["id"] == "cc0-1.0"
it "should be OSI approved" do
spdx = find_spdx(license["id"])
expect(spdx[1]["osiApproved"]).to eql(true)
end
end
end
end
["permitted", "required", "forbidden"].each do |group|
describe "#{group} properties" do
it "should list the properties" do
expect(license[group]).to_not be_nil
end
license[group].to_a.each do |tag|
describe "#{tag} tag" do
it "should be a valid tag" do
expect(rule?(tag,group)).to be(true)
end
end
end
end
end
end
end

47
spec/spec_helper.rb Normal file
View File

@ -0,0 +1,47 @@
require 'jekyll'
require 'open-uri'
require 'json'
def config_file
File.expand_path "./_config.yml", source
end
def source
File.expand_path("../", File.dirname(__FILE__))
end
def config
config = Jekyll::Configuration.new.read_config_file config_file
config = Jekyll::Utils.deep_merge_hashes(config, {:source => source})
Jekyll::Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, config)
end
def licenses
site.collections["licenses"].docs.map { |l| l.data.merge("id" => l.basename(".txt")) }
end
def site
$site ||= begin
site = Jekyll::Site.new(config)
site.reset
site.read
site
end
end
def rules
site.data["rules"]
end
def rule?(tag, group)
rules[group].any? { |r| r["tag"] == tag }
end
def spdx_list
url = "https://raw.githubusercontent.com/sindresorhus/spdx-license-list/master/spdx.json"
$spdx ||= JSON.parse(open(url).read)
end
def find_spdx(license)
spdx_list.find { |name, properties| name.downcase == license }
end