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.
B2969ce4f044f9f0a2f056d7264f68a7?d=identicon&s=25 James B. (byrnejb)
on 2008-11-24 17: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
B2969ce4f044f9f0a2f056d7264f68a7?d=identicon&s=25 James B. (byrnejb)
on 2008-11-24 17:18
James Byrne 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
B2969ce4f044f9f0a2f056d7264f68a7?d=identicon&s=25 James B. (byrnejb)
on 2008-11-24 17:28
James Byrne wrote:
> James Byrne 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 Premdas (Guest)
on 2008-11-24 17:34
(Received via mailing list)
Missing slash at end of regex

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

2008/11/24 James Byrne <lists@ruby-forum.com>:
Mark Anderson (Guest)
on 2008-11-24 17: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
Caa5aae0eebe20491ed4b3b4dd7f76b3?d=identicon&s=25 Nick H. (nickh)
on 2008-11-24 17:44
(Received via mailing list)
On 2008-11-24, at 11:16, James Byrne wrote:
> I have this:
>
> When /obtain the party (.*)/ do |n|
>  n case

Hi James. Shouldn't that be "case n"?
-Nick
B2969ce4f044f9f0a2f056d7264f68a7?d=identicon&s=25 James B. (byrnejb)
on 2008-11-24 17:47
Nick Hoffman wrote:
> On 2008-11-24, at 11:16, James Byrne 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.
Caa5aae0eebe20491ed4b3b4dd7f76b3?d=identicon&s=25 Nick H. (nickh)
on 2008-11-24 19:35
(Received via mailing list)
On 2008-11-24, at 11:47, James Byrne 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.