Sha256: 489d450e933f0c59559bff91157833946b21c8fa87c0443bfd1e365011e2c7c1

Contents?: true

Size: 1.45 KB

Versions: 31

Compression:

Stored size: 1.45 KB

Contents

FactoryGirl.define do
  sequence :metasploit_model_module_class_payload_type, Metasploit::Model::Module::Class::PAYLOAD_TYPES.cycle

  trait :metasploit_model_module_class do
    #
    # Attributes
    #

    # Don't set full_name: before_validation will derive it from {Metasploit::Model::Module::Class#module_type} and
    # {Metasploit::Model::Module::Class::reference_name}.

    ignore do
      # derives from associations in instance, so don't set on instance
      module_type { generate :metasploit_model_module_type }

      # depends on module_type
      # ignored because model attribute will derived from reference_name, this factory attribute is used to generate
      # the correct reference_name.
      payload_type {
        # module_type is factory attribute, not model attribute
        if module_type == Metasploit::Model::Module::Type::PAYLOAD
          generate :metasploit_model_module_class_payload_type
        else
          nil
        end
      }

      #
      # Callback helpers
      #

      before_write_template {
        ->(module_class, evaluator) {}
      }
      write_template {
        ->(module_class, evaluator) {
          Metasploit::Model::Module::Class::Spec::Template.write(module_class: module_class)
        }
      }
    end

    after(:build) do |module_class, evaluator|
      instance_exec(evaluator, evaluator, &evaluator.before_write_template)
      instance_exec(evaluator, evaluator, &evaluator.write_template)
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
metasploit-model-0.28.0 spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.28.0-java spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.28.0.pre.engine.pre.requires spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.27.4 spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.27.4-java spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.27.3 spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.27.3-java spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.27.2 spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.27.2-java spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.27.1 spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.27.1-java spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.27.0 spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.27.0-java spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.27.0.pre.dep.pre.railties spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.26.1-java spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.26.1 spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.25.7 spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.25.7-java spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.25.6 spec/factories/metasploit/model/module/classes.rb
metasploit-model-0.25.6-java spec/factories/metasploit/model/module/classes.rb