Sha256: aed7c3a39e8298f4d28f00f7321036b1a9e01a06b007721215276d10db3b2d69

Contents?: true

Size: 443 Bytes

Versions: 5

Compression:

Stored size: 443 Bytes

Contents

# frozen_string_literal: true

RSpec::Matchers.define :allow_file_size do |size, validator, message|
  match do |model|
    value = double('file', size: size)
    allow_any_instance_of(model).to receive(:read_attribute_for_validation).and_return(value)
    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_file_size.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/file_validators-3.0.0/spec/support/matchers/allow_file_size.rb
file_validators-3.0.0 spec/support/matchers/allow_file_size.rb
file_validators-3.0.0.beta2 spec/support/matchers/allow_file_size.rb
file_validators-3.0.0.beta1 spec/support/matchers/allow_file_size.rb