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:in
Given’
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