Sha256: c7f171f57afb2706aadd95cc87475bc4c6c70321b990aa08ac225463457d4189

Contents?: true

Size: 1.07 KB

Versions: 21

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Zizia::CsvFormatValidator do
  subject(:validator)  { described_class.new }
  let(:invalid_parser) { Zizia::CsvParser.new(file: invalid_file) }
  let(:invalid_file)   { File.open('spec/fixtures/bad_example.csv') }

  it_behaves_like 'a Zizia::Validator' do
    let(:valid_parser)   { Zizia::CsvParser.new(file: valid_file) }
    let(:valid_file)     { File.open('spec/fixtures/example.csv') }
  end

  define :a_validator_error do
    match do |error|
      return false unless error.respond_to?(:validator)

      if fields
        return false if fields[:validator] && error.validator != fields[:validator]
        return false if fields[:name]      && error.name      != fields[:name]
      end

      true
    end

    chain :with, :fields
  end

  describe '#validate' do
    it 'returns a Validator::Error' do
      expect(validator.validate(parser: invalid_parser))
        .to contain_exactly a_validator_error
        .with(validator: validator.class,
              name:      CSV::MalformedCSVError)
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
zizia-6.0.0 spec/zizia/csv_format_validator_spec.rb
zizia-5.5.0 spec/zizia/csv_format_validator_spec.rb
zizia-5.4.0 spec/zizia/csv_format_validator_spec.rb
zizia-5.3.0 spec/zizia/csv_format_validator_spec.rb
zizia-5.2.0 spec/zizia/csv_format_validator_spec.rb
zizia-5.1.0 spec/zizia/csv_format_validator_spec.rb
zizia-5.0.1 spec/zizia/csv_format_validator_spec.rb
zizia-5.0.0 spec/zizia/csv_format_validator_spec.rb
zizia-4.6.0.alpha.01 spec/zizia/csv_format_validator_spec.rb
zizia-4.5.4.alpha.01 spec/zizia/csv_format_validator_spec.rb
zizia-4.5.3.alpha.01 spec/zizia/csv_format_validator_spec.rb
zizia-4.5.2.alpha.01 spec/zizia/csv_format_validator_spec.rb
zizia-4.5.1.alpha.01 spec/zizia/csv_format_validator_spec.rb
zizia-4.4.1.alpha.01 spec/zizia/csv_format_validator_spec.rb
zizia-4.4.0.alpha.01 spec/zizia/csv_format_validator_spec.rb
zizia-4.3.1.alpha.01 spec/zizia/csv_format_validator_spec.rb
zizia-4.2.0.alpha.01 spec/zizia/csv_format_validator_spec.rb
zizia-4.1.0.alpha.01 spec/zizia/csv_format_validator_spec.rb
zizia-4.0.4.alpha.01 spec/zizia/csv_format_validator_spec.rb
zizia-3.1.0.alpha.01 spec/zizia/csv_format_validator_spec.rb