Sha256: 5c78678a1c3ea970abaf03573fb0f35f5def2a7113ecfc6c6a84404b6d4da6f1

Contents?: true

Size: 1.26 KB

Versions: 124

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

RSpec.describe :validate_length do
  link :validate_length, from: :ree_validator

  context "valid" do
    it {
      expect(validate_length([1], min: 1)).to eq(true)
      expect(validate_length([1], max: 1)).to eq(true)
      expect(validate_length([1], equal_to: 1)).to eq(true)
      expect(validate_length([1], not_equal_to: 0)).to eq(true)
    }
  end

  context "invalid" do
    it {
      expect {
        validate_length([1], min: 2)
      }.to raise_error(ReeValidator::ValidateLength::LenthErr) do |e|
        expect(e.message).to eq("length can not be less than 2")
      end
    }

    it {
      expect {
        validate_length([1, 2], max: 1)
      }.to raise_error(ReeValidator::ValidateLength::LenthErr) do |e|
        expect(e.message).to eq("length can not be more than 1")
      end
    }

    it {
      expect {
        validate_length([1, 2], equal_to: 1)
      }.to raise_error(ReeValidator::ValidateLength::LenthErr) do |e|
        expect(e.message).to eq("length should be equal to 1")
      end
    }

    it {
      expect {
        validate_length([1, 2], Class.new(StandardError).new("message"), not_equal_to: 2)
      }.to raise_error(StandardError) do |e|
        expect(e.message).to eq("message")
      end
    }
  end
end

Version data entries

124 entries across 124 versions & 1 rubygems

Version Path
ree_lib-1.0.64 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.63 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.62 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.61 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.60 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.59 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.58 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.57 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.56 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.55 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.54 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.53 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.52 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.51 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.50 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.49 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.48 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.47 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.46 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.45 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb