Question

I have to test a method which takes a Hash that is associated with some content I scrap from a website.

Here is what I have tried to do in a file located in /test/fixtures/scrapped_sites.yml

web_sites:
  product_images: <% { 'images' => [] } %> 

Then in my test:

page = Page.new
page.my_method(web_sites(:product_images))

But I get:

ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: scrapped_sites: DELETE FROM "scrapped_sites"

How/where should I create this Fixtures?

EDIT:

I have creating a file in test/data/scrapped_data.yml that looks like this:

web_sites:
  scrapped: {'images' => []}

But when running trying to open that file I get:

Psych::SyntaxError: (##): did not find expected ',' or '}' while parsing a flow mapping at line 2 column 9

What am I doing wrong?

Was it helpful?

Solution

Look at Yaml's nested mappings and Simple Inline Arrays

Need to do something like (note indenting with two spaces in critical)

web_sites:
  scrapped:
    images: [img1.png, img2.png, img3.png]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top