Module: Metasploit::Model::Search::Association
- Extended by:
- ActiveSupport::Concern
- Included in:
- Metasploit::Model::Search
- Defined in:
- lib/metasploit/model/search/association.rb
Overview
Use search operators registered on an associated class using Metasploit::Model::Search::Attribute::ClassMethods#search_attribute, With::ClassMethods#search_with.
Searchable associations are declared explicitly so that associations cycles can be avoided and the search interface can be tuned for clarity and complexity.
Testing
ClassMethods#search_association calls can be tested with the 'search_association' shared example. First,
ensure the shared examples from metasploit-model
are required in your spec_helper.rb
:
# spec/spec_helper.rb
support_glob = Metasploit::Model::Engine.root.join('spec', 'support', '**', '*.rb')
Dir.glob(support_glob) do |path|
require path
end
In the spec for the Class
that called search_association
, use the 'search_association' shared example:
# spec/app/models/my_class_spec.rb
require 'spec_helper'
describe MyClass do
context 'search' do
context 'associations' do
it_should_be_like 'search_association', :association_name
end
end
end
Defined Under Namespace
Modules: ClassMethods