cucumber 0.7.0.beta.3 → 0.7.0.beta.4
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/.gitignore +1 -0
- data/History.txt +8 -0
- data/VERSION.yml +1 -1
- data/cucumber.gemspec +16 -16
- data/examples/dos_line_endings/features/dos_line_endings.feature +1 -1
- data/examples/i18n/Rakefile +2 -2
- data/examples/{selenium → javascript}/Rakefile +1 -3
- data/examples/javascript/features/fibonacci.feature +41 -0
- data/examples/javascript/features/lib/fibonacci.js +19 -0
- data/examples/javascript/features/step_definitions/fib_steps.js +46 -0
- data/examples/javascript/features/support/env.js +11 -0
- data/examples/{selenium_webrat → python}/Rakefile +1 -3
- data/examples/ramaze/README.textile +3 -3
- data/examples/ruby2python/Rakefile +4 -0
- data/examples/tcl/README.textile +1 -1
- data/examples/watir/.gitignore +2 -0
- data/examples/webrat/Rakefile +4 -0
- data/gem_tasks/examples.rake +10 -0
- data/lib/cucumber/cli/main.rb +6 -0
- data/lib/cucumber/js_support/js_dsl.js +70 -0
- data/lib/cucumber/js_support/js_language.rb +164 -0
- data/lib/cucumber/js_support/js_snippets.rb +27 -0
- data/lib/cucumber/py_support/py_language.rb +9 -6
- metadata +17 -17
- data/examples/selenium/features/search.feature +0 -9
- data/examples/selenium/features/step_definitons/search_steps.rb +0 -13
- data/examples/selenium/features/support/env.rb +0 -19
- data/examples/selenium_webrat/config.ru +0 -0
- data/examples/selenium_webrat/features/search.feature +0 -9
- data/examples/selenium_webrat/features/step_definitons/search_steps.rb +0 -13
- data/examples/selenium_webrat/features/support/env.rb +0 -45
data/.gitignore
CHANGED
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 0.7.0.beta.4 (2010-04-24)
|
2
|
+
|
3
|
+
=== New Features
|
4
|
+
* New, experimental V8 javascript support - step definitions in Javascript! (Joseph Wilk)
|
5
|
+
|
6
|
+
=== Bugfixes
|
7
|
+
* Gherkin is loaded via rubygems if it can't be found on the $LOAD_PATH. (Aslak Hellesøy)
|
8
|
+
|
1
9
|
== 0.7.0.beta.3 (2010-04-23)
|
2
10
|
|
3
11
|
=== Changed Features
|
data/VERSION.yml
CHANGED
data/cucumber.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cucumber}
|
8
|
-
s.version = "0.7.0.beta.
|
8
|
+
s.version = "0.7.0.beta.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Aslak Helles\303\270y"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-24}
|
13
13
|
s.default_executable = %q{cucumber}
|
14
14
|
s.description = %q{A BDD tool written in Ruby}
|
15
15
|
s.email = %q{cukes@googlegroups.com}
|
@@ -224,9 +224,15 @@ Gem::Specification.new do |s|
|
|
224
224
|
"examples/i18n/zh-TW/features/division.feature",
|
225
225
|
"examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb",
|
226
226
|
"examples/i18n/zh-TW/lib/calculator.rb",
|
227
|
+
"examples/javascript/Rakefile",
|
228
|
+
"examples/javascript/features/fibonacci.feature",
|
229
|
+
"examples/javascript/features/lib/fibonacci.js",
|
230
|
+
"examples/javascript/features/step_definitions/fib_steps.js",
|
231
|
+
"examples/javascript/features/support/env.js",
|
227
232
|
"examples/junit/features/one_passing_one_failing.feature",
|
228
233
|
"examples/junit/features/pending.feature",
|
229
234
|
"examples/junit/features/step_definitions/steps.rb",
|
235
|
+
"examples/python/Rakefile",
|
230
236
|
"examples/python/features/fibonacci.feature",
|
231
237
|
"examples/python/features/step_definitions/fib_steps.py",
|
232
238
|
"examples/python/lib/.gitignore",
|
@@ -239,20 +245,12 @@ Gem::Specification.new do |s|
|
|
239
245
|
"examples/ramaze/features/support/env.rb",
|
240
246
|
"examples/ramaze/layout/default.html.erb",
|
241
247
|
"examples/ramaze/view/index.html.erb",
|
248
|
+
"examples/ruby2python/Rakefile",
|
242
249
|
"examples/ruby2python/features/fibonacci.feature",
|
243
250
|
"examples/ruby2python/features/step_definitions/fib_steps.rb",
|
244
251
|
"examples/ruby2python/features/support/env.rb",
|
245
252
|
"examples/ruby2python/lib/.gitignore",
|
246
253
|
"examples/ruby2python/lib/fib.py",
|
247
|
-
"examples/selenium/Rakefile",
|
248
|
-
"examples/selenium/features/search.feature",
|
249
|
-
"examples/selenium/features/step_definitons/search_steps.rb",
|
250
|
-
"examples/selenium/features/support/env.rb",
|
251
|
-
"examples/selenium_webrat/Rakefile",
|
252
|
-
"examples/selenium_webrat/config.ru",
|
253
|
-
"examples/selenium_webrat/features/search.feature",
|
254
|
-
"examples/selenium_webrat/features/step_definitons/search_steps.rb",
|
255
|
-
"examples/selenium_webrat/features/support/env.rb",
|
256
254
|
"examples/self_test/.gitignore",
|
257
255
|
"examples/self_test/README.textile",
|
258
256
|
"examples/self_test/Rakefile",
|
@@ -331,6 +329,7 @@ Gem::Specification.new do |s|
|
|
331
329
|
"examples/tickets/features/step_definitons/tickets_steps.rb",
|
332
330
|
"examples/tickets/features/table_diffing.feature",
|
333
331
|
"examples/tickets/features/tickets.feature",
|
332
|
+
"examples/watir/.gitignore",
|
334
333
|
"examples/watir/README.textile",
|
335
334
|
"examples/watir/Rakefile",
|
336
335
|
"examples/watir/cucumber.yml",
|
@@ -338,6 +337,7 @@ Gem::Specification.new do |s|
|
|
338
337
|
"examples/watir/features/step_definitions/search_steps.rb",
|
339
338
|
"examples/watir/features/support/env.rb",
|
340
339
|
"examples/watir/features/support/screenshots.rb",
|
340
|
+
"examples/webrat/Rakefile",
|
341
341
|
"examples/webrat/features/search.feature",
|
342
342
|
"examples/webrat/features/step_definitions/kvasir_steps.rb",
|
343
343
|
"examples/webrat/features/support/env.rb",
|
@@ -395,6 +395,7 @@ Gem::Specification.new do |s|
|
|
395
395
|
"features/work_in_progress.feature",
|
396
396
|
"gem_tasks/contributors.rake",
|
397
397
|
"gem_tasks/environment.rake",
|
398
|
+
"gem_tasks/examples.rake",
|
398
399
|
"gem_tasks/features.rake",
|
399
400
|
"gem_tasks/fix_cr_lf.rake",
|
400
401
|
"gem_tasks/flog.rake",
|
@@ -462,6 +463,9 @@ Gem::Specification.new do |s|
|
|
462
463
|
"lib/cucumber/formatter/tag_cloud.rb",
|
463
464
|
"lib/cucumber/formatter/unicode.rb",
|
464
465
|
"lib/cucumber/formatter/usage.rb",
|
466
|
+
"lib/cucumber/js_support/js_dsl.js",
|
467
|
+
"lib/cucumber/js_support/js_language.rb",
|
468
|
+
"lib/cucumber/js_support/js_snippets.rb",
|
465
469
|
"lib/cucumber/language_support.rb",
|
466
470
|
"lib/cucumber/language_support/language_methods.rb",
|
467
471
|
"lib/cucumber/parser.rb",
|
@@ -537,7 +541,7 @@ Gem::Specification.new do |s|
|
|
537
541
|
|
538
542
|
(::) U P G R A D I N G (::)
|
539
543
|
|
540
|
-
Thank you for installing cucumber-0.7.0.beta.
|
544
|
+
Thank you for installing cucumber-0.7.0.beta.4.
|
541
545
|
Please be sure to read http://wiki.github.com/aslakhellesoy/cucumber/upgrading
|
542
546
|
for important information about this release. Happy cuking!
|
543
547
|
|
@@ -675,10 +679,6 @@ for important information about this release. Happy cuking!
|
|
675
679
|
"examples/ramaze/features/support/env.rb",
|
676
680
|
"examples/ruby2python/features/step_definitions/fib_steps.rb",
|
677
681
|
"examples/ruby2python/features/support/env.rb",
|
678
|
-
"examples/selenium/features/step_definitons/search_steps.rb",
|
679
|
-
"examples/selenium/features/support/env.rb",
|
680
|
-
"examples/selenium_webrat/features/step_definitons/search_steps.rb",
|
681
|
-
"examples/selenium_webrat/features/support/env.rb",
|
682
682
|
"examples/self_test/features/step_definitions/sample_steps.rb",
|
683
683
|
"examples/self_test/features/support/env.rb",
|
684
684
|
"examples/self_test/tmp/features/step_definitions/steps.rb",
|
data/examples/i18n/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
desc 'Run features for all languages'
|
2
|
-
task :
|
2
|
+
task :cucumber do
|
3
3
|
dir = File.dirname(__FILE__)
|
4
4
|
Dir["#{dir}/*"].each do |f|
|
5
5
|
if File.directory?(f)
|
@@ -22,7 +22,7 @@ task :i18n do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
task :default => :
|
25
|
+
task :default => :cucumber
|
26
26
|
|
27
27
|
def examples_working?(lang)
|
28
28
|
!%w{}.index(lang)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Feature: Fibonacci
|
2
|
+
In order to calculate super fast fibonacci series
|
3
|
+
As a Javascriptist
|
4
|
+
I want to use Javascript for that
|
5
|
+
|
6
|
+
Scenario Outline: Series
|
7
|
+
When I ask Javascript to calculate fibonacci up to <n>
|
8
|
+
Then it should give me <series>
|
9
|
+
|
10
|
+
Examples:
|
11
|
+
| n | series |
|
12
|
+
| 1 | [] |
|
13
|
+
| 2 | [1, 1] |
|
14
|
+
| 3 | [1, 1, 2] |
|
15
|
+
| 4 | [1, 1, 2, 3] |
|
16
|
+
| 6 | [1, 1, 2, 3, 5] |
|
17
|
+
| 9 | [1, 1, 2, 3, 5, 8] |
|
18
|
+
| 100 | [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] |
|
19
|
+
|
20
|
+
Scenario: Single series tested via a PyString
|
21
|
+
When I ask Javascript to calculate fibonacci up to 2 with formatting
|
22
|
+
Then it should give me:
|
23
|
+
"""
|
24
|
+
|
25
|
+
'[1, 1]'
|
26
|
+
|
27
|
+
"""
|
28
|
+
|
29
|
+
Scenario: Single series tested via a Step Table
|
30
|
+
When I ask Javascript to calculate fibonacci up to 2
|
31
|
+
Then it should contain:
|
32
|
+
| cell 1 | cell 2 |
|
33
|
+
| 1 | 1 |
|
34
|
+
|
35
|
+
|
36
|
+
@do-fibonnacci-in-before-hook
|
37
|
+
Scenario: Single series with Before hook with a tag label
|
38
|
+
Then it should give me [1, 1, 2]
|
39
|
+
|
40
|
+
Scenario: Single series by calling a step from within a step
|
41
|
+
Then it should give me [1, 1] via calling another step definition
|
@@ -0,0 +1,19 @@
|
|
1
|
+
function fibonacci(n){
|
2
|
+
return n<2?n:fibonacci(n-1)+fibonacci(n-2);
|
3
|
+
}
|
4
|
+
|
5
|
+
var fibonacciSeries = function(fibonacciLimit) {
|
6
|
+
var result = Array();
|
7
|
+
var currentfibonacciValue = fibonacci(1);
|
8
|
+
var i = 2;
|
9
|
+
while(currentfibonacciValue < fibonacciLimit) {
|
10
|
+
result.push(currentfibonacciValue);
|
11
|
+
currentfibonacciValue = fibonacci(i);
|
12
|
+
i++;
|
13
|
+
}
|
14
|
+
return "[" + result.join(", ") + "]";
|
15
|
+
}
|
16
|
+
|
17
|
+
var fibonacciSeriesFormatted = function(fibonacciLimit){
|
18
|
+
return "\n'" + fibonacciSeries(fibonacciLimit) + "'\n"
|
19
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
Before(function(){
|
2
|
+
fibResult = 0;
|
3
|
+
});
|
4
|
+
|
5
|
+
Before('@do-fibonnacci-in-before-hook', function(){
|
6
|
+
fibResult = fibonacciSeries(3);
|
7
|
+
});
|
8
|
+
|
9
|
+
After(function(){
|
10
|
+
//throw 'Sabotage scenario';
|
11
|
+
});
|
12
|
+
|
13
|
+
Transform(/^(\d+)$/, function(n){
|
14
|
+
return parseInt(n);
|
15
|
+
});
|
16
|
+
|
17
|
+
When(/^I ask Javascript to calculate fibonacci up to (\d+)$/, function(n){
|
18
|
+
assertEqual(0, fibResult)
|
19
|
+
fibResult = fibonacciSeries(n);
|
20
|
+
});
|
21
|
+
|
22
|
+
When(/^I ask Javascript to calculate fibonacci up to (\d+) with formatting$/, function(n){
|
23
|
+
assertEqual(0, fibResult)
|
24
|
+
fibResult = fibonacciSeriesFormatted(n);
|
25
|
+
});
|
26
|
+
|
27
|
+
Then(/^it should give me (\[.*\])$/, function(expectedResult){
|
28
|
+
assertEqual(expectedResult, fibResult)
|
29
|
+
});
|
30
|
+
|
31
|
+
Then(/^it should give me:$/, function(string){
|
32
|
+
assertEqual(string, fibResult);
|
33
|
+
});
|
34
|
+
|
35
|
+
Then(/^it should contain:$/, function(table){
|
36
|
+
var hashes = table.hashes();
|
37
|
+
assertMatches(hashes[0]['cell 1'], fibResult);
|
38
|
+
assertMatches(hashes[0]['cell 2'], fibResult);
|
39
|
+
});
|
40
|
+
|
41
|
+
|
42
|
+
Then(/^it should give me (\[.*\]) via calling another step definition$/, function(expectedResult){
|
43
|
+
Given("I ask Javascript to calculate fibonacci up to 2");
|
44
|
+
assertEqual(expectedResult, fibResult);
|
45
|
+
});
|
46
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
function assertEqual(expected, actual){
|
2
|
+
if(expected != actual){
|
3
|
+
throw 'Expected <' + expected + "> but got <" + actual + ">";
|
4
|
+
}
|
5
|
+
}
|
6
|
+
|
7
|
+
function assertMatches(expected, actual){
|
8
|
+
if(actual.indexOf(expected) == -1){
|
9
|
+
throw 'Expected <' + expected + "> to contain <" + actual + "> but it did not";
|
10
|
+
}
|
11
|
+
}
|
data/examples/tcl/README.textile
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
desc 'Run all exmples'
|
2
|
+
task :examples do
|
3
|
+
Dir['examples/*'].each do |example_dir|
|
4
|
+
next if !File.directory?(example_dir) || %w{examples/junit examples/i18n examples/python examples/ruby2python examples/self_test examples/steps_library examples/tickets}.index(example_dir)
|
5
|
+
puts "Running #{example_dir}"
|
6
|
+
Dir.chdir(example_dir) do
|
7
|
+
sh "rake cucumber"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/lib/cucumber/cli/main.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
var CucumberJsDsl = {
|
2
|
+
registerStepDefinition: function(regexp, func) {
|
3
|
+
if(func == null){
|
4
|
+
jsLanguage.executeStepDefinition(regexp);
|
5
|
+
}
|
6
|
+
else{
|
7
|
+
jsLanguage.addStepDefinition(regexp, func);
|
8
|
+
}
|
9
|
+
},
|
10
|
+
|
11
|
+
registerTransform: function(regexp, func){
|
12
|
+
jsLanguage.registerJsTransform(regexp, func);
|
13
|
+
},
|
14
|
+
|
15
|
+
beforeHook: function(tag_or_func, func){
|
16
|
+
CucumberJsDsl.__registerJsHook('before', tag_or_func, func);
|
17
|
+
},
|
18
|
+
|
19
|
+
afterHook: function(tag_or_func, func){
|
20
|
+
CucumberJsDsl.__registerJsHook('after', tag_or_func, func);
|
21
|
+
},
|
22
|
+
|
23
|
+
Table: function(raw_table){
|
24
|
+
this.raw = raw_table;
|
25
|
+
},
|
26
|
+
|
27
|
+
__registerJsHook: function(label, tag_or_func, func){
|
28
|
+
if(func != null){
|
29
|
+
var hook_func = func;
|
30
|
+
var tag = tag_or_func;
|
31
|
+
}
|
32
|
+
else{
|
33
|
+
var hook_func = tag_or_func;
|
34
|
+
var tag = null;
|
35
|
+
}
|
36
|
+
jsLanguage.registerJsHook(label, hook_func, tag);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
CucumberJsDsl.Table.prototype.hashes = function(){
|
41
|
+
var rows = this.rows();
|
42
|
+
var headers = this.headers();
|
43
|
+
var hashes = [];
|
44
|
+
|
45
|
+
for (var rowIndex in rows){
|
46
|
+
var hash_row = [];
|
47
|
+
for (var cellIndex in headers){
|
48
|
+
hash_row[headers[cellIndex]] = rows[rowIndex][cellIndex];
|
49
|
+
}
|
50
|
+
hashes[rowIndex] = hash_row;
|
51
|
+
}
|
52
|
+
return hashes;
|
53
|
+
}
|
54
|
+
|
55
|
+
CucumberJsDsl.Table.prototype.rows = function(){
|
56
|
+
return this.raw.slice(1);
|
57
|
+
}
|
58
|
+
|
59
|
+
CucumberJsDsl.Table.prototype.headers = function(){
|
60
|
+
var raw_cells = this.raw.slice(0);
|
61
|
+
return raw_cells.shift();
|
62
|
+
}
|
63
|
+
|
64
|
+
var Given = CucumberJsDsl.registerStepDefinition;
|
65
|
+
var When = CucumberJsDsl.registerStepDefinition;
|
66
|
+
var Then = CucumberJsDsl.registerStepDefinition;
|
67
|
+
|
68
|
+
var Before = CucumberJsDsl.beforeHook;
|
69
|
+
var After = CucumberJsDsl.afterHook;
|
70
|
+
var Transform = CucumberJsDsl.registerTransform;
|
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'v8'
|
2
|
+
|
3
|
+
require 'cucumber/js_support/js_snippets'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
module JsSupport
|
7
|
+
|
8
|
+
def self.argument_safe_string(string)
|
9
|
+
arg_string = string.to_s.gsub(/[']/, '\\\\\'')
|
10
|
+
"'#{arg_string.gsub("\n", '\n')}'"
|
11
|
+
end
|
12
|
+
|
13
|
+
class JsWorld
|
14
|
+
def initialize
|
15
|
+
@world = V8::Context.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute(js_function, args=[])
|
19
|
+
js_args = args.map do |arg|
|
20
|
+
if arg.is_a?(Ast::Table)
|
21
|
+
"new CucumberJsDsl.Table(#{arg.raw.inspect})"
|
22
|
+
else
|
23
|
+
JsSupport.argument_safe_string(arg)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
@world.eval("(#{js_function.ToString})(#{js_args.join(',')});")
|
28
|
+
end
|
29
|
+
|
30
|
+
def method_missing(method_name, *args)
|
31
|
+
@world.send(method_name, *args)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class JsStepDefinition
|
36
|
+
def initialize(js_language, regexp, js_function)
|
37
|
+
@js_language, @regexp, @js_function = js_language, regexp.ToString, js_function
|
38
|
+
end
|
39
|
+
|
40
|
+
def invoke(args)
|
41
|
+
args = @js_language.execute_transforms(args)
|
42
|
+
@js_language.current_world.execute(@js_function, args)
|
43
|
+
end
|
44
|
+
|
45
|
+
def arguments_from(step_name)
|
46
|
+
matches = eval_js "#{@regexp}.exec('#{step_name}')"
|
47
|
+
if matches
|
48
|
+
matches[1..-1].map do |match|
|
49
|
+
JsArg.new(match)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def file_colon_line
|
55
|
+
# Not possible yet to get file/line of js function with V8/therubyracer
|
56
|
+
""
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class JsHook
|
61
|
+
def initialize(js_language, tag_names, js_function)
|
62
|
+
@js_language, @tag_names, @js_function = js_language, tag_names, js_function
|
63
|
+
end
|
64
|
+
|
65
|
+
def tag_expressions
|
66
|
+
@tag_names
|
67
|
+
end
|
68
|
+
|
69
|
+
def invoke(location, scenario)
|
70
|
+
@js_language.current_world.execute(@js_function)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class JsTransform
|
75
|
+
def initialize(js_language, regexp, js_function)
|
76
|
+
@js_language, @regexp, @js_function = js_language, regexp.ToString, js_function
|
77
|
+
end
|
78
|
+
|
79
|
+
def match(arg)
|
80
|
+
arg = JsSupport.argument_safe_string(arg)
|
81
|
+
matches = eval_js "#{@regexp}.exec(#{arg});"
|
82
|
+
matches ? matches[1..-1] : nil
|
83
|
+
end
|
84
|
+
|
85
|
+
def invoke(arg)
|
86
|
+
@js_language.current_world.execute(@js_function, [arg])
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class JsArg
|
91
|
+
def initialize(arg)
|
92
|
+
@arg = arg
|
93
|
+
end
|
94
|
+
|
95
|
+
def val
|
96
|
+
@arg
|
97
|
+
end
|
98
|
+
|
99
|
+
def byte_offset
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class JsLanguage
|
104
|
+
include LanguageSupport::LanguageMethods
|
105
|
+
include JsSnippets
|
106
|
+
|
107
|
+
def initialize(step_mother)
|
108
|
+
@step_definitions = []
|
109
|
+
@world = JsWorld.new
|
110
|
+
@step_mother = step_mother
|
111
|
+
|
112
|
+
@world["jsLanguage"] = self
|
113
|
+
@world.load(File.dirname(__FILE__) + '/js_dsl.js')
|
114
|
+
end
|
115
|
+
|
116
|
+
def load_code_file(js_file)
|
117
|
+
@world.load(js_file)
|
118
|
+
end
|
119
|
+
|
120
|
+
def alias_adverbs(adverbs)
|
121
|
+
end
|
122
|
+
|
123
|
+
def begin_scenario(scenario)
|
124
|
+
end
|
125
|
+
|
126
|
+
def end_scenario
|
127
|
+
end
|
128
|
+
|
129
|
+
def step_matches(name_to_match, name_to_format)
|
130
|
+
@step_definitions.map do |step_definition|
|
131
|
+
if(arguments = step_definition.arguments_from(name_to_match))
|
132
|
+
StepMatch.new(step_definition, name_to_match, name_to_format, arguments)
|
133
|
+
else
|
134
|
+
nil
|
135
|
+
end
|
136
|
+
end.compact
|
137
|
+
end
|
138
|
+
|
139
|
+
def add_step_definition(regexp, js_function)
|
140
|
+
@step_definitions << JsStepDefinition.new(self, regexp, js_function)
|
141
|
+
end
|
142
|
+
|
143
|
+
#TODO: support multiline arguments when calling steps from within steps
|
144
|
+
def execute_step_definition(name, multiline_argument = nil)
|
145
|
+
@step_mother.step_match(name).invoke(multiline_argument)
|
146
|
+
end
|
147
|
+
|
148
|
+
#TODO: support multiple tag_names
|
149
|
+
def register_js_hook(phase, js_function, tag_name = nil)
|
150
|
+
tag_names = tag_name ? [tag_name] : []
|
151
|
+
add_hook(phase, JsHook.new(self, tag_names, js_function))
|
152
|
+
end
|
153
|
+
|
154
|
+
def register_js_transform(regexp, js_function)
|
155
|
+
add_transform(JsTransform.new(self, regexp, js_function))
|
156
|
+
end
|
157
|
+
|
158
|
+
def current_world
|
159
|
+
@world
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module JsSupport
|
3
|
+
module JsSnippets
|
4
|
+
PARAM_PATTERN = /"([^\"]*)"/
|
5
|
+
ESCAPED_PARAM_PATTERN = '"([^\\"]*)"'
|
6
|
+
|
7
|
+
def snippet_text(step_keyword, step_name, multiline_arg_class)
|
8
|
+
escaped = Regexp.escape(step_name).gsub('\ ', ' ').gsub('/', '\/')
|
9
|
+
escaped = escaped.gsub(PARAM_PATTERN, ESCAPED_PARAM_PATTERN)
|
10
|
+
|
11
|
+
n = 0
|
12
|
+
block_args = escaped.scan(ESCAPED_PARAM_PATTERN).map do |a|
|
13
|
+
n += 1
|
14
|
+
"arg#{n}"
|
15
|
+
end
|
16
|
+
block_args << multiline_arg_class.default_arg_name unless multiline_arg_class.nil?
|
17
|
+
block_arg_string = block_args.empty? ? "" : "#{block_args.join(", ")}"
|
18
|
+
multiline_class_comment = ""
|
19
|
+
if(multiline_arg_class == Ast::Table)
|
20
|
+
multiline_class_comment = "//#{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
"#{step_keyword}(/^#{escaped}$/, function(#{block_arg_string}){\n #{multiline_class_comment} //express the regexp above with the code you wish you had\n});"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -7,13 +7,13 @@ module Cucumber
|
|
7
7
|
|
8
8
|
def initialize(step_mother)
|
9
9
|
@step_def_files = []
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# @python_path = ENV['PYTHONPATH'] ? ENV['PYTHONPATH'].split(':') : []
|
12
12
|
# add_to_python_path(File.dirname(__FILE__))
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# RubyPython.start
|
15
15
|
# at_exit{RubyPython.stop}
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# import(File.dirname(__FILE__) + '/py_language.py')
|
18
18
|
end
|
19
19
|
|
@@ -32,17 +32,20 @@ module Cucumber
|
|
32
32
|
"python snippet: #{step_keyword}, #{step_name}"
|
33
33
|
end
|
34
34
|
|
35
|
-
def begin_scenario
|
35
|
+
def begin_scenario(scenario)
|
36
36
|
@python_path = []
|
37
37
|
add_to_python_path(File.dirname(__FILE__))
|
38
38
|
@step_def_files.each{|f| add_to_python_path(File.dirname(f))}
|
39
|
-
|
39
|
+
|
40
40
|
RubyPython.start
|
41
41
|
|
42
42
|
@delegate = import(File.dirname(__FILE__) + '/py_language.py')
|
43
43
|
@step_def_files.each{|f| import(f)}
|
44
44
|
end
|
45
45
|
|
46
|
+
def end_scenario
|
47
|
+
end
|
48
|
+
|
46
49
|
def step_matches(step_name, name_to_report)
|
47
50
|
@delegate.step_matches(step_name, name_to_report)
|
48
51
|
end
|
@@ -75,7 +78,7 @@ class String #:nodoc:
|
|
75
78
|
def end_with?(str) #:nodoc:
|
76
79
|
str = str.to_str
|
77
80
|
tail = self[-str.length, str.length]
|
78
|
-
tail == str
|
81
|
+
tail == str
|
79
82
|
end
|
80
83
|
end
|
81
84
|
end
|
metadata
CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
|
|
7
7
|
- 7
|
8
8
|
- 0
|
9
9
|
- beta
|
10
|
-
-
|
11
|
-
version: 0.7.0.beta.
|
10
|
+
- 4
|
11
|
+
version: 0.7.0.beta.4
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- "Aslak Helles\xC3\xB8y"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-04-
|
19
|
+
date: 2010-04-24 00:00:00 +02:00
|
20
20
|
default_executable: cucumber
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -402,9 +402,15 @@ files:
|
|
402
402
|
- examples/i18n/zh-TW/features/division.feature
|
403
403
|
- examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb
|
404
404
|
- examples/i18n/zh-TW/lib/calculator.rb
|
405
|
+
- examples/javascript/Rakefile
|
406
|
+
- examples/javascript/features/fibonacci.feature
|
407
|
+
- examples/javascript/features/lib/fibonacci.js
|
408
|
+
- examples/javascript/features/step_definitions/fib_steps.js
|
409
|
+
- examples/javascript/features/support/env.js
|
405
410
|
- examples/junit/features/one_passing_one_failing.feature
|
406
411
|
- examples/junit/features/pending.feature
|
407
412
|
- examples/junit/features/step_definitions/steps.rb
|
413
|
+
- examples/python/Rakefile
|
408
414
|
- examples/python/features/fibonacci.feature
|
409
415
|
- examples/python/features/step_definitions/fib_steps.py
|
410
416
|
- examples/python/lib/.gitignore
|
@@ -417,20 +423,12 @@ files:
|
|
417
423
|
- examples/ramaze/features/support/env.rb
|
418
424
|
- examples/ramaze/layout/default.html.erb
|
419
425
|
- examples/ramaze/view/index.html.erb
|
426
|
+
- examples/ruby2python/Rakefile
|
420
427
|
- examples/ruby2python/features/fibonacci.feature
|
421
428
|
- examples/ruby2python/features/step_definitions/fib_steps.rb
|
422
429
|
- examples/ruby2python/features/support/env.rb
|
423
430
|
- examples/ruby2python/lib/.gitignore
|
424
431
|
- examples/ruby2python/lib/fib.py
|
425
|
-
- examples/selenium/Rakefile
|
426
|
-
- examples/selenium/features/search.feature
|
427
|
-
- examples/selenium/features/step_definitons/search_steps.rb
|
428
|
-
- examples/selenium/features/support/env.rb
|
429
|
-
- examples/selenium_webrat/Rakefile
|
430
|
-
- examples/selenium_webrat/config.ru
|
431
|
-
- examples/selenium_webrat/features/search.feature
|
432
|
-
- examples/selenium_webrat/features/step_definitons/search_steps.rb
|
433
|
-
- examples/selenium_webrat/features/support/env.rb
|
434
432
|
- examples/self_test/.gitignore
|
435
433
|
- examples/self_test/README.textile
|
436
434
|
- examples/self_test/Rakefile
|
@@ -509,6 +507,7 @@ files:
|
|
509
507
|
- examples/tickets/features/step_definitons/tickets_steps.rb
|
510
508
|
- examples/tickets/features/table_diffing.feature
|
511
509
|
- examples/tickets/features/tickets.feature
|
510
|
+
- examples/watir/.gitignore
|
512
511
|
- examples/watir/README.textile
|
513
512
|
- examples/watir/Rakefile
|
514
513
|
- examples/watir/cucumber.yml
|
@@ -516,6 +515,7 @@ files:
|
|
516
515
|
- examples/watir/features/step_definitions/search_steps.rb
|
517
516
|
- examples/watir/features/support/env.rb
|
518
517
|
- examples/watir/features/support/screenshots.rb
|
518
|
+
- examples/webrat/Rakefile
|
519
519
|
- examples/webrat/features/search.feature
|
520
520
|
- examples/webrat/features/step_definitions/kvasir_steps.rb
|
521
521
|
- examples/webrat/features/support/env.rb
|
@@ -573,6 +573,7 @@ files:
|
|
573
573
|
- features/work_in_progress.feature
|
574
574
|
- gem_tasks/contributors.rake
|
575
575
|
- gem_tasks/environment.rake
|
576
|
+
- gem_tasks/examples.rake
|
576
577
|
- gem_tasks/features.rake
|
577
578
|
- gem_tasks/fix_cr_lf.rake
|
578
579
|
- gem_tasks/flog.rake
|
@@ -640,6 +641,9 @@ files:
|
|
640
641
|
- lib/cucumber/formatter/tag_cloud.rb
|
641
642
|
- lib/cucumber/formatter/unicode.rb
|
642
643
|
- lib/cucumber/formatter/usage.rb
|
644
|
+
- lib/cucumber/js_support/js_dsl.js
|
645
|
+
- lib/cucumber/js_support/js_language.rb
|
646
|
+
- lib/cucumber/js_support/js_snippets.rb
|
643
647
|
- lib/cucumber/language_support.rb
|
644
648
|
- lib/cucumber/language_support/language_methods.rb
|
645
649
|
- lib/cucumber/parser.rb
|
@@ -718,7 +722,7 @@ post_install_message: |+
|
|
718
722
|
|
719
723
|
(::) U P G R A D I N G (::)
|
720
724
|
|
721
|
-
Thank you for installing cucumber-0.7.0.beta.
|
725
|
+
Thank you for installing cucumber-0.7.0.beta.4.
|
722
726
|
Please be sure to read http://wiki.github.com/aslakhellesoy/cucumber/upgrading
|
723
727
|
for important information about this release. Happy cuking!
|
724
728
|
|
@@ -878,10 +882,6 @@ test_files:
|
|
878
882
|
- examples/ramaze/features/support/env.rb
|
879
883
|
- examples/ruby2python/features/step_definitions/fib_steps.rb
|
880
884
|
- examples/ruby2python/features/support/env.rb
|
881
|
-
- examples/selenium/features/step_definitons/search_steps.rb
|
882
|
-
- examples/selenium/features/support/env.rb
|
883
|
-
- examples/selenium_webrat/features/step_definitons/search_steps.rb
|
884
|
-
- examples/selenium_webrat/features/support/env.rb
|
885
885
|
- examples/self_test/features/step_definitions/sample_steps.rb
|
886
886
|
- examples/self_test/features/support/env.rb
|
887
887
|
- examples/self_test/tmp/features/step_definitions/steps.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
Given 'I am on the Google search page' do
|
2
|
-
@browser.open('http://www.google.com/')
|
3
|
-
end
|
4
|
-
|
5
|
-
When /I search for "(.*)"/ do |query|
|
6
|
-
@browser.type('q', query)
|
7
|
-
@browser.click 'btnG'
|
8
|
-
@browser.wait_for_page_to_load
|
9
|
-
end
|
10
|
-
|
11
|
-
Then /I should see a link to (.*)/ do |expected_url|
|
12
|
-
@browser.is_element_present("css=a[href='#{expected_url}']").should be_true
|
13
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec/expectations'
|
2
|
-
require 'selenium'
|
3
|
-
|
4
|
-
# "before all"
|
5
|
-
browser = Selenium::SeleniumDriver.new("localhost", 4444, "*chrome", "http://localhost", 15000)
|
6
|
-
|
7
|
-
Before do
|
8
|
-
@browser = browser
|
9
|
-
@browser.start
|
10
|
-
end
|
11
|
-
|
12
|
-
After do
|
13
|
-
@browser.stop
|
14
|
-
end
|
15
|
-
|
16
|
-
# "after all"
|
17
|
-
at_exit do
|
18
|
-
browser.close rescue nil
|
19
|
-
end
|
File without changes
|
@@ -1,13 +0,0 @@
|
|
1
|
-
Given 'I am on the Google search page' do
|
2
|
-
visit('http://www.google.com/')
|
3
|
-
end
|
4
|
-
|
5
|
-
When /I search for "(.*)"/ do |query|
|
6
|
-
fill_in('q', :with => query)
|
7
|
-
click_button 'Google Search'
|
8
|
-
selenium.wait_for_page_to_load
|
9
|
-
end
|
10
|
-
|
11
|
-
Then /I should see a link to (.*)/ do |expected_url|
|
12
|
-
click_link expected_url
|
13
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec/expectations'
|
2
|
-
|
3
|
-
# START HACK
|
4
|
-
# Webrat's Selenium wrongly assumes Rails in available. # We'll just fool it...
|
5
|
-
module ActionController
|
6
|
-
class IntegrationTest
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def silence_stream(*args)
|
11
|
-
yield if block_given?
|
12
|
-
end
|
13
|
-
# END HACK
|
14
|
-
|
15
|
-
# RSpec
|
16
|
-
require 'spec/expectations'
|
17
|
-
|
18
|
-
# Webrat
|
19
|
-
require 'webrat'
|
20
|
-
|
21
|
-
Webrat.configure do |config|
|
22
|
-
config.mode = :selenium
|
23
|
-
end
|
24
|
-
|
25
|
-
World do
|
26
|
-
session = Webrat::SeleniumSession.new
|
27
|
-
session.extend(Webrat::Methods)
|
28
|
-
session.extend(Webrat::Selenium::Methods)
|
29
|
-
session.extend(Webrat::Selenium::Matchers)
|
30
|
-
session
|
31
|
-
end
|
32
|
-
|
33
|
-
# START HACK
|
34
|
-
# Disable Rails-specific code
|
35
|
-
class Webrat::Selenium::ApplicationServer
|
36
|
-
def self.boot
|
37
|
-
|
38
|
-
STDOUT.puts "Starting app server"
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.stop_at_exit
|
42
|
-
STDOUT.puts "Stopping app server"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
# END HACK
|