Sha256: 2e98860ff0919e62485fc30a6bfd7081de7fd8e31eb0a241bfe3f24b32087c3a

Contents?: true

Size: 1.18 KB

Versions: 22

Compression:

Stored size: 1.18 KB

Contents

RSpec.describe Metasploit::Model::Base do
  subject(:base_class) do
    Class.new(described_class)
  end

  it_should_behave_like 'Metasploit::Model::Translation',
                        metasploit_model_ancestor: Metasploit::Model::Base

  context '#initialize' do
    it 'should use public_send to set attributes' do
      attribute = :attribute
      value = double('Value')
      expect_any_instance_of(base_class).to receive(:public_send).with("#{attribute}=", value)

      base_class.new(attribute => value)
    end
  end

  context '#valid!' do
    subject(:valid!) do
      base_instance.valid!
    end

    let(:base_instance) do
      base_class.new
    end

    before(:example) do
      allow(base_instance).to receive(:valid?).and_return(valid)
    end

    context 'with valid' do
      let(:valid) do
        true
      end

      it 'should not raise error' do
        expect {
          valid!
        }.to_not raise_error
      end
    end

    context 'without valid' do
      let(:valid) do
        false
      end

      it 'should raise Metasploit::Model::Invalid' do
        expect {
          valid!
        }.to raise_error(Metasploit::Model::Invalid)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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