* Update rubocop-todo.yml with new violations * Fix Layout/EmptyLine* rules * Fix Layout/Indentation* rules * Fix remaining Layout/* rules * Fix Lint/DuplicateMethods by removing unused accessor * Fix Lint/IneffectiveAccessModifier * Fix Lint/MissingCopEnableDirective * Re-run rubocop auto gen config * Fix Layout/RescueEnsureAlignment * Fix Naming/* rules * Fix some RSpec/* rules * Fix typos * Fix RSpec/LetBeforeExamples * Series should only be an attr_writer, not an attr_accessor * Fix RSpec/InstanceVariable * Fix RSpec/InstanceVariable * Fix RSpec/RepeatedDescription and RSpec/RepeatedExample * Fix Style/ClassAndModuleChildren * Fix Style/ConditionalAssignment * Fix some Style/* rules * Trigger Travis CI build because failing tests are not failing locally * Revert "Fix Style/ClassAndModuleChildren" This reverts commit 1686801d8a1516ba1894f79e24401a20dea65f99.
29 lines
1.4 KiB
Ruby
29 lines
1.4 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe UserSimilarity, vcr: {} do
|
|
let(:user) { create(:user, summary: "I like ruby and JavaScript and Go") }
|
|
let(:similar_user) { create(:user, summary: "I like JavaScript and Go") }
|
|
let(:dissimilar_user) { create(:user, summary: "I like Haskell and functional programming") }
|
|
|
|
it "returns similar user" do
|
|
similar_score = UserSimilarity.new(user, similar_user).score
|
|
dissimilar_score = UserSimilarity.new(user, dissimilar_user).score
|
|
expect(similar_score).to be > dissimilar_score
|
|
end
|
|
|
|
it "Is not affected by stop words" do
|
|
user.summary = user.summary + " throughout yourself can indeed otherwise thru yourselves through yours by inc others"
|
|
dissimilar_user.summary = dissimilar_user.summary + " throughout yourself can indeed otherwise thru yourselves through yours by inc others"
|
|
similar_score = UserSimilarity.new(user, similar_user).score
|
|
dissimilar_score = UserSimilarity.new(user, dissimilar_user).score
|
|
expect(similar_score).to be > dissimilar_score
|
|
end
|
|
|
|
it "Is affected by non-stop words" do
|
|
user.mentee_description = "Hot dogs languages punk rock hello"
|
|
dissimilar_user.mentor_description = "Hot dogs languages punk rock hello "
|
|
similar_score = UserSimilarity.new(user, similar_user).score
|
|
dissimilar_score = UserSimilarity.new(user, dissimilar_user).score
|
|
expect(similar_score).to be < dissimilar_score
|
|
end
|
|
end
|