cucumber-tcl 0.0.4 → 0.0.5
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/CONTRIBUTING.md +3 -3
- data/features/data_tables.feature +0 -1
- data/features/define_a_step.feature +107 -0
- data/features/pending_step.feature +41 -0
- data/lib/cucumber/tcl.rb +16 -4
- data/lib/cucumber/tcl/framework.rb +19 -0
- data/lib/cucumber/tcl/framework.tcl +50 -26
- data/lib/cucumber/tcl/step_definitions.rb +23 -11
- data/lib/cucumber/tcl/test/test_framework.tcl +63 -56
- data/lib/cucumber/tcl/version +1 -1
- data/spec/cucumber/tcl/step_definitions_spec.rb +18 -4
- metadata +5 -3
data/CONTRIBUTING.md
CHANGED
@@ -16,14 +16,14 @@ Now release it
|
|
16
16
|
git commit -m "Release `cat lib/cucumber/tcl/version`"
|
17
17
|
rake release
|
18
18
|
|
19
|
-
## Gaining Release
|
19
|
+
## Gaining Release Privileges
|
20
20
|
|
21
|
-
To become a release manager, create a pull request adding your name to the list below, and include your [Rubygems
|
21
|
+
To become a release manager, create a pull request adding your name to the list below, and make sure to include a link to your [Rubygems profile](https://rubygems.org/sign_up). One of the existing release managers will then add you.
|
22
22
|
|
23
23
|
Current release managers:
|
24
24
|
* [Matt Wynne](https://rubygems.org/profiles/mattwynne)
|
25
25
|
* [Jonathan Owers](https://rubygems.org/profiles/jowers)
|
26
26
|
|
27
|
-
To grant release
|
27
|
+
To grant release privilege, issue the following command:
|
28
28
|
|
29
29
|
gem owner cucumber-tcl --add <NEW OWNER RUBYGEMS EMAIL>
|
@@ -46,3 +46,110 @@ Feature: Define a step
|
|
46
46
|
Hello 123
|
47
47
|
"""
|
48
48
|
|
49
|
+
Scenario: Define a feature with no steps file
|
50
|
+
Given a file named "features/test.feature" with:
|
51
|
+
"""
|
52
|
+
Feature:
|
53
|
+
Scenario:
|
54
|
+
Given undefined
|
55
|
+
"""
|
56
|
+
And a file named "features/support/env.rb" with:
|
57
|
+
"""
|
58
|
+
require 'cucumber/tcl'
|
59
|
+
"""
|
60
|
+
When I run `cucumber`
|
61
|
+
Then it should pass with:
|
62
|
+
"""
|
63
|
+
Feature:
|
64
|
+
|
65
|
+
Scenario: # features/test.feature:2
|
66
|
+
Given undefined # features/test.feature:3
|
67
|
+
|
68
|
+
1 scenario (1 undefined)
|
69
|
+
1 step (1 undefined)
|
70
|
+
"""
|
71
|
+
|
72
|
+
Scenario: Define a failing step
|
73
|
+
Given a file named "features/test.feature" with:
|
74
|
+
"""
|
75
|
+
Feature:
|
76
|
+
Scenario:
|
77
|
+
Given failing
|
78
|
+
"""
|
79
|
+
And a file named "features/support/env.rb" with:
|
80
|
+
"""
|
81
|
+
require 'cucumber/tcl'
|
82
|
+
"""
|
83
|
+
And a file named "features/step_defintions/steps.tcl" with:
|
84
|
+
"""
|
85
|
+
Given {^failing$} {
|
86
|
+
error "Failing Step"
|
87
|
+
}
|
88
|
+
"""
|
89
|
+
When I run `cucumber`
|
90
|
+
Then it should fail with:
|
91
|
+
"""
|
92
|
+
Feature:
|
93
|
+
|
94
|
+
Scenario: # features/test.feature:2
|
95
|
+
Given failing # features/test.feature:3
|
96
|
+
Failing Step
|
97
|
+
while executing
|
98
|
+
"error "Failing Step""
|
99
|
+
("eval" body line 2)
|
100
|
+
invoked from within
|
101
|
+
"eval $existing_step_body" (Tcl::Error)
|
102
|
+
features/test.feature:3:in `Given failing'
|
103
|
+
|
104
|
+
Failing Scenarios:
|
105
|
+
cucumber features/test.feature:2 # Scenario:
|
106
|
+
|
107
|
+
1 scenario (1 failed)
|
108
|
+
1 step (1 failed)
|
109
|
+
"""
|
110
|
+
|
111
|
+
Scenario: Define a step that calls a failing proc
|
112
|
+
Given a file named "features/test.feature" with:
|
113
|
+
"""
|
114
|
+
Feature:
|
115
|
+
Scenario:
|
116
|
+
Given failing
|
117
|
+
"""
|
118
|
+
And a file named "features/support/env.rb" with:
|
119
|
+
"""
|
120
|
+
require 'cucumber/tcl'
|
121
|
+
"""
|
122
|
+
And a file named "features/step_defintions/steps.tcl" with:
|
123
|
+
"""
|
124
|
+
Given {^failing$} {
|
125
|
+
failing_proc
|
126
|
+
}
|
127
|
+
proc failing_proc {} {
|
128
|
+
error "Failing Step"
|
129
|
+
}
|
130
|
+
"""
|
131
|
+
When I run `cucumber`
|
132
|
+
Then it should fail with:
|
133
|
+
"""
|
134
|
+
Feature:
|
135
|
+
|
136
|
+
Scenario: # features/test.feature:2
|
137
|
+
Given failing # features/test.feature:3
|
138
|
+
Failing Step
|
139
|
+
while executing
|
140
|
+
"error "Failing Step""
|
141
|
+
(procedure "failing_proc" line 2)
|
142
|
+
invoked from within
|
143
|
+
"failing_proc"
|
144
|
+
("eval" body line 2)
|
145
|
+
invoked from within
|
146
|
+
"eval $existing_step_body" (Tcl::Error)
|
147
|
+
features/test.feature:3:in `Given failing'
|
148
|
+
|
149
|
+
Failing Scenarios:
|
150
|
+
cucumber features/test.feature:2 # Scenario:
|
151
|
+
|
152
|
+
1 scenario (1 failed)
|
153
|
+
1 step (1 failed)
|
154
|
+
"""
|
155
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Feature: A step that is still pending implementation
|
2
|
+
|
3
|
+
Calling `pending` from a Tcl step definition will fail that scenario as
|
4
|
+
pending.
|
5
|
+
|
6
|
+
Still to do:
|
7
|
+
|
8
|
+
- [pass a message back about why the step is pending](https://github.com/cucumber/cucumber-ruby-tcl/issues/24)
|
9
|
+
- [display the file:line where `pending` was called in backtrace](https://github.com/cucumber/cucumber-ruby-tcl/issues/25)
|
10
|
+
|
11
|
+
Scenario: A un-implemented step returns pending
|
12
|
+
Given a file named "features/test.feature" with:
|
13
|
+
"""
|
14
|
+
Feature:
|
15
|
+
Scenario:
|
16
|
+
Given pending
|
17
|
+
"""
|
18
|
+
And a file named "features/support/env.rb" with:
|
19
|
+
"""
|
20
|
+
require 'cucumber/tcl'
|
21
|
+
"""
|
22
|
+
And a file named "features/step_defintions/steps.tcl" with:
|
23
|
+
"""
|
24
|
+
Given {^pending$} {
|
25
|
+
pending
|
26
|
+
}
|
27
|
+
"""
|
28
|
+
When I run `cucumber -q`
|
29
|
+
Then it should pass with:
|
30
|
+
"""
|
31
|
+
Feature:
|
32
|
+
|
33
|
+
Scenario:
|
34
|
+
Given pending
|
35
|
+
TODO: Step not yet implemented (Cucumber::Core::Test::Result::Pending)
|
36
|
+
features/test.feature:3:in `Given pending'
|
37
|
+
|
38
|
+
1 scenario (1 pending)
|
39
|
+
1 step (1 pending)
|
40
|
+
"""
|
41
|
+
|
data/lib/cucumber/tcl.rb
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
require 'cucumber/tcl/activate_steps'
|
2
|
+
require 'cucumber/tcl/framework'
|
2
3
|
require 'cucumber/tcl/step_definitions'
|
3
4
|
|
5
|
+
# Use Cucumber's configuration hook to install the plugin
|
4
6
|
if respond_to?(:AfterConfiguration)
|
5
7
|
AfterConfiguration do |config|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
Cucumber::Tcl.install config
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Cucumber
|
13
|
+
module Tcl
|
14
|
+
|
15
|
+
def self.install(cucumber_config)
|
16
|
+
create_step_definitions = lambda {
|
17
|
+
StepDefinitions.new(Framework.new)
|
18
|
+
}
|
19
|
+
cucumber_config.filters << ActivateSteps.new(create_step_definitions)
|
20
|
+
end
|
21
|
+
|
10
22
|
end
|
11
23
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Tcl
|
3
|
+
class Framework
|
4
|
+
TCL_FRAMEWORK_PATH = File.dirname(__FILE__) + '/framework.tcl'
|
5
|
+
|
6
|
+
def initialize(path = TCL_FRAMEWORK_PATH)
|
7
|
+
@tcl = ::Tcl::Interp.load_from_file(path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def step_definition_exists?(step_name)
|
11
|
+
@tcl.proc('step_definition_exists').call(step_name) == "1"
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute_step_definition(*args)
|
15
|
+
@tcl.proc('execute_step_definition').call(*args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,36 +1,42 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
}
|
2
|
+
namespace eval ::cucumber:: {
|
3
|
+
variable STEPS [list]
|
4
|
+
variable TEST
|
5
|
+
|
6
|
+
# Set a variable to allow this to be more easily tested
|
7
|
+
if {[info exists env(TEST)] && $::env(TEST) eq 1} {
|
8
|
+
set TEST 1
|
9
|
+
} else {
|
10
|
+
set TEST 0
|
11
|
+
}
|
8
12
|
|
9
|
-
|
10
|
-
|
13
|
+
namespace export step_definition_exists
|
14
|
+
namespace export execute_step_definition
|
15
|
+
namespace export Given
|
16
|
+
namespace export When
|
17
|
+
namespace export Then
|
18
|
+
namespace export pending
|
19
|
+
|
20
|
+
}
|
11
21
|
|
12
22
|
#
|
13
23
|
# Define procs to match Gherkin keyworkds that put data in the STEPS array
|
14
24
|
#
|
15
|
-
proc Given args {
|
16
|
-
_add_step {*}$args
|
17
|
-
}
|
18
|
-
|
19
|
-
proc When args {
|
25
|
+
proc ::cucumber::Given args {
|
20
26
|
_add_step {*}$args
|
21
27
|
}
|
22
28
|
|
23
|
-
proc
|
29
|
+
proc ::cucumber::When args {
|
24
30
|
_add_step {*}$args
|
25
31
|
}
|
26
32
|
|
27
|
-
proc
|
33
|
+
proc ::cucumber::Then args {
|
28
34
|
_add_step {*}$args
|
29
35
|
}
|
30
36
|
|
31
|
-
proc _add_step args {
|
37
|
+
proc ::cucumber::_add_step args {
|
32
38
|
|
33
|
-
|
39
|
+
variable STEPS
|
34
40
|
|
35
41
|
if {[llength $args] == 2} {
|
36
42
|
set re [lindex $args 0]
|
@@ -50,21 +56,21 @@ proc _add_step args {
|
|
50
56
|
|
51
57
|
#
|
52
58
|
# Procs needed by cucumber for checking and executing steps
|
53
|
-
proc step_definition_exists { step_name } {
|
59
|
+
proc ::cucumber::step_definition_exists { step_name } {
|
54
60
|
set res [_search_steps $step_name 0]
|
55
61
|
return $res
|
56
62
|
}
|
57
63
|
|
58
64
|
|
59
|
-
proc execute_step_definition { step_name {multiline_args {}} } {
|
65
|
+
proc ::cucumber::execute_step_definition { step_name {multiline_args {}} } {
|
60
66
|
set res [_search_steps $step_name 1 $multiline_args]
|
61
67
|
return $res
|
62
68
|
|
63
69
|
}
|
64
70
|
|
65
71
|
|
66
|
-
proc _search_steps {step_name {execute 0} {multiline_args {}}} {
|
67
|
-
|
72
|
+
proc ::cucumber::_search_steps {step_name {execute 0} {multiline_args {}}} {
|
73
|
+
variable STEPS
|
68
74
|
|
69
75
|
foreach step $STEPS {
|
70
76
|
set existing_step_name [lindex $step 0]
|
@@ -81,7 +87,14 @@ proc _search_steps {step_name {execute 0} {multiline_args {}}} {
|
|
81
87
|
}
|
82
88
|
|
83
89
|
if {$execute == 1} {
|
84
|
-
|
90
|
+
if {[catch {
|
91
|
+
eval $existing_step_body
|
92
|
+
} msg]} {
|
93
|
+
if {$msg eq "pending"} {
|
94
|
+
return "pending"
|
95
|
+
}
|
96
|
+
error $::errorInfo
|
97
|
+
}
|
85
98
|
}
|
86
99
|
return 1
|
87
100
|
}
|
@@ -89,9 +102,20 @@ proc _search_steps {step_name {execute 0} {multiline_args {}}} {
|
|
89
102
|
return 0
|
90
103
|
}
|
91
104
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
105
|
+
proc ::cucumber::source_steps args {
|
106
|
+
variable TEST
|
107
|
+
|
108
|
+
if {$TEST ne 1} {
|
109
|
+
#TODO let that path be configurable from cucumber-ruby
|
110
|
+
foreach x [glob -nocomplain features/**/*.tcl] {
|
111
|
+
source $x
|
112
|
+
}
|
96
113
|
}
|
97
114
|
}
|
115
|
+
|
116
|
+
proc ::cucumber::pending args {
|
117
|
+
error "pending"
|
118
|
+
}
|
119
|
+
|
120
|
+
namespace import ::cucumber::*
|
121
|
+
::cucumber::source_steps
|
@@ -5,9 +5,8 @@ module Cucumber
|
|
5
5
|
module Tcl
|
6
6
|
|
7
7
|
class StepDefinitions
|
8
|
-
def initialize(
|
9
|
-
|
10
|
-
@tcl = ::Tcl::Interp.load_from_file(path)
|
8
|
+
def initialize(tcl_framework)
|
9
|
+
@tcl_framework = tcl_framework
|
11
10
|
end
|
12
11
|
|
13
12
|
def attempt_to_activate(test_step)
|
@@ -18,20 +17,33 @@ module Cucumber
|
|
18
17
|
private
|
19
18
|
|
20
19
|
def match?(test_step)
|
21
|
-
|
22
|
-
@tcl.proc('step_definition_exists').call(step_name) == "1"
|
20
|
+
@tcl_framework.step_definition_exists?(test_step.name)
|
23
21
|
end
|
24
22
|
|
25
23
|
def action_for(test_step)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
arguments = ArgumentList.new(test_step)
|
25
|
+
proc {
|
26
|
+
response = ExecuteResponse.new(@tcl_framework.execute_step_definition(*arguments))
|
27
|
+
response.raise_any_pending_error
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
class ExecuteResponse
|
32
|
+
def initialize(raw)
|
33
|
+
@raw = raw
|
34
|
+
end
|
35
|
+
|
36
|
+
def raise_any_pending_error
|
37
|
+
if @raw == "pending"
|
38
|
+
raise Cucumber::Core::Test::Result::Pending.new("TODO: Step not yet implemented")
|
39
|
+
end
|
40
|
+
end
|
30
41
|
end
|
31
42
|
|
32
43
|
class ArgumentList
|
33
|
-
def initialize(
|
34
|
-
@arguments =
|
44
|
+
def initialize(test_step)
|
45
|
+
@arguments = [test_step.name]
|
46
|
+
test_step.source.last.multiline_arg.describe_to self
|
35
47
|
end
|
36
48
|
|
37
49
|
def doc_string(arg)
|
@@ -2,40 +2,41 @@ package require tcltest 2
|
|
2
2
|
namespace import tcltest::*
|
3
3
|
|
4
4
|
source "./lib/cucumber/tcl/framework.tcl"
|
5
|
+
namespace import cucumber::*
|
5
6
|
|
6
7
|
#
|
7
8
|
# Test Given
|
8
9
|
#
|
9
10
|
test Given-1 {calling Given with 2 parameters adds a new entry to the STEPS list with an empty parameters list} {
|
10
11
|
-setup {
|
11
|
-
set ::STEPS [list]
|
12
|
+
set ::cucumber::STEPS [list]
|
12
13
|
}
|
13
14
|
-body {
|
14
15
|
Given {^Regular Expression$} { puts "Given RegExp" }
|
15
|
-
expr { [llength $::STEPS] == 1 && [llength [lindex $::STEPS 0]] == 3}
|
16
|
+
expr { [llength $::cucumber::STEPS] == 1 && [llength [lindex $::cucumber::STEPS 0]] == 3}
|
16
17
|
}
|
17
18
|
-result 1
|
18
19
|
}
|
19
20
|
|
20
21
|
test Given-2 {calling Given twice adds 2 entries to the STEPS list} {
|
21
22
|
-setup {
|
22
|
-
set ::STEPS [list]
|
23
|
+
set ::cucumber::STEPS [list]
|
23
24
|
}
|
24
25
|
-body {
|
25
26
|
Given {^Regular Expression$} { puts "Given RegExp" }
|
26
27
|
Given {^Regular Expression 2$} { puts "Given RegExp 2" }
|
27
|
-
expr { [llength $::STEPS] == 2 && [llength [lindex $::STEPS 0]] == 3}
|
28
|
+
expr { [llength $::cucumber::STEPS] == 2 && [llength [lindex $::cucumber::STEPS 0]] == 3}
|
28
29
|
}
|
29
30
|
-result 1
|
30
31
|
}
|
31
32
|
|
32
33
|
test Given-3 {calling Given with 3 parameters adds a new entry to the STEPS list} {
|
33
34
|
-setup {
|
34
|
-
set ::STEPS [list]
|
35
|
+
set ::cucumber::STEPS [list]
|
35
36
|
}
|
36
37
|
-body {
|
37
38
|
Given {^Regular Expression (\d+)$} {match} { puts "Given RegExp $match" }
|
38
|
-
expr { [llength $::STEPS] == 1 && [llength [lindex $::STEPS 0]] == 3}
|
39
|
+
expr { [llength $::cucumber::STEPS] == 1 && [llength [lindex $::cucumber::STEPS 0]] == 3}
|
39
40
|
}
|
40
41
|
-result 1
|
41
42
|
}
|
@@ -45,41 +46,41 @@ test Given-3 {calling Given with 3 parameters adds a new entry to the STEPS list
|
|
45
46
|
#
|
46
47
|
test _add_step-1 {calling _add_step with 2 parameters adds a new entry to the STEPS list with an empty parameters list} {
|
47
48
|
-setup {
|
48
|
-
set ::STEPS [list]
|
49
|
+
set ::cucumber::STEPS [list]
|
49
50
|
}
|
50
51
|
-body {
|
51
|
-
_add_step {^Regular Expression$} { puts "Given RegExp" }
|
52
|
-
expr { [llength $::STEPS] == 1 && [llength [lindex $::STEPS 0]] == 3}
|
52
|
+
::cucumber::_add_step {^Regular Expression$} { puts "Given RegExp" }
|
53
|
+
expr { [llength $::cucumber::STEPS] == 1 && [llength [lindex $::cucumber::STEPS 0]] == 3}
|
53
54
|
}
|
54
55
|
-result 1
|
55
56
|
}
|
56
57
|
|
57
58
|
test _add_step-2 {calling _add_step twice adds 2 entries to the STEPS list} {
|
58
59
|
-setup {
|
59
|
-
set ::STEPS [list]
|
60
|
+
set ::cucumber::STEPS [list]
|
60
61
|
}
|
61
62
|
-body {
|
62
|
-
_add_step {^Regular Expression$} { puts "Given RegExp" }
|
63
|
-
_add_step {^Regular Expression 2$} { puts "Given RegExp 2" }
|
64
|
-
expr { [llength $::STEPS] == 2 && [llength [lindex $::STEPS 0]] == 3}
|
63
|
+
::cucumber::_add_step {^Regular Expression$} { puts "Given RegExp" }
|
64
|
+
::cucumber::_add_step {^Regular Expression 2$} { puts "Given RegExp 2" }
|
65
|
+
expr { [llength $::cucumber::STEPS] == 2 && [llength [lindex $::cucumber::STEPS 0]] == 3}
|
65
66
|
}
|
66
67
|
-result 1
|
67
68
|
}
|
68
69
|
|
69
70
|
test _add_step-3 {calling _add_step with 3 parameters adds a new entry to the STEPS list} {
|
70
71
|
-setup {
|
71
|
-
set ::STEPS [list]
|
72
|
+
set ::cucumber::STEPS [list]
|
72
73
|
}
|
73
74
|
-body {
|
74
|
-
_add_step {^Regular Expression (\d+)$} {match} { puts "Given RegExp $match" }
|
75
|
-
expr { [llength $::STEPS] == 1 && [llength [lindex $::STEPS 0]] == 3}
|
75
|
+
::cucumber::_add_step {^Regular Expression (\d+)$} {match} { puts "Given RegExp $match" }
|
76
|
+
expr { [llength $::cucumber::STEPS] == 1 && [llength [lindex $::cucumber::STEPS 0]] == 3}
|
76
77
|
}
|
77
78
|
-result 1
|
78
79
|
}
|
79
80
|
|
80
81
|
test _add_step-4 {calling _add_step with more than 3 parameters adds a new entry to the STEPS list} {
|
81
82
|
-body {
|
82
|
-
_add_step {^Match1 (\w+) Match2 (\d+) Match3 (\d+)$} {match1} {match2} {match3} { puts "Given RegExp $match" }
|
83
|
+
::cucumber::_add_step {^Match1 (\w+) Match2 (\d+) Match3 (\d+)$} {match1} {match2} {match3} { puts "Given RegExp $match" }
|
83
84
|
}
|
84
85
|
-returnCodes error
|
85
86
|
-result {The parameters for this procedure are regular_expression ?list_of_capture_variables? body}
|
@@ -92,12 +93,12 @@ test _add_step-4 {calling _add_step with more than 3 parameters adds a new entry
|
|
92
93
|
#
|
93
94
|
test When-1 {calling When adds a new entry to the STEPS list} {
|
94
95
|
-setup {
|
95
|
-
set ::STEPS [list]
|
96
|
+
set ::cucumber::STEPS [list]
|
96
97
|
}
|
97
98
|
-body {
|
98
99
|
When {^Regular Expression$} { puts "When RegExp" }
|
99
|
-
expr { [llength $::STEPS] == 1 }
|
100
|
-
expr { [llength $::STEPS] == 1 && [llength [lindex $::STEPS 0]] == 3}
|
100
|
+
expr { [llength $::cucumber::STEPS] == 1 }
|
101
|
+
expr { [llength $::cucumber::STEPS] == 1 && [llength [lindex $::cucumber::STEPS 0]] == 3}
|
101
102
|
}
|
102
103
|
-result 1
|
103
104
|
}
|
@@ -109,27 +110,11 @@ test When-1 {calling When adds a new entry to the STEPS list} {
|
|
109
110
|
#
|
110
111
|
test Then-1 {calling Then adds a new entry to the STEPS list} {
|
111
112
|
-setup {
|
112
|
-
set ::STEPS [list]
|
113
|
+
set ::cucumber::STEPS [list]
|
113
114
|
}
|
114
115
|
-body {
|
115
116
|
Then {^Regular Expression$} { puts "Then RegExp" }
|
116
|
-
expr { [llength $::STEPS] == 1 && [llength [lindex $::STEPS 0]] == 3}
|
117
|
-
}
|
118
|
-
-result 1
|
119
|
-
}
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
#
|
124
|
-
# Test And
|
125
|
-
#
|
126
|
-
test And-1 {calling And adds a new entry to the STEPS list} {
|
127
|
-
-setup {
|
128
|
-
set ::STEPS [list]
|
129
|
-
}
|
130
|
-
-body {
|
131
|
-
And {^Regular Expression$} { puts "And RegExp" }
|
132
|
-
expr { [llength $::STEPS] == 1 && [llength [lindex $::STEPS 0]] == 3}
|
117
|
+
expr { [llength $::cucumber::STEPS] == 1 && [llength [lindex $::cucumber::STEPS 0]] == 3}
|
133
118
|
}
|
134
119
|
-result 1
|
135
120
|
}
|
@@ -141,56 +126,56 @@ test And-1 {calling And adds a new entry to the STEPS list} {
|
|
141
126
|
#
|
142
127
|
test _search_steps-1 {_search_steps returns 0 if there are no existing steps} {
|
143
128
|
-setup {
|
144
|
-
set ::STEPS [list]
|
129
|
+
set ::cucumber::STEPS [list]
|
145
130
|
}
|
146
131
|
-body {
|
147
|
-
_search_steps {Unknown Regexp}
|
132
|
+
::cucumber::_search_steps {Unknown Regexp}
|
148
133
|
}
|
149
134
|
-result 0
|
150
135
|
}
|
151
136
|
|
152
137
|
test _search_steps-2 {_search_steps returns 0 if there are no matching steps} {
|
153
138
|
-setup {
|
154
|
-
set ::STEPS [list [list {^First Step$} {} {puts "First Step"}]]
|
139
|
+
set ::cucumber::STEPS [list [list {^First Step$} {} {puts "First Step"}]]
|
155
140
|
}
|
156
141
|
-body {
|
157
|
-
_search_steps {Unknown Regexp}
|
142
|
+
::cucumber::_search_steps {Unknown Regexp}
|
158
143
|
}
|
159
144
|
-result 0
|
160
145
|
}
|
161
146
|
|
162
147
|
test _search_steps-3 {_search_steps returns 1 if there is a matching step} {
|
163
148
|
-setup {
|
164
|
-
set ::STEPS [list [list {^First Step$} {} {puts "First Step"}]]
|
149
|
+
set ::cucumber::STEPS [list [list {^First Step$} {} {puts "First Step"}]]
|
165
150
|
}
|
166
151
|
-body {
|
167
|
-
_search_steps {First Step}
|
152
|
+
::cucumber::_search_steps {First Step}
|
168
153
|
}
|
169
154
|
-result 1
|
170
155
|
}
|
171
156
|
|
172
157
|
test _search_steps-4 {_search_steps returns 1 if there is a matching step with multiple values in STEPS} {
|
173
158
|
-setup {
|
174
|
-
set ::STEPS [list \
|
159
|
+
set ::cucumber::STEPS [list \
|
175
160
|
[list {^First Step$} {} {puts "First Step"}] \
|
176
161
|
[list {^Second Step$} {} {puts "Second Step"}] \
|
177
162
|
]
|
178
163
|
}
|
179
164
|
-body {
|
180
|
-
_search_steps {Second Step}
|
165
|
+
::cucumber::_search_steps {Second Step}
|
181
166
|
}
|
182
167
|
-result 1
|
183
168
|
}
|
184
169
|
|
185
170
|
test _search_steps-5 {_search_steps returns 1 and executes body of step if there is a matching step and execute is set to 1} {
|
186
171
|
-setup {
|
187
|
-
set ::STEPS [list \
|
172
|
+
set ::cucumber::STEPS [list \
|
188
173
|
[list {^First Step$} {} {puts "First Step"}] \
|
189
174
|
[list {^Second Step$} {} {puts "Second Step"}] \
|
190
175
|
]
|
191
176
|
}
|
192
177
|
-body {
|
193
|
-
_search_steps {Second Step} {1}
|
178
|
+
::cucumber::_search_steps {Second Step} {1}
|
194
179
|
}
|
195
180
|
-result 1
|
196
181
|
-match glob
|
@@ -199,13 +184,13 @@ test _search_steps-5 {_search_steps returns 1 and executes body of step if there
|
|
199
184
|
|
200
185
|
test _search_steps-6 {_search_steps returns 1 and executes body of step if there is a matching step and execute is set to 1 with a parameter in the match} {
|
201
186
|
-setup {
|
202
|
-
set ::STEPS [list \
|
187
|
+
set ::cucumber::STEPS [list \
|
203
188
|
[list {^First Step$} {} {puts "First Step"}] \
|
204
189
|
[list {^Second (\w+)$} {match} {puts "Second $match"}] \
|
205
190
|
]
|
206
191
|
}
|
207
192
|
-body {
|
208
|
-
_search_steps {Second Step} {1}
|
193
|
+
::cucumber::_search_steps {Second Step} {1}
|
209
194
|
}
|
210
195
|
-result 1
|
211
196
|
-match glob
|
@@ -214,13 +199,13 @@ test _search_steps-6 {_search_steps returns 1 and executes body of step if there
|
|
214
199
|
|
215
200
|
test _search_steps-7 {_search_steps returns 1 and executes body of step if there is a matching step and execute is set to 1 with 2 parameters in the match} {
|
216
201
|
-setup {
|
217
|
-
set ::STEPS [list \
|
202
|
+
set ::cucumber::STEPS [list \
|
218
203
|
[list {^First Step$} {} {puts "First Step"}] \
|
219
204
|
[list {^(\w+) (\w+)$} {match1 match2} {puts "$match1 $match2"}] \
|
220
205
|
]
|
221
206
|
}
|
222
207
|
-body {
|
223
|
-
_search_steps {Second Step} {1}
|
208
|
+
::cucumber::_search_steps {Second Step} {1}
|
224
209
|
}
|
225
210
|
-result 1
|
226
211
|
-match glob
|
@@ -230,13 +215,13 @@ test _search_steps-7 {_search_steps returns 1 and executes body of step if there
|
|
230
215
|
# Testing multiline args
|
231
216
|
test _search_steps-8 {_search_steps returns 1 and executes body of step if there is a matching step, execute is set to 1 and there is a multiline_arg passed in} {
|
232
217
|
-setup {
|
233
|
-
set ::STEPS [list \
|
218
|
+
set ::cucumber::STEPS [list \
|
234
219
|
[list {^First Step$} {} {puts "First Step"}] \
|
235
220
|
[list {^Second Step:$} {content} {puts "$content"}] \
|
236
221
|
]
|
237
222
|
}
|
238
223
|
-body {
|
239
|
-
_search_steps {Second Step:} {1} {Multiline Content}
|
224
|
+
::cucumber::_search_steps {Second Step:} {1} {Multiline Content}
|
240
225
|
}
|
241
226
|
-result 1
|
242
227
|
-match glob
|
@@ -245,19 +230,41 @@ test _search_steps-8 {_search_steps returns 1 and executes body of step if there
|
|
245
230
|
|
246
231
|
test _search_steps-9 {_search_steps returns 1 and executes body of step if there is a matching step, execute is set to 1 and there is a multiline_arg passed in and there is a parameter match in the regexp} {
|
247
232
|
-setup {
|
248
|
-
set ::STEPS [list \
|
233
|
+
set ::cucumber::STEPS [list \
|
249
234
|
[list {^First Step$} {} {puts "First Step"}] \
|
250
235
|
[list {^Second (\w+):$} {match1 content} {puts "content=$content, match=$match1"}] \
|
251
236
|
]
|
252
237
|
}
|
253
238
|
-body {
|
254
|
-
_search_steps {Second Step:} {1} {Multiline Content}
|
239
|
+
::cucumber::_search_steps {Second Step:} {1} {Multiline Content}
|
255
240
|
}
|
256
241
|
-result 1
|
257
242
|
-match glob
|
258
243
|
-output {content=Multiline Content, match=Step*}
|
259
244
|
}
|
260
245
|
|
246
|
+
test _search_steps-10 {_search_steps returns "pending" if there is a matching step, execute is set to 1 and the proc to be executed is pending} {
|
247
|
+
-setup {
|
248
|
+
set ::cucumber::STEPS [list \
|
249
|
+
[list {^Pending$} {} {pending}] \
|
250
|
+
]
|
251
|
+
}
|
252
|
+
-body {
|
253
|
+
::cucumber::_search_steps {Pending} {1} {}
|
254
|
+
}
|
255
|
+
-result "pending"
|
256
|
+
}
|
257
|
+
|
258
|
+
#
|
259
|
+
# Test Pending
|
260
|
+
#
|
261
|
+
test pending-1 {pending returns an error with the text "pending"} {
|
262
|
+
-setup {}
|
263
|
+
-body {pending}
|
264
|
+
-returnCodes error
|
265
|
+
-result {pending}
|
266
|
+
}
|
267
|
+
|
261
268
|
#
|
262
269
|
# Cleanup
|
263
270
|
#
|
data/lib/cucumber/tcl/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
@@ -4,13 +4,27 @@ require 'cucumber/core/test/step'
|
|
4
4
|
|
5
5
|
module Cucumber::Tcl
|
6
6
|
describe StepDefinitions do
|
7
|
+
let(:location) { double }
|
8
|
+
let(:test_step) {
|
9
|
+
ast_step = double(name: double, location: location, multiline_arg: Cucumber::Core::Ast::EmptyMultilineArgument.new)
|
10
|
+
Cucumber::Core::Test::Step.new([ ast_step ])
|
11
|
+
}
|
7
12
|
|
8
13
|
it "can activate a passing tcl step" do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
test_step = Cucumber::Core::Test::Step.new([ ast_step ])
|
14
|
+
path = File.dirname(__FILE__) + '/fixtures/everything_ok.tcl'
|
15
|
+
tcl_framework = Framework.new(path)
|
16
|
+
step_definitions = StepDefinitions.new(tcl_framework)
|
13
17
|
expect(step_definitions.attempt_to_activate(test_step).location).to eq location
|
14
18
|
end
|
19
|
+
|
20
|
+
it "raises a pending error when TCL returns a pending message" do
|
21
|
+
tcl_framework = double(
|
22
|
+
step_definition_exists?: true,
|
23
|
+
execute_step_definition: "pending"
|
24
|
+
)
|
25
|
+
step_definitions = StepDefinitions.new(tcl_framework)
|
26
|
+
result = step_definitions.attempt_to_activate(test_step).execute
|
27
|
+
expect(result).to be_a Cucumber::Core::Test::Result::Pending
|
28
|
+
end
|
15
29
|
end
|
16
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-tcl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-05-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: ruby-tcl
|
@@ -125,11 +125,13 @@ files:
|
|
125
125
|
- features/data_tables.feature
|
126
126
|
- features/define_a_step.feature
|
127
127
|
- features/doc_strings.feature
|
128
|
+
- features/pending_step.feature
|
128
129
|
- features/reset_state.feature
|
129
130
|
- features/support/aruba.rb
|
130
131
|
- lib/cucumber/tcl.rb
|
131
132
|
- lib/cucumber/tcl/activate_steps.rb
|
132
133
|
- lib/cucumber/tcl/data_table.rb
|
134
|
+
- lib/cucumber/tcl/framework.rb
|
133
135
|
- lib/cucumber/tcl/framework.tcl
|
134
136
|
- lib/cucumber/tcl/step_definitions.rb
|
135
137
|
- lib/cucumber/tcl/test/test_framework.tcl
|
@@ -162,6 +164,6 @@ rubyforge_project:
|
|
162
164
|
rubygems_version: 1.8.23
|
163
165
|
signing_key:
|
164
166
|
specification_version: 3
|
165
|
-
summary: cucumber-tcl-0.0.
|
167
|
+
summary: cucumber-tcl-0.0.5
|
166
168
|
test_files: []
|
167
169
|
has_rdoc:
|