Skip to content

Commit

Permalink
Release 0.3.102.2
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Sep 23, 2009
1 parent 4796709 commit a637058
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions History.txt
Expand Up @@ -10,6 +10,9 @@ Using this release on a Rails project requires a rerun of script/generate cucumb
* Added back a way to globally turn off transactions.
* Renamed @allow_rescue tag to @allow-rescue.

=== Bugfixes
* Gracefully handle cases when optional regexp groups are not matched. Ex: /should( not)? be flashed '([^']*?)'$/ (Aslak Hellesøy)

== 2009-09-22

This release has some changes in the Rails support, so make sure you run "script/generate cucumber" after you upgrade.
Expand Down
4 changes: 2 additions & 2 deletions cucumber.gemspec
Expand Up @@ -2,11 +2,11 @@

Gem::Specification.new do |s|
s.name = %q{cucumber}
s.version = "0.3.102.1"
s.version = "0.3.102.2"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Aslak Helles\303\270y"]
s.date = %q{2009-09-23}
s.date = %q{2009-09-24}
s.default_executable = %q{cucumber}
s.description = %q{Executable Feature scenarios}
s.email = ["aslak.hellesoy@gmail.com"]
Expand Down
3 changes: 2 additions & 1 deletion lib/cucumber/rb_support/regexp_argument_matcher.rb
Expand Up @@ -9,7 +9,8 @@ def self.arguments_from(regexp, step_name)
n = 0
match.captures.map do |val|
n += 1
StepArgument.new(val, match.offset(n)[0])
start = match.offset(n)[0]
StepArgument.new(val, start)
end
else
nil
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/step_match.rb
Expand Up @@ -55,6 +55,7 @@ def replace_arguments(string, step_arguments, format, &proc)
s = string.dup
offset = 0
step_arguments.each do |step_argument|
next if step_argument.pos.nil?
replacement = if block_given?
proc.call(step_argument.val)
elsif Proc === format
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/version.rb
Expand Up @@ -3,7 +3,7 @@ class VERSION #:nodoc:
MAJOR = 0
MINOR = 3
TINY = 102
PATCH = 1 # Set to nil for official release
PATCH = 2 # Set to nil for official release

STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
end
Expand Down
5 changes: 5 additions & 0 deletions spec/cucumber/rb_support/regexp_argument_matcher_spec.rb
Expand Up @@ -8,6 +8,11 @@ module RbSupport
arguments = RegexpArgumentMatcher.arguments_from(/I (\w+) (\w+)/, "I like fish")
arguments.map{|argument| [argument.val, argument.pos]}.should == [["like", 2], ["fish", 7]]
end

it "should create 2 arguments when first group is optional" do
arguments = RegexpArgumentMatcher.arguments_from(/should( not)? be flashed '([^']*?)'$/, "I should be flashed 'Login failed.'")
arguments.map{|argument| [argument.val, argument.pos]}.should == [[nil, nil], ["Login failed.", 21]]
end
end
end
end
5 changes: 5 additions & 0 deletions spec/cucumber/step_match_spec.rb
Expand Up @@ -31,5 +31,10 @@ def stepdef(regexp)
m = stepdef(/I (\w+) (\d+) (\w+) this (\w+)/).step_match("I ate 1 egg this morning", nil)
m.format_args(lambda{|m| "<span>#{m}</span>"}).should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
end

it "should format groups even when first group is optional and not matched" do
m = stepdef(/should( not)? be flashed '([^']*?)'$/).step_match("I should be flashed 'Login failed.'", nil)
m.format_args("<span>%s</span>").should == "I should be flashed '<span>Login failed.</span>'"
end
end
end

0 comments on commit a637058

Please sign in to comment.