mirror of
https://github.com/github/choosealicense.com
synced 2024-12-22 04:40:09 +01:00
Test examples provided in 'using:' would be detected by licensee
This commit is contained in:
parent
7c25006fca
commit
7649067151
1
Gemfile
1
Gemfile
@ -16,6 +16,7 @@ end
|
|||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'html-proofer', '~> 3.0'
|
gem 'html-proofer', '~> 3.0'
|
||||||
|
gem 'licensee'
|
||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
gem 'rspec'
|
gem 'rspec'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'licensee'
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'license meta' do
|
describe 'license meta' do
|
||||||
@ -19,6 +20,8 @@ describe 'license meta' do
|
|||||||
expect(missing).to be_empty
|
expect(missing).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
examples = raw_fields['using'] || []
|
||||||
|
|
||||||
it 'using contains 3 examples' do
|
it 'using contains 3 examples' do
|
||||||
legacy = [
|
legacy = [
|
||||||
'afl-3.0',
|
'afl-3.0',
|
||||||
@ -43,9 +46,33 @@ describe 'license meta' do
|
|||||||
'zlib'
|
'zlib'
|
||||||
]
|
]
|
||||||
skip 'added before 3 using examples required' if legacy.include?(license['slug'])
|
skip 'added before 3 using examples required' if legacy.include?(license['slug'])
|
||||||
examples = raw_fields['using'] || []
|
|
||||||
expect(examples.length).to eq(3)
|
expect(examples.length).to eq(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'licensee detects using examples' do
|
||||||
|
module Licensee
|
||||||
|
class License
|
||||||
|
class << self
|
||||||
|
def license_dir
|
||||||
|
dir = ::File.dirname(__FILE__)
|
||||||
|
::File.expand_path '../_licenses', dir
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
examples.each do |example|
|
||||||
|
example_url = example.values[0]
|
||||||
|
if example_url.index('https://github.com/') == 0
|
||||||
|
example_url.gsub!(%r{\Ahttps://github.com/(\w+/\w+)/blob/(\w+/\S+)\z}, 'https://raw.githubusercontent.com/\1/\2')
|
||||||
|
end
|
||||||
|
content = open(example_url).read
|
||||||
|
detected = Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE').license
|
||||||
|
it example_url do
|
||||||
|
expect(detected.key).to eq(license['slug'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'jekyll'
|
require 'jekyll'
|
||||||
require 'open-uri'
|
|
||||||
require 'json'
|
require 'json'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
require 'nokogiri'
|
require 'nokogiri'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user