Question

I currently have some large strings that I would like use as test data when testing a log scraper. It would work well to have these strings in a YAML file.

I would love to refer to them while testing in a short and concise manner such as:

log_lines(:incorrect_string)

Is there anyway to do this using fixtures, or are they exclusively for use with a corresponding model?

Was it helpful?

Solution

If your yaml looks like this:

:incorrect_string: blah

then you can just

logs = YAML::load_file('filename')
p logs[:incorrect_string]

cheer!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top