require'spec_helper'require'rubocop'require'rubocop/rspec/support'require_relative'../../../rubocop/cop/polymorphic_associations'describeRuboCop::Cop::PolymorphicAssociationsdoincludeCopHelpersubject(:cop){described_class.new}context'inside the app/models directory'doit'registers an offense when polymorphic: true is used'doallow(cop).toreceive(:in_model?).and_return(true)inspect_source(cop,'belongs_to :foo, polymorphic: true')aggregate_failuresdoexpect(cop.offenses.size).toeq(1)expect(cop.offenses.map(&:line)).toeq([1])endendendcontext'outside the app/models directory'doit'does nothing'doallow(cop).toreceive(:in_model?).and_return(false)inspect_source(cop,'belongs_to :foo, polymorphic: true')expect(cop.offenses).tobe_emptyendendend