spec/paperclip/validators_spec.rb in kt-paperclip-4.4.0 vs spec/paperclip/validators_spec.rb in kt-paperclip-5.4.0

- old
+ new

@@ -1,10 +1,11 @@ require 'spec_helper' describe Paperclip::Validators do context "using the helper" do before do + rebuild_class Dummy.validates_attachment :avatar, presence: true, content_type: { content_type: "image/jpeg" }, size: { in: 0..10240 } end it "adds the attachment_presence validator to the class" do assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :attachment_presence } @@ -28,12 +29,12 @@ context 'using the helper with array of validations' do before do rebuild_class Dummy.validates_attachment :avatar, file_type_ignorance: true, file_name: [ - { matches: /\A.*\.jpe?g\Z/i, message: :invalid_extension }, - { matches: /\A.{,8}\..+\Z/i, message: [:too_long, count: 8] }, + { matches: /\A.*\.jpe?g\z/i, message: :invalid_extension }, + { matches: /\A.{,8}\..+\z/i, message: [:too_long, count: 8] }, ] end it 'adds the attachment_file_name validator to the class' do assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :attachment_file_name } @@ -62,15 +63,14 @@ dummy = Dummy.new(avatar: File.new(fixture_file('spaced file.jpg'))) expect(dummy.errors.keys).to match_array [:avatar, :avatar_file_name] assert_raises(RuntimeError){ dummy.valid? } end - it 'allows you to attach a file that does not violates these validations' do + it 'allows you to attach a file that does not violate these validations' do dummy = Dummy.new(avatar: File.new(fixture_file('rotated.jpg'))) - expect(dummy.errors.keys).to match_array [] + expect(dummy.errors.full_messages).to be_empty assert dummy.valid? end - end context "using the helper with a conditional" do before do rebuild_class