Sha256: 54b738cc0ea5bacb2f9501fc06d9e1490ab56a3d1c6c6d615a0cf2339992771e

Contents?: true

Size: 1.72 KB

Versions: 22

Compression:

Stored size: 1.72 KB

Contents

RSpec.describe Metasploit::Model::Search::Operation::Date, type: :model do
  context 'validation' do
    context 'value' do
      before(:example) 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

22 entries across 22 versions & 1 rubygems

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