Sha256: b95133e7b0d4537fbd22b3d9cbc6ebe786e587d269894c087dfda4425f738c3a

Contents?: true

Size: 1.16 KB

Versions: 38

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

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')
      base_class.any_instance.should_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(:each) do
      base_instance.stub(:valid? => 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

38 entries across 38 versions & 1 rubygems

Version Path
metasploit-model-1.0.0.pre.rails.pre.4.0 spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.30.0 spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.30.0-java spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.29.2 spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.29.2-java spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.29.0 spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.29.0-java spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.28.0 spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.28.0-java spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.28.0.pre.engine.pre.requires spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.27.4 spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.27.4-java spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.27.3 spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.27.3-java spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.27.2 spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.27.2-java spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.27.1 spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.27.1-java spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.27.0 spec/lib/metasploit/model/base_spec.rb
metasploit-model-0.27.0-java spec/lib/metasploit/model/base_spec.rb