2016-09-27 2 views
0

피닉스 프로젝트에서 JSON 픽스처 파일을로드하려면 어떻게해야합니까?피닉스 픽스처 json 파일

Application.app_dir (my_app, "priv")과 같은 것을 시도하면 컴파일 된 경로가 생겨 테스트에서 사용할 수 없습니다.

"test/support/somefile.json"에서 조명기 파일을로드하는 다른 방법이 있습니까?

답변

4

__DIR__Path.expand/2과 함께 사용할 수 있습니다. 예를 들어 테스트가 test/controllers/page_controller_test.exs 인 경우 test/support/somefile.json 경로는 다음을 사용하여 얻을 수 있습니다.

path = Path.expand("../support/somefile.json", __DIR__)