Question

Let's say we have.

 apple:
    name: apple

  orange:
    name: orange

  grape:
    name: grape

Can this turn into something below?

    name: apple

    name: orange

    name: grape

Because I have like 25 items, manually name them is really a valueless job.

Was it helpful?

Solution

No, you can't, also because this is not a valid YML syntax. Each fixture element must belong to a name which reflects the YAML node name.

However, you can generate the names with Ruby.

<% %w(apple orange grape).each do |fruit| %>
<%= fruit %>:
    name: <%= fruit %>
<% end %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top