aslakhellesoy-cucumber 0.3.101.2 → 0.3.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -1
- data/Manifest.txt +1 -0
- data/features/custom_formatter.feature +36 -1
- data/features/support/env.rb +1 -1
- data/lib/cucumber/cli/main.rb +1 -0
- data/lib/cucumber/cli/options.rb +2 -0
- data/lib/cucumber/constantize.rb +8 -2
- data/lib/cucumber/core_ext/string.rb +12 -22
- data/lib/cucumber/language_support/step_definition_methods.rb +2 -25
- data/lib/cucumber/rb_support/rb_group.rb +11 -0
- data/lib/cucumber/rb_support/rb_step_definition.rb +23 -5
- data/lib/cucumber/step_match.rb +24 -5
- data/lib/cucumber/step_mother.rb +1 -1
- data/lib/cucumber/version.rb +2 -2
- data/spec/cucumber/core_ext/string_spec.rb +11 -13
- metadata +3 -2
data/History.txt
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
==
|
1
|
+
== 2009-09-22
|
2
2
|
|
3
3
|
This release has some changes in the Rails support, so make sure you run "script/generate cucumber" after you upgrade.
|
4
|
+
Other noteworthy new features are improved Hook, tags and Transform support, and as always - several smaler bug fixes.
|
4
5
|
|
5
6
|
=== New Features
|
7
|
+
* Added new internal API for Regexp and groups, allowing other programming languages to leverage native regexps. (Aslak Hellesøy)
|
6
8
|
* New @allow_rescue tag for Rails scenarios. Causes exceptions raised in actions to be caught by rails and not bubble up to Cucumber (Aslak Hellesøy)
|
7
9
|
* Negative tags can now be used in hooks, just like the command line's --tags option: Before('~@yarr') - will run for all scenarios that *don't* have the @yarr tag. (Aslak Hellesøy)
|
8
10
|
* Transform has current "World" scope (Larry Diehl)
|
@@ -10,6 +12,9 @@ This release has some changes in the Rails support, so make sure you run "script
|
|
10
12
|
* Execute "After" hooks in reverse order of declaration for better behavior with dependent blocks and to mimic the behavior of at_exit (David Waite)
|
11
13
|
|
12
14
|
=== Bugfixes
|
15
|
+
* features/support/env.rb runs commands twice (bugfix cuts total time by almost 50% w00t) (#452 Jim Meyer)
|
16
|
+
* Problems adding custom formatters to features/support. (features/support is added to $LOAD_PATH) (#449 Aslak Hellesøy)
|
17
|
+
* Some options set in cucumber.yml profiles are ignored (#446 Leonard CHIN)
|
13
18
|
* Missing step_definition snippets not properly displayed (#433 Aslak Hellesøy)
|
14
19
|
* rspec-rails, :lib => false (#447 David Chelimsky)
|
15
20
|
* Cucumber with Spork breaks on OS X Snow Leopard (#431 David Chelimsky)
|
data/Manifest.txt
CHANGED
@@ -385,6 +385,7 @@ lib/cucumber/rails/test_unit.rb
|
|
385
385
|
lib/cucumber/rails/world.rb
|
386
386
|
lib/cucumber/rake/task.rb
|
387
387
|
lib/cucumber/rb_support/rb_dsl.rb
|
388
|
+
lib/cucumber/rb_support/rb_group.rb
|
388
389
|
lib/cucumber/rb_support/rb_hook.rb
|
389
390
|
lib/cucumber/rb_support/rb_language.rb
|
390
391
|
lib/cucumber/rb_support/rb_step_definition.rb
|
@@ -8,4 +8,39 @@ Feature: Custom Formatter
|
|
8
8
|
| 1 | 1 | 1 | 1 | 1 | 2 | 1 | 2 | 1 | 2 | 1 |
|
9
9
|
|
10
10
|
"""
|
11
|
-
|
11
|
+
|
12
|
+
Scenario: my own formatter
|
13
|
+
Given a standard Cucumber project directory structure
|
14
|
+
And a file named "features/f.feature" with:
|
15
|
+
"""
|
16
|
+
Feature: i'll use my own
|
17
|
+
Scenario: just print me
|
18
|
+
Given this step works
|
19
|
+
"""
|
20
|
+
And a file named "features/step_definitions/steps.rb" with:
|
21
|
+
"""
|
22
|
+
Given /^this step works$/ do
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
And a file named "features/support/ze/formator.rb" with:
|
26
|
+
"""
|
27
|
+
module Ze
|
28
|
+
class Formator < Cucumber::Ast::Visitor
|
29
|
+
def initialize(step_mother, io, options)
|
30
|
+
super(step_mother)
|
31
|
+
@io = io
|
32
|
+
end
|
33
|
+
|
34
|
+
def visit_scenario_name(keyword, name, file_colon_line, source_indent)
|
35
|
+
@io.puts "$ #{name.upcase}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
"""
|
40
|
+
When I run cucumber features/f.feature --format Ze::Formator
|
41
|
+
Then STDERR should be empty
|
42
|
+
Then it should pass with
|
43
|
+
"""
|
44
|
+
$ JUST PRINT ME
|
45
|
+
|
46
|
+
"""
|
data/features/support/env.rb
CHANGED
@@ -61,6 +61,7 @@ class CucumberWorld
|
|
61
61
|
def create_file(file_name, file_content)
|
62
62
|
file_content.gsub!("CUCUMBER_LIB", "'#{cucumber_lib_dir}'") # Some files, such as Rakefiles need to use the lib dir
|
63
63
|
in_current_dir do
|
64
|
+
FileUtils.mkdir_p(File.dirname(file_name)) unless File.directory?(File.dirname(file_name))
|
64
65
|
File.open(file_name, 'w') { |f| f << file_content }
|
65
66
|
end
|
66
67
|
end
|
@@ -83,7 +84,6 @@ class CucumberWorld
|
|
83
84
|
stderr_file = Tempfile.new('cucumber')
|
84
85
|
stderr_file.close
|
85
86
|
in_current_dir do
|
86
|
-
@last_stdout = `#{command} 2> #{stderr_file.path}`
|
87
87
|
mode = Cucumber::RUBY_1_9 ? {:external_encoding=>"UTF-8"} : 'r'
|
88
88
|
IO.popen("#{command} 2> #{stderr_file.path}", mode) do |io|
|
89
89
|
@last_stdout = io.read
|
data/lib/cucumber/cli/main.rb
CHANGED
@@ -47,6 +47,7 @@ module Cucumber
|
|
47
47
|
step_mother.after_configuration(configuration)
|
48
48
|
features = step_mother.load_plain_text_features(configuration.feature_files)
|
49
49
|
step_mother.load_code_files(configuration.step_defs_to_load)
|
50
|
+
|
50
51
|
enable_diffing
|
51
52
|
|
52
53
|
visitor = configuration.build_formatter_broadcaster(step_mother)
|
data/lib/cucumber/cli/options.rb
CHANGED
@@ -319,6 +319,8 @@ module Cucumber
|
|
319
319
|
def reverse_merge(other_options)
|
320
320
|
@options = other_options.options.merge(@options)
|
321
321
|
@options[:require] += other_options[:require]
|
322
|
+
@options[:excludes] += other_options[:excludes]
|
323
|
+
@options[:name_regexps] += other_options[:name_regexps]
|
322
324
|
@options[:tag_names].merge! other_options[:tag_names]
|
323
325
|
@options[:env_vars] = other_options[:env_vars].merge(@options[:env_vars])
|
324
326
|
if @options[:paths].empty?
|
data/lib/cucumber/constantize.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module Cucumber
|
2
2
|
module Constantize #:nodoc:
|
3
3
|
def constantize(camel_cased_word)
|
4
|
+
try = 0
|
4
5
|
begin
|
6
|
+
try += 1
|
5
7
|
names = camel_cased_word.split('::')
|
6
8
|
names.shift if names.empty? || names.first.empty?
|
7
9
|
|
@@ -10,9 +12,13 @@ module Cucumber
|
|
10
12
|
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
11
13
|
end
|
12
14
|
constant
|
13
|
-
rescue NameError
|
15
|
+
rescue NameError => e
|
14
16
|
require underscore(camel_cased_word)
|
15
|
-
|
17
|
+
if try < 2
|
18
|
+
retry
|
19
|
+
else
|
20
|
+
raise e
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
18
24
|
|
@@ -7,34 +7,24 @@ class String #:nodoc:
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# TODO: Use subs instead...
|
19
|
-
def gzub(regexp, format=nil, &proc)
|
20
|
-
md = match(regexp)
|
21
|
-
raise "#{self.inspect} doesn't match #{regexp.inspect}" if md.nil?
|
22
|
-
|
10
|
+
# TODO: Move to StepMatch
|
11
|
+
# +groups+ is an array of 2-element arrays, where
|
12
|
+
# the 1st element is the value of a regexp match group,
|
13
|
+
# and the 2nd element is its start index.
|
14
|
+
def gzub(groups, format=nil, &proc)
|
23
15
|
s = dup
|
24
|
-
|
25
|
-
|
16
|
+
offset = 0
|
17
|
+
groups.each do |group|
|
26
18
|
replacement = if block_given?
|
27
|
-
proc.call(
|
19
|
+
proc.call(group.val)
|
28
20
|
elsif Proc === format
|
29
|
-
format.call(
|
21
|
+
format.call(group.val)
|
30
22
|
else
|
31
|
-
format %
|
23
|
+
format % group.val
|
32
24
|
end
|
33
25
|
|
34
|
-
|
35
|
-
|
36
|
-
pos += replacement.length - m.length
|
37
|
-
end
|
26
|
+
s[group.start + offset, group.val.length] = replacement
|
27
|
+
offset += replacement.length - group.val.length
|
38
28
|
end
|
39
29
|
s
|
40
30
|
end
|
@@ -4,36 +4,13 @@ module Cucumber
|
|
4
4
|
module LanguageSupport
|
5
5
|
module StepDefinitionMethods
|
6
6
|
def step_match(name_to_match, name_to_report)
|
7
|
-
if(
|
8
|
-
StepMatch.new(self, name_to_match, name_to_report,
|
7
|
+
if(groups = groups(name_to_match))
|
8
|
+
StepMatch.new(self, name_to_match, name_to_report, groups)
|
9
9
|
else
|
10
10
|
nil
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
# Formats the matched arguments of the associated Step. This method
|
15
|
-
# is usually called from visitors, which render output.
|
16
|
-
#
|
17
|
-
# The +format+ can either be a String or a Proc.
|
18
|
-
#
|
19
|
-
# If it is a String it should be a format string according to
|
20
|
-
# <tt>Kernel#sprinf</tt>, for example:
|
21
|
-
#
|
22
|
-
# '<span class="param">%s</span></tt>'
|
23
|
-
#
|
24
|
-
# If it is a Proc, it should take one argument and return the formatted
|
25
|
-
# argument, for example:
|
26
|
-
#
|
27
|
-
# lambda { |param| "[#{param}]" }
|
28
|
-
#
|
29
|
-
def format_args(step_name, format)
|
30
|
-
step_name.gzub(regexp, format)
|
31
|
-
end
|
32
|
-
|
33
|
-
def same_regexp?(regexp)
|
34
|
-
self.regexp == regexp
|
35
|
-
end
|
36
|
-
|
37
14
|
def backtrace_line
|
38
15
|
"#{file_colon_line}:in `#{regexp.inspect}'"
|
39
16
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'cucumber/step_match'
|
2
2
|
require 'cucumber/core_ext/string'
|
3
3
|
require 'cucumber/core_ext/proc'
|
4
|
+
require 'cucumber/rb_support/rb_group'
|
4
5
|
|
5
6
|
module Cucumber
|
6
7
|
module RbSupport
|
@@ -25,13 +26,30 @@ module Cucumber
|
|
25
26
|
|
26
27
|
attr_reader :proc, :regexp
|
27
28
|
|
28
|
-
def initialize(rb_language,
|
29
|
+
def initialize(rb_language, regexp, proc)
|
29
30
|
raise MissingProc if proc.nil?
|
30
|
-
if String ===
|
31
|
-
p =
|
32
|
-
|
31
|
+
if String === regexp
|
32
|
+
p = regexp.gsub(/\$\w+/, '(.*)') # Replace $var with (.*)
|
33
|
+
regexp = Regexp.new("^#{p}$")
|
34
|
+
end
|
35
|
+
@rb_language, @regexp, @proc = rb_language, regexp, proc
|
36
|
+
end
|
37
|
+
|
38
|
+
def ==(step_definition)
|
39
|
+
self.regexp == step_definition.regexp
|
40
|
+
end
|
41
|
+
|
42
|
+
def groups(step_name)
|
43
|
+
match = regexp.match(step_name)
|
44
|
+
if match
|
45
|
+
n = 0
|
46
|
+
match.captures.map do |val|
|
47
|
+
n += 1
|
48
|
+
RbGroup.new(val, match.offset(n)[0])
|
49
|
+
end
|
50
|
+
else
|
51
|
+
nil
|
33
52
|
end
|
34
|
-
@rb_language, @regexp, @proc = rb_language, pattern, proc
|
35
53
|
end
|
36
54
|
|
37
55
|
def invoke(args)
|
data/lib/cucumber/step_match.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module Cucumber
|
2
2
|
class StepMatch #:nodoc:
|
3
|
-
attr_reader :step_definition
|
3
|
+
attr_reader :step_definition
|
4
4
|
|
5
|
-
def initialize(step_definition, step_name, formatted_step_name,
|
6
|
-
@step_definition, @step_name, @formatted_step_name, @
|
5
|
+
def initialize(step_definition, step_name, formatted_step_name, groups)
|
6
|
+
@step_definition, @step_name, @formatted_step_name, @groups = step_definition, step_name, formatted_step_name, groups
|
7
|
+
end
|
8
|
+
|
9
|
+
def args
|
10
|
+
@groups.map{|g| g.val}
|
7
11
|
end
|
8
12
|
|
9
13
|
def name
|
@@ -11,13 +15,28 @@ module Cucumber
|
|
11
15
|
end
|
12
16
|
|
13
17
|
def invoke(multiline_arg)
|
14
|
-
all_args =
|
18
|
+
all_args = args
|
15
19
|
all_args << multiline_arg if multiline_arg
|
16
20
|
@step_definition.invoke(all_args)
|
17
21
|
end
|
18
22
|
|
23
|
+
# Formats the matched arguments of the associated Step. This method
|
24
|
+
# is usually called from visitors, which render output.
|
25
|
+
#
|
26
|
+
# The +format+ can either be a String or a Proc.
|
27
|
+
#
|
28
|
+
# If it is a String it should be a format string according to
|
29
|
+
# <tt>Kernel#sprinf</tt>, for example:
|
30
|
+
#
|
31
|
+
# '<span class="param">%s</span></tt>'
|
32
|
+
#
|
33
|
+
# If it is a Proc, it should take one argument and return the formatted
|
34
|
+
# argument, for example:
|
35
|
+
#
|
36
|
+
# lambda { |param| "[#{param}]" }
|
37
|
+
#
|
19
38
|
def format_args(format = lambda{|a| a})
|
20
|
-
@formatted_step_name || @
|
39
|
+
@formatted_step_name || @step_name.gzub(@groups, format)
|
21
40
|
end
|
22
41
|
|
23
42
|
def file_colon_line
|
data/lib/cucumber/step_mother.rb
CHANGED
@@ -249,7 +249,7 @@ module Cucumber
|
|
249
249
|
# contract (API).
|
250
250
|
def register_step_definition(step_definition)
|
251
251
|
step_definitions.each do |already|
|
252
|
-
raise Redundant.new(already, step_definition) if already
|
252
|
+
raise Redundant.new(already, step_definition) if already == step_definition
|
253
253
|
end
|
254
254
|
step_definitions << step_definition
|
255
255
|
step_definition
|
data/lib/cucumber/version.rb
CHANGED
@@ -1,19 +1,24 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
-
require
|
2
|
+
require 'cucumber/core_ext/string'
|
3
|
+
require 'cucumber/rb_support/rb_group'
|
3
4
|
|
4
5
|
describe String, "#gzub" do
|
6
|
+
def groups(a)
|
7
|
+
a.map{|c| Cucumber::RbSupport::RbGroup.new(c[0], c[1])}
|
8
|
+
end
|
9
|
+
|
5
10
|
it "should format groups with format string" do
|
6
|
-
"I ate 1 egg this morning".gzub(
|
11
|
+
"I ate 1 egg this morning".gzub(groups([['ate', 2], ['1', 6], ['egg', 8], ['morning', 17]]), "<span>%s</span>").should ==
|
7
12
|
"I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
|
8
13
|
end
|
9
14
|
|
10
15
|
it "should format groups with format string when there are dupes" do
|
11
|
-
"I bob 1 bo this bobs".gzub(
|
16
|
+
"I bob 1 bo this bobs".gzub(groups([['bob', 2], ['1', 6], ['bo', 8], ['bobs', 16]]), "<span>%s</span>").should ==
|
12
17
|
"I <span>bob</span> <span>1</span> <span>bo</span> this <span>bobs</span>"
|
13
18
|
end
|
14
19
|
|
15
20
|
it "should format groups with block" do
|
16
|
-
f = "I ate 1 egg this morning".gzub(
|
21
|
+
f = "I ate 1 egg this morning".gzub(groups([['ate', 2], ['1', 6], ['egg', 8], ['morning', 17]])) do |m|
|
17
22
|
"<span>#{m}</span>"
|
18
23
|
end
|
19
24
|
f.should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
|
@@ -23,21 +28,14 @@ describe String, "#gzub" do
|
|
23
28
|
proc = lambda do |m|
|
24
29
|
"<span>#{m}</span>"
|
25
30
|
end
|
26
|
-
f = "I ate 1 egg this morning".gzub(
|
31
|
+
f = "I ate 1 egg this morning".gzub(groups([['ate', 2], ['1', 6], ['egg', 8], ['morning', 17]]), proc)
|
27
32
|
f.should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
|
28
33
|
end
|
29
34
|
|
30
35
|
it "should format groups with block with not all placeholders having a value" do
|
31
|
-
f = "another member named Bob joins the group".gzub(
|
36
|
+
f = "another member named Bob joins the group".gzub(groups([['another', 0], ['member', 8], ['Bob', 21]])) do |m|
|
32
37
|
"<span>#{m}</span>"
|
33
38
|
end
|
34
39
|
f.should == "<span>another</span> <span>member</span> named <span>Bob</span> joins the group"
|
35
40
|
end
|
36
|
-
|
37
|
-
it "should format match groups in a textile table row" do
|
38
|
-
f = "I ate 1 egg this morning".gzub(/I (\w+) (\d+) (\w+) this (\w+)/) do |m|
|
39
|
-
"<span>#{m}</span>"
|
40
|
-
end
|
41
|
-
f.should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
|
42
|
-
end
|
43
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aslakhellesoy-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.102
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Aslak Helles\xC3\xB8y"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-22 00:00:00 -07:00
|
13
13
|
default_executable: cucumber
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -463,6 +463,7 @@ files:
|
|
463
463
|
- lib/cucumber/rails/world.rb
|
464
464
|
- lib/cucumber/rake/task.rb
|
465
465
|
- lib/cucumber/rb_support/rb_dsl.rb
|
466
|
+
- lib/cucumber/rb_support/rb_group.rb
|
466
467
|
- lib/cucumber/rb_support/rb_hook.rb
|
467
468
|
- lib/cucumber/rb_support/rb_language.rb
|
468
469
|
- lib/cucumber/rb_support/rb_step_definition.rb
|