Sha256: 058b8173e2bee811a125895302f03cbf56e5f19a541ea122538a9a1c4cd72c52

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require "rails_helper"

module Archangel
  RSpec.describe Asset, type: :model do
    context "with validations" do
      it { is_expected.to validate_presence_of(:file) }
      it { is_expected.to validate_presence_of(:file_name) }

      it { is_expected.to allow_value("success.js").for(:file_name) }
      it { is_expected.to allow_value("success.jpg").for(:file_name) }
      it { is_expected.to allow_value("filename.extension").for(:file_name) }
      it { is_expected.to allow_value("foo-bar.jpg").for(:file_name) }
      it { is_expected.to allow_value("foo_bar.jpg").for(:file_name) }
      it { is_expected.to allow_value("18.jpg").for(:file_name) }

      it { is_expected.not_to allow_value("error").for(:file_name) }
      it { is_expected.not_to allow_value("error.j").for(:file_name) }
      it { is_expected.not_to allow_value("with.dot.jpg").for(:file_name) }
      it { is_expected.not_to allow_value("with space.jpg").for(:file_name) }
      it { is_expected.not_to allow_value("with/slash.jpg").for(:file_name) }
      it { is_expected.not_to allow_value("with/numbers.18").for(:file_name) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.4.0 spec/unit/models/archangel/asset_spec.rb