Sha256: 042c64c93d013f4d3d8edc0b71884a293244323da64ca1838be3ff42bee5910b

Contents?: true

Size: 1.78 KB

Versions: 30

Compression:

Stored size: 1.78 KB

Contents

RSpec.describe Metasploit::Model::Translation do
  let(:base_class) do
    described_class = self.described_class

    Class.new do
      include described_class
    end
  end

  context 'lookup_ancestors' do
    subject(:lookup_ancestors) do
      base_class.lookup_ancestors
    end

    let(:base_class) do
      described_class = self.described_class

      Class.new(named_class) do
        include described_class
      end
    end

    let(:named_class) do
      named_module = self.named_module
      unnamed_class = self.unnamed_class

      Class.new(unnamed_class) do
        include named_module

        def self.model_name

        end
      end
    end

    let(:named_module) do
      Module.new do
        def self.model_name

        end
      end
    end

    let(:unnamed_class) do
      unnamed_module = self.unnamed_module

      Class.new do
        include unnamed_module
      end
    end

    let(:unnamed_module) do
      Module.new
    end

    it 'should have named and unnamed ancestors' do
      expect(base_class.ancestors).to include(named_class)
      expect(base_class.ancestors).to include(named_module)
      expect(base_class.ancestors).to include(unnamed_class)
      expect(base_class.ancestors).to include(unnamed_module)
    end

    it 'should return all ancestors that respond to model_name' do
      expect(lookup_ancestors).to include(base_class)
      expect(lookup_ancestors).to include(named_class)
      expect(lookup_ancestors).to include(named_module)
    end

    it 'should not return ancestors that do not respond to model_name' do
      expect(lookup_ancestors).not_to include(unnamed_class)
      expect(lookup_ancestors).not_to include(unnamed_module)
    end
  end

  context 'i18n_scope' do
    subject(:i18n_scope) do
      'metasploit.model'
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
metasploit-model-5.0.2 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-5.0.1 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-5.0.0 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-4.0.6 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-4.0.5 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-4.0.4 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-4.0.3 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-4.0.2 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-4.0.1 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-4.0.0 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-3.1.4 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-3.1.3 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-3.1.2 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-3.1.1 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-3.1.0 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-3.0.0 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-2.0.4 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-2.0.3 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-2.0.2 spec/lib/metasploit/model/translation_spec.rb
metasploit-model-2.0.1 spec/lib/metasploit/model/translation_spec.rb