Sha256: 06f8fcabe8c78e5a361ea533482ad9d251eee10912029fe8d4f1e2be9dc4119f

Contents?: true

Size: 545 Bytes

Versions: 6

Compression:

Stored size: 545 Bytes

Contents

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

6 entries across 6 versions & 1 rubygems

Version Path
file_validators-2.3.0 spec/support/matchers/allow_content_type.rb
file_validators-2.2.0.beta1 spec/support/matchers/allow_content_type.rb
file_validators-2.1.0 spec/support/matchers/allow_content_type.rb
file_validators-2.0.2 spec/support/matchers/allow_content_type.rb
file_validators-2.0.1 spec/support/matchers/allow_content_type.rb
file_validators-2.0.0 spec/support/matchers/allow_content_type.rb