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.124 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.123 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.122 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.121 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.120 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.119 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.118 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.117 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.116 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.115 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.114 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.113 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.112 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.111 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.110 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.109 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.108 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.107 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.106 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb
ree_lib-1.0.105 lib/ree_lib/packages/ree_validator/spec/ree_validator/functions/validate_length_spec.rb