paulelliott/fabrication-site

The documentation could use some expected output

Closed this issue · 6 comments

Without knowing the exact thinking and idea behind every part of fabrications it's sometimes hard to guess what some of the example code will actually do.

For better/easier/faster understanding I'd suggest to add some sections like "this should return..."
To keep documentation clean they could be hidden by default.

I might write something down if you like the idea.

I'm all for improving the documentation. I know it can be hard to get your head around everything that is going on with libraries like this. Could you put together an example of how it could be presented differently to make more sense?

-- Paul

On Tuesday, November 29, 2011 at 8:52 AM, Martin Klepsch wrote:

Without knowing the exact thinking and idea behind every part of fabrications it's sometimes hard to guess what some of the example code will actually do.

For better understanding I'd suggest to add some sections like "this should return..."
To keep documentation clean they could be hidden by default.

I might write something down if you like the idea.


Reply to this email directly or view it on GitHub:
#4

I'm especially having a hard time understanding the way to use sequences.

From my understanding I create a sequence with:

Fabricate.sequence(:name) { |i| "Name #{i}" }

There is no advice however how to use this sequence when fabricating a new object.
The obvious one (to me) below does not work.

 Fabricator(:account) do
   Fabricate.sequence(:name) { |i| "Name #{i}" }
   name :name 
 end

I guess I opened the issue because I wanted to have more example code to understand the usage.

Thanks for pointing that out. I'll update the documentation to illustrate some examples. In the mean time, you would do the below like this:

Fabricator(:account) do
name { sequence(:name) { |i| "Name #{i}" } }
end

-- Paul

On Nov 30, 2011, at 10:19 AM, Martin Klepschreply@reply.github.com wrote:

I'm especially having a hard time understanding the way to use sequences.

From my understanding I create a sequence with:
Fabricate.sequence(:name) { |i| "Name #{i}" }

There is no advice however how to use this sequence when fabricating a new object.
The obvious one (to me) below does not work.

Fabricator(:account) do
  Fabricate.sequence(:name) { |i| "Name #{i}" }
  name :name 
end

I guess I opened the issue because I wanted to have more example code to understand the usage.


Reply to this email directly or view it on GitHub:
#4 (comment)

Thanks for the quick response.
I know about the shorthand syntax you suggested.

I just wondered: How would I use something like

Fabricate.sequence(:name) { |i| "Name #{i}" }

to fill some attribute with it?

If I can only use the shorthand syntax to set attributes that should depend on a sequence,
what are the other ways to define sequences good for?

The shortened syntax is only when you are using a sequence within a fabricator block. It is exactly the same as the longhand, you can just leave off Fabricate if you are already in a fabricator for convenience.

You can use them anywhere outside of fabricators...possibly in a populate script or elsewhere in your test suite. People do lots of different things with them.

-- Paul

On Nov 30, 2011, at 10:33 AM, Martin Klepschreply@reply.github.com wrote:

Thanks for the quick response.
I know about the shorthand syntax you suggested.

I just wondered: How would I use something like

Fabricate.sequence(:name) { |i| "Name #{i}" }

to fill some attribute with it?

If I can only use the shorthand syntax to set attributes that should depend on a sequence,
what are the other ways to define sequences good for?


Reply to this email directly or view it on GitHub:
#4 (comment)

Thank you. I got it now. :-)