Skip to content

Commit

Permalink
v1.10.2 improving error message for MissingKeys (#272)
Browse files Browse the repository at this point in the history
* v1.10.2 improving error message for MissingKeys
  • Loading branch information
tilo authored Feb 11, 2024
1 parent 303c703 commit 2f264ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# SmarterCSV 1.x Change Log

## 1.10.2 (2024-02-11)
* improve error message for missing keys

## 1.10.1 (2024-01-07)
* fix incorrect warning about UTF-8 (issue #268, thanks hirowatari)

Expand Down
2 changes: 1 addition & 1 deletion lib/smarter_csv/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SmarterCSV
VERSION = "1.10.1"
VERSION = "1.10.2"
end
8 changes: 4 additions & 4 deletions spec/features/header_handling/invalid_headers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
options = {required_keys: %i[lastname email employee_id firstname manager_email]} # order does not matter
SmarterCSV.process("#{fixture_path}/user_import.csv", options)
end.to raise_exception(
SmarterCSV::MissingKeys, "ERROR: missing attributes: employee_id"
SmarterCSV::MissingKeys, "ERROR: missing attributes: employee_id. Check `SmarterCSV.headers` for original headers."
)
end

Expand All @@ -46,7 +46,7 @@
expect do
SmarterCSV.process("#{fixture_path}/user_import.csv", options)
end.to raise_exception(
SmarterCSV::MissingKeys, "ERROR: missing attributes: email" # it was mapped, and is now missing
SmarterCSV::MissingKeys, /ERROR: missing attributes: email/ # it was mapped, and is now missing
)
end
end
Expand Down Expand Up @@ -115,7 +115,7 @@
expect{ process_file }.not_to raise_exception SmarterCSV::KeyMappingError
# still raises an error because :middle_name is required
expect{ process_file }.to raise_exception(
SmarterCSV::MissingKeys, "ERROR: missing attributes: middle_name"
SmarterCSV::MissingKeys, /ERROR: missing attributes: middle_name/
)
end
end
Expand All @@ -128,7 +128,7 @@
)
# still raises an error because :middle_name is required
expect{ process_file }.to raise_exception(
SmarterCSV::MissingKeys, "ERROR: missing attributes: middle_name"
SmarterCSV::MissingKeys, /ERROR: missing attributes: middle_name/
)
end

Expand Down

0 comments on commit 2f264ca

Please sign in to comment.