If I have a step matcher defined as so:
Given “a user named $username” do |username|
…
end
Is there a way to call it from another step? For example:
Given "a user named $username with a blog post |username|
given_a_user_named(username) # calls existing step code
create a blog post
end
Cheers,
Bryan H. wrote:
create a blog post
end
Cheers,
I’m not sure if you can call a step directly… I would be very
interested in that if you can… But AFAIK the only option is to extract
it into a helper method an place it in Spec::Story::World.
So you would have:
Given “a user named $username” do |username|
create_user_with_name(user_name)
end
Given "a user named $username with a blog post |username|
create_user_with_name(user_name)
create a blog post
end
I typically do things with instance variables though. So the “Given a
user named $username” step would set an instance variable named
@username.
Then I would have a step that reads “$username has a blog post” that
would get the instance variable name and it would build a post off of
that user. The story would the read like:
Given a user named Joey
And Joey has a blog post
-Ben
On May 14, 2008, at 12:45 PM, Bryan H. wrote:
create a blog post
end
I’m pretty sure you can do this:
Given "a user named $username with a blog post |username|
Given “a user named #{username}”
create a blog post
end
Cheers,
David
On Wed, May 14, 2008 at 2:24 PM, David C. [email protected]
wrote:
Given "a user named $username with a blog post |username|
end
Is this by intention or just a side effect of the current
implementation?
On May 14, 2008, at 3:07 PM, Zach D. wrote:
Is there a way to call it from another step? For example:
Given “a user named #{username}”
create a blog post
end
Is this by intention or just a side effect of the current
implementation?
You’ll have to ask Dan - Dan?