Story problem if parenthesis used in Given, When, Then or And

VERSION: rspec rails plugin current edge version
XP/Cygwin on XP

Hi,
I hit this when trying to use parenthesis in my stories … (that’ll
teach
me!).

If a scenario looks like the following:

Story “User has story with parentheses”, %{
As a user
I want parenthesis
So that … well I just do
}, :type => RailsStory do

Scenario “the Given has parentheses” do
Given "parenthesis () in the given " do
end

When "anything" do
end

Then "The error occurred while evaluating nil.perform " do
end

end
end

This fails with the following:

The error occurred while evaluating nil.perform

/cygdrive/c/development/sandbox/prototypes/proj/config/…/vendor/plugins/rspec/lib/spec/story/world.rb:
60:in store_and_call' /cygdrive/c/development/sandbox/prototypes/proj/config/../vendor/plugins/rspec/lib/spec/story/world.rb: 92:inGiven’
stories/parenthesis_error_story.rb:10

Looks like the problem is in the Step#matches? method
since
“abc (re) def”.match /abc (re) def/
returns nil
however
“abc (re) def”.match /abc (re) def/
returns the match

The Step#assign_expression method when modifed as follows

    def assign_expression(name)
      expression = name.dup
      if String === expression
        while expression =~ /(\$\w*)/
          expression.gsub!($1, "(.*)")
        end

        expression.gsub! '(', '\('     # here
        expression.gsub! ')', '\)'     # here

      end
      @expression = Regexp.new("^#{expression}$")
    end

Then the specs pass.

This has been here for a couple of weeks just got round to debugging.

HTH
heers!
sinclair

On Nov 13, 2007 11:05 AM, sinclair bain [email protected] wrote:

As a user

/cygdrive/c/development/sandbox/prototypes/proj/config/…/vendor/plugins/rspec/lib/spec/story/world.rb:
however
end
This has been here for a couple of weeks just got round to debugging.
Please do not use this list for patches if you expect them to be
incorporated.

http://rspec.rubyforge.org/community/contribute.html
http://rubyforge.org/tracker/?group_id=797

Cheers,
David

Submitted error #15608.

On Nov 13, 2007 12:16 PM, David C. [email protected] wrote:

When "anything" do

The error occurred while evaluating nil.perform
Looks like the problem is in the Step#matches? method
expression = name.dup
end

Cheers,
David


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Cheers!
sinclair

On Nov 13, 2007 11:54 AM, sinclair bain [email protected] wrote:

Submitted error #15608.

Thanks!