Forum: RSpec calling a step from a step

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
James B. (Guest)
on 2008-11-24 18:16
cucumber 0.1.9

I have this:

When /obtain the party (.*)/ do |n|
  n case
    when "common name"
      @party.entity_name = "Anything will do"
    when "legal name"
      @party.entity_legal_name = "Something a Bit Longer I SHOULD think"
    when "corporate form"
      @party.entity_legal_form = "PERS"
    else
      raise ArgumentError, "#{n} attribute is not provided for."
  end
end

When /should determine the party (.*) do |n|
  When "obtain the party #{n}"
end

# rake features gives this error:

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require': ./features/step_definitions/entity_steps.rb:28:
unknown regexp options - rcrd (SyntaxError)
./features/step_definitions/entity_steps.rb:28: syntax error
Then /record the party/ do
                ^
./features/step_definitions/entity_steps.rb:28: syntax error


I understood that as of 0.1.7 cucumber supported steps from step calls.
Have I mistyped or misunderstood something
James B. (Guest)
on 2008-11-24 18:18
James B. wrote:

> When /should determine the party (.*) do |n|
>   When "obtain the party #{n}"
> end
>

Missed the next follow on lines. Snippet should be:

When /should determine the party (.*) do |n|
  When "obtain the party #{n}"
end

Then /record the party/ do
  Entity.destroy_all
  @party.save!
end
James B. (Guest)
on 2008-11-24 18:28
James B. wrote:
> James B. wrote:
>
>> When /should determine the party (.*) do |n|
>>   When "obtain the party #{n}"
>> end
>>
>

Another helpful tidbit that I neglected to post.  The reason that I
focused on the step from step method shown above is that when I comment
these lines out the following method "Then /record the party/" run fine.
Andrew P. (Guest)
on 2008-11-24 18:34
(Received via mailing list)
Missing slash at end of regex

/When /should determine the party (.*)/

2008/11/24 James B. <removed_email_address@domain.invalid>:
Mark Anderson (Guest)
on 2008-11-24 18:40
(Received via mailing list)
It looks like you are not closing your regexp here:

> When /should determine the party (.*) do |n|
>   When "obtain the party #{n}"
> end

So it doesn't close until it gets here, where you are trying to start a
new
one:

> Then /record the party/ do
>   Entity.destroy_all
>   @party.save!
> end

And then is treating 'record' as options to the regexp and not
recognizing
some of them

> # rake features gives this error:
>
> /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `gem_original_require': ./features/step_definitions/entity_steps.rb:28:
> unknown regexp options - rcrd (SyntaxError)
>./features/step_definitions/entity_steps.rb:28: syntax error Then /record
the party/ do
>                 ^
> ./features/step_definitions/entity_steps.rb:28: syntax error


__________ Information from ESET NOD32 Antivirus, version of virus
signature
database 3636 (20081124) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
Nick H. (Guest)
on 2008-11-24 18:44
(Received via mailing list)
On 2008-11-24, at 11:16, James B. wrote:
> I have this:
>
> When /obtain the party (.*)/ do |n|
>  n case

Hi James. Shouldn't that be "case n"?
-Nick
James B. (Guest)
on 2008-11-24 18:47
Nick H. wrote:
> On 2008-11-24, at 11:16, James B. wrote:
>> I have this:
>>
>> When /obtain the party (.*)/ do |n|
>>  n case
>
> Hi James. Shouldn't that be "case n"?
> -Nick

Yes.


> Missing slash at end of regex

> /When /should determine the party (.*)/

Sighhhh.... Thanks.
Nick H. (Guest)
on 2008-11-24 20:35
(Received via mailing list)
On 2008-11-24, at 11:47, James B. wrote:
>> Missing slash at end of regex
>
>> /When /should determine the party (.*)/
>
> Sighhhh.... Thanks.

Hey, it happens to the best of us, mate. At least it's an easy fix!
This topic is locked and can not be replied to.