Sha256: ab870b5bca863ec3eb01ad99cc1a7cf7f20d6561a3a087471c5aa04c716131f2

Contents?: true

Size: 576 Bytes

Versions: 5

Compression:

Stored size: 576 Bytes

Contents

# frozen_string_literal: true

RSpec::Matchers.define :allow_file_content_type do |content_type, validator, message|
  match do |model|
    value = double('file', path: content_type, original_filename: content_type)
    allow_any_instance_of(model).to receive(:read_attribute_for_validation).and_return(value)
    allow(validator).to receive(:get_content_type).and_return(content_type)
    dummy = model.new
    validator.validate(dummy)
    if message.present?
      dummy.errors.full_messages.exclude?(message[:message])
    else
      dummy.errors.empty?
    end
  end
end

Version data entries

5 entries across 4 versions & 2 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/file_validators-3.0.0/spec/support/matchers/allow_content_type.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/file_validators-3.0.0/spec/support/matchers/allow_content_type.rb
file_validators-3.0.0 spec/support/matchers/allow_content_type.rb
file_validators-3.0.0.beta2 spec/support/matchers/allow_content_type.rb
file_validators-3.0.0.beta1 spec/support/matchers/allow_content_type.rb