Sha256: 0469e7042ae2e708f32a61821d1c4aceb3c1a4b066cf002a1de4d5e2e4c86b26
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
require File.expand_path('../../test_helper', __FILE__) class Embratel::CSVParserTest < Test::Unit::TestCase FIXTURES_PATH = File.join(File.dirname(__FILE__), '..', 'fixtures') NON_EXISTING_FILE_PATH = "#{FIXTURES_PATH}/non_existing_file.csv" DIRECTORY_PATH = "#{FIXTURES_PATH}" NON_PHONE_BILL_FILE_PATH = "#{FIXTURES_PATH}/lorem_ipsum.csv" INVALID_CSV_PHONE_BILL_FILE_PATH = "#{FIXTURES_PATH}/invalid_phone_bill_file.csv" VALID_CSV_PHONE_BILL_FILE_PATH = "#{FIXTURES_PATH}/valid_phone_bill_file.csv" NON_CSV_PHONE_BILL_FILE_PATH = "#{FIXTURES_PATH}/phone_bill.txt" def test_csv_parser_instantiation_with_a_non_existing_file_path assert_raise(Errno::ENOENT) do Embratel::CSVParser.parse(NON_EXISTING_FILE_PATH) end end def test_csv_parser_instantiation_with_a_directory_path assert_raise(Errno::EISDIR) { Embratel::CSVParser.parse(DIRECTORY_PATH) } end def test_csv_parser_instantiation_with_a_non_phone_bill_file_path assert_raise(Embratel::InvalidRowsError) do Embratel::CSVParser.parse(NON_PHONE_BILL_FILE_PATH) end end def test_csv_parser_instantiation_with_an_invalid_csv_phone_bill_file assert_raise(Embratel::InvalidRowsError) do Embratel::CSVParser.parse(INVALID_CSV_PHONE_BILL_FILE_PATH) end end def test_does_not_allow_other_file_extensions_than_csv assert_raise(Embratel::NonCSVFileError) do Embratel::CSVParser.parse(NON_CSV_PHONE_BILL_FILE_PATH) end end def test_parse_with_valid_phone_bill_file payables = Embratel::CSVParser.parse(VALID_CSV_PHONE_BILL_FILE_PATH) calls = payables.select(&:call?) fees = payables.select(&:fee?) assert_equal(4, payables.size) assert_equal(3, calls.size) assert_equal(1, fees.size) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
embratel-1.1.0 | test/embratel/csv_parser_test.rb |