Skip to content
代码片段 群组 项目
提交 4cd962ec 编辑于 作者: Mike Greiling's avatar Mike Greiling
浏览文件

allow storage of raw string fixtures

上级 313aa339
No related branches found
No related tags found
无相关合并请求
......@@ -20,11 +20,24 @@ def clean_frontend_fixtures(directory_name)
# Public: Store a response object as fixture file
#
# response - response object to store
# response - string or response object to store
# fixture_file_name - file name to store the fixture in (relative to FIXTURE_PATH)
#
def store_frontend_fixture(response, fixture_file_name)
fixture_file_name = File.expand_path(fixture_file_name, FIXTURE_PATH)
fixture = response.respond_to?(:body) ? parse_response(response) : response
FileUtils.mkdir_p(File.dirname(fixture_file_name))
File.write(fixture_file_name, fixture)
end
private
# Private: Prepare a response object for use as a frontend fixture
#
# response - response object to prepare
#
def parse_response(response)
fixture = response.body
response_mime_type = Mime::Type.lookup(response.content_type)
......@@ -44,7 +57,6 @@ def store_frontend_fixture(response, fixture_file_name)
fixture.gsub!(%r{="/}, "=\"http://#{test_host}/")
end
FileUtils.mkdir_p(File.dirname(fixture_file_name))
File.write(fixture_file_name, fixture)
fixture
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册