Renames a option item allowing one to use a normalized name internally, e.g. rename a deprecated item to the currently accepted name.
Based on a general understanding of what "rename" means, I would expect :rename_to to remove the old key, but it does not. Specifically I'd expect this test to pass:
test "removes the old key" do
schema = [
context: [rename_to: :new_context],
new_context: [type: {:custom, __MODULE__, :string_to_integer, []}]
]
assert NimbleOptions.validate([context: "1"], schema) == {:ok, [{:new_context, 1}]}
end
Instead it fails with this error:
1) test :rename_to removes the old key (NimbleOptionsTest)
test/nimble_options_test.exs:156
Assertion with == failed
code: assert NimbleOptions.validate([context: "1"], schema) == {:ok, [new_context: 1]}
left: {:ok, [{:context, "1"}, {:new_context, 1}]}
right: {:ok, [new_context: 1]}
stacktrace:
test/nimble_options_test.exs:162: (test)
I'm not sure if this can be considered a bug, but this behavior did surprise me.
The docs for
:rename_to
state:Based on a general understanding of what "rename" means, I would expect
:rename_to
to remove the old key, but it does not. Specifically I'd expect this test to pass:Instead it fails with this error:
I'm not sure if this can be considered a bug, but this behavior did surprise me.