Open sn3p opened 6 years ago
You mean to not show the test helpers in the code when running in production?
If that is so, it could easily be achieved because we're already using a macro to initialize the test helper.
This is not real code:
use TestSelector.HTML.Helpers(enable: !ENV["production"])
def test_selector when !options[:enable], do: ""
def test_selector when options[:enable] do
__MODULE__
|> Module.split()
|> List.last()
|> (&List.insert_at([], 0, &1)).()
|> Enum.join("-")
|> String.trim_trailing("View")
|> String.trim_trailing("Cell")
|> String.downcase()
|> Kernel.<>("-#{test_selector_hash()}")
end
You mean to not show the test helpers in the code when running in production?
Yes exactly that :)
It could easily be achieved because we're already using a macro to initialize the test helper.
Sounds good, will give that a shot soon.
@sn3p gotta work that macro magic though 🐰 so unwrap the options variables etc. See how ex_cell uses the opts variable: https://github.com/DefactoSoftware/ex_cell/blob/master/lib/ex_cell/base.ex
This way we can output/use the helpers in development and test environments, but hide them in production.
Thoughts on this?