You can YAML.load_file and return the processed YAML from your text, for example:
yaml_text = <<-EOF A_NAME: ABC A_ALIAS: my_alias EOF yaml = YAML.load(yaml_text) filepath = "bogus_filename.yml" YAML.stub(:load_file).with(filepath).and_return(yaml)
This does not completely exhaust the file download, but for this you will have to make assumptions about what YAML.load_file does under the covers, and this is not a good idea. Since it is safe to assume that the YAML implementation has already been tested, you can use the code above to replace the entire call with text parsing.
If you want to verify that the correct file name is passed to load_file , replace the stub with a wait:
YAML.should_receive(:load_file).with(filepath).and_return(yaml)
source share