Sha256: bceb194bd002e6cbaa1a9159a5c16d2ac25a2c15e686b9ef726ffbfc23e90706

Contents?: true

Size: 1.72 KB

Versions: 8

Compression:

Stored size: 1.72 KB

Contents

RSpec.describe Metasploit::Model::Search::Operation::Date, type: :model do
  context 'validation' do
    context 'value' do
      before(:each) do
        operation.valid?
      end

      let(:error) do
        I18n.translate('metasploit.model.errors.models.metasploit/model/search/operation/date.attributes.value.unparseable_date')
      end

      let(:errors) do
        operation.errors[:value]
      end

      let(:operation) do
        described_class.new(:value => value)
      end

      context 'with Date' do
        let(:value) do
          Date.today
        end

        it 'should not record error' do
          expect(errors).not_to include(error)
        end
      end

      context 'without Date' do
        let(:value) do
          'not a date'
        end

        it 'should record error' do
          expect(errors).to include(error)
        end
      end
    end
  end

  context '#value' do
    subject(:value) do
      operation.value
    end

    let(:operation) do
      described_class.new(:value => formatted_value)
    end

    context 'with Date' do
      let(:formatted_value) do
        Date.today
      end

      it 'should be passed in Date' do
        expect(value).to eq(formatted_value)
      end
    end

    context 'without Date' do
      context 'with parseable' do
        let(:date) do
          Date.today
        end

        let(:formatted_value) do
          date.to_s
        end

        it 'should be parsed Date' do
          expect(value).to eq(date)
        end
      end

      context 'without parseable' do
        let(:formatted_value) do
          'not a date'
        end

        it 'should pass through value' do
          expect(value).to be formatted_value
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
metasploit-model-1.0.2 spec/app/models/metasploit/model/search/operation/date_spec.rb
metasploit-model-1.0.1 spec/app/models/metasploit/model/search/operation/date_spec.rb
metasploit-model-1.0.0 spec/app/models/metasploit/model/search/operation/date_spec.rb
metasploit-model-0.30.2 spec/app/models/metasploit/model/search/operation/date_spec.rb
metasploit-model-0.30.2-java spec/app/models/metasploit/model/search/operation/date_spec.rb
metasploit-model-0.30.1 spec/app/models/metasploit/model/search/operation/date_spec.rb
metasploit-model-0.30.1-java spec/app/models/metasploit/model/search/operation/date_spec.rb
metasploit-model-0.30.1.pre.rspec.pre.3.pre.1 spec/app/models/metasploit/model/search/operation/date_spec.rb