Sha256: a202d9d9f85f3d65f790e53f5e7926661447aefda0f2c965315baaa57b3d2347

Contents?: true

Size: 1.2 KB

Versions: 51

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe MetasploitDataModels::Match::Child do
  let(:extending_class) {
    # capture as local for Class.new block scope
    described_class = self.described_class

    Class.new(Metasploit::Model::Base) {
      extend described_class

      #
      # Attributes
      #

      # @!attribute value
      #   @return [String]
      attr_accessor :value
    }
  }

  before(:each) do
    stub_const('ExtendingClass', extending_class)
    stub_const('ExtendingClass::REGEXP', /\d+-\d+/)
  end

  context '#match' do
    subject(:match) {
      extending_class.match(formatted_value)
    }

    context 'formatted value' do
      context 'with matching' do
        let(:formatted_value) {
          '1-2'
        }

        it 'returns instance of extending class' do
          expect(match).to be_an extending_class
        end

        context '#value' do
          subject(:value) {
            match.value
          }

          it 'is set to formatted value' do
            expect(value).to eq(formatted_value)
          end
        end
      end

      context 'without matching' do
        let(:formatted_value) do
          '1,2-3'
        end

        it { should be_nil }
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
metasploit_data_models-0.24.5 spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.24.1 spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-1.0.0.pre.rails.pre.4.0b spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-1.0.0.pre.rails.pre.4.0a spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.24.0 spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.23.3.pre.autoload spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.23.2 spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.23.2-java spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.23.1 spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.23.1-java spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.23.0 spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.23.0-java spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.22.8 spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.22.8-java spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.22.7 spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.22.7-java spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.22.6 spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.22.6-java spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.22.5 spec/lib/metasploit_data_models/match/child_spec.rb
metasploit_data_models-0.22.5-java spec/lib/metasploit_data_models/match/child_spec.rb