Skip to content

Commit

Permalink
Merge branch 'master' into deprecate_visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Sep 23, 2009
2 parents 1198b7a + a637058 commit 9e12c20
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 10 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
6 changes: 4 additions & 2 deletions Manifest.txt
Expand Up @@ -385,13 +385,14 @@ lib/cucumber/rails/test_unit.rb
lib/cucumber/rails/world.rb
lib/cucumber/rake/task.rb
lib/cucumber/rb_support/rb_dsl.rb
lib/cucumber/rb_support/rb_group.rb
lib/cucumber/rb_support/rb_hook.rb
lib/cucumber/rb_support/rb_language.rb
lib/cucumber/rb_support/rb_step_definition.rb
lib/cucumber/rb_support/rb_transform.rb
lib/cucumber/rb_support/rb_world.rb
lib/cucumber/rb_support/regexp_argument_matcher.rb
lib/cucumber/rspec_neuter.rb
lib/cucumber/step_argument.rb
lib/cucumber/step_match.rb
lib/cucumber/step_mother.rb
lib/cucumber/version.rb
Expand Down Expand Up @@ -427,7 +428,6 @@ spec/cucumber/cli/main_spec.rb
spec/cucumber/cli/options_spec.rb
spec/cucumber/cli/profile_loader_spec.rb
spec/cucumber/core_ext/proc_spec.rb
spec/cucumber/core_ext/string_spec.rb
spec/cucumber/formatter/ansicolor_spec.rb
spec/cucumber/formatter/color_io_spec.rb
spec/cucumber/formatter/duration_spec.rb
Expand All @@ -436,7 +436,9 @@ spec/cucumber/formatter/progress_spec.rb
spec/cucumber/parser/feature_parser_spec.rb
spec/cucumber/parser/table_parser_spec.rb
spec/cucumber/rb_support/rb_step_definition_spec.rb
spec/cucumber/rb_support/regexp_argument_matcher_spec.rb
spec/cucumber/sell_cucumbers.feature
spec/cucumber/step_match_spec.rb
spec/cucumber/step_mother_spec.rb
spec/cucumber/treetop_parser/empty_feature.feature
spec/cucumber/treetop_parser/empty_scenario.feature
Expand Down
6 changes: 3 additions & 3 deletions cucumber.gemspec

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/java/README.textile
Expand Up @@ -11,8 +11,8 @@ h2. Running the scenarios

Open a shell in this directory (java) and execute the following command:

<pre><code>
ant
</code></pre>
<pre>ant</pre>

There is a deliberate error. See if you can fix it!

Also see "Cuke4Duke":http://wiki.github.com/aslakhellesoy/cuke4duke for more powerful JVM and Java support for Cucumber.
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 = nil # 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 9e12c20

Please sign in to comment.