summaryrefslogtreecommitdiff
path: root/spec/unit/core
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-05-02 18:24:10 -0600
committermo khan <mo.khan@gmail.com>2020-05-02 18:24:10 -0600
commitaad1f8c405cea3f54734246ecfa9e07ad6e42a39 (patch)
treef1e5adff76d7102be9ad855323de82755b03f537 /spec/unit/core
parentb68c2b23b28bf88a22befc07bb439dccc4540c27 (diff)
Stick to a single text similarity algorithm for now
Diffstat (limited to 'spec/unit/core')
-rw-r--r--spec/unit/core/content_spec.rb20
-rw-r--r--spec/unit/core/guess_spec.rb11
2 files changed, 7 insertions, 24 deletions
diff --git a/spec/unit/core/content_spec.rb b/spec/unit/core/content_spec.rb
index 4b01dc4..7a633fc 100644
--- a/spec/unit/core/content_spec.rb
+++ b/spec/unit/core/content_spec.rb
@@ -17,19 +17,13 @@ RSpec.describe Spandx::Core::Content do
let(:mit) { described_class.new(license_file('MIT')) }
let(:lgpl) { described_class.new(license_file('LGPL-2.0-only')) }
- [
- :dice_coefficient,
- :jaro_winkler,
- #:levenshtein,
- ].each do |algorithm|
- specify { expect(subject).to be_similar(mit, algorithm: algorithm) }
- specify { expect(subject).not_to be_similar(lgpl, algorithm: algorithm) }
- specify { expect(subject).to be_similar(subject, algorithm: algorithm) }
- specify { expect(text('hello world')).to be_similar(text('hello world'), algorithm: algorithm) }
- specify { expect(text('hello world')).not_to be_similar(text('goodbye world'), algorithm: algorithm) }
- specify { expect(text('hello world')).not_to be_similar(text('goodbye universe'), algorithm: algorithm) }
- specify { expect(text('a b c')).not_to be_similar(text('b c d'), algorithm: algorithm) }
- end
+ specify { expect(subject).to be_similar(mit) }
+ specify { expect(subject).not_to be_similar(lgpl) }
+ specify { expect(subject).to be_similar(subject) }
+ specify { expect(text('hello world')).to be_similar(text('hello world')) }
+ specify { expect(text('hello world')).not_to be_similar(text('goodbye world')) }
+ specify { expect(text('hello world')).not_to be_similar(text('goodbye universe')) }
+ specify { expect(text('a b c')).not_to be_similar(text('b c d')) }
end
describe '#similarity_score' do
diff --git a/spec/unit/core/guess_spec.rb b/spec/unit/core/guess_spec.rb
index 2e267d4..4d5364d 100644
--- a/spec/unit/core/guess_spec.rb
+++ b/spec/unit/core/guess_spec.rb
@@ -47,17 +47,6 @@ RSpec.describe Spandx::Core::Guess do
let!(:content) { IO.read('LICENSE.txt') }
specify { expect(subject.license_for(content)&.id).to eql('MIT') }
- specify { expect(subject.license_for(content, algorithm: :dice_coefficient)&.id).to eql('MIT') }
- specify { expect(subject.license_for(content, algorithm: :levenshtein)&.id).to eql('MIT') }
- specify { expect(subject.license_for(content, algorithm: :jaro_winkler)&.id).to eql('MIT') }
-
- %i[dice_coefficient levenshtein jaro_winkler].each do |algorithm|
- pending algorithm do
- expect do
- subject.license_for(content, algorithm: algorithm)
- end.to perform_under(0.01).sample(10)
- end
- end
end
end
end