How to place YAML inside a YAML document

I work with Rails devices to test my rails application. This is good if only one of my database columns should not contain YAML content. But, I am sure how to place the YAML markup that I want to load into my database in a YAML file. Here is an example:

mvnforum: name: mvnforum abstraction_type: SVN url: src: test username: admin #is this possible? sourcepath: mvnforum/src/ webroot: codesecure_project: mvnforum 

If it is not possible to create YAML inside a YAML file, what would be the best way to upload it to the database for testing?

+4
source share
2 answers

If you want to put the YAML code inside a YAML document, you need to process it as a string:

 url: "src: test username: admin" 

If you need a multi-line string, you can do

 mvnforum: name: mvnforum abstraction_type: SVN url: " src: test\n username: admin\n " sourcepath: mvnforum/src/ webroot: codesecure_project: mvnforum 
+8
source

You might want to study the Factory pattern to replace your lights for your tests and use something like Factory Girl .

Take a look at a great article on why you should use a factory on top of fixtures and benefits.

+3
source

All Articles