spec/licensee/license_spec.rb in licensee-9.5.0 vs spec/licensee/license_spec.rb in licensee-9.6.0

- old
+ new

@@ -367,10 +367,44 @@ it 'matches' do expect(text).to match(license.title_regex) end end + + if variation == :title + context 'version notation variations' do + context "with 'version x.x'" do + let(:text) do + license_variation.sub(/v?(\d+\.\d+)/i, 'version \1') + end + + it 'matches' do + expect(text).to match(license.title_regex) + end + end + + context "with ', version x.x'" do + let(:text) do + license_variation.sub(/ v?(\d+\.\d+)/i, ', version \1') + end + + it 'matches' do + expect(text).to match(license.title_regex) + end + end + + context "with 'vx.x'" do + let(:text) do + license_variation.sub(/(?:version)? (\d+\.\d+)/i, ' v\1') + end + + it 'matches' do + expect(text).to match(license.title_regex) + end + end + end + end end end end end @@ -382,9 +416,46 @@ expect(text).to match(license.title_regex) end it 'finds by title' do expect(described_class.find_by_title(text)).to eql(license) + end + end + end + + context 'source regex' do + Licensee::License.all(hidden: true, psuedo: false).each do |license| + context "the #{license.title} license" do + let(:source) { URI.parse(license.source) } + + %w[http https].each do |scheme| + context "with a #{scheme}:// scheme" do + before { source.scheme = scheme } + + ['www.', ''].each do |prefix| + context "with '#{prefix}' before the host" do + before do + source.host = "#{prefix}#{source.host.sub(/\Awww\./, '')}" + end + + ['.html', '.htm', '.txt', ''].each do |suffix| + context "with '#{suffix}' after the path" do + before do + next if license.key == 'wtfpl' + regex = /#{Licensee::License::SOURCE_SUFFIX}\z/ + source.path = source.path.sub(regex, '') + source.path = "#{source.path}#{suffix}" + end + + it 'matches' do + expect(source.to_s).to match(license.source_regex) + end + end + end + end + end + end + end end end end end