cucumber-tcl 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +29 -0
- data/README.md +36 -1
- data/features/data_tables.feature +27 -0
- data/features/reset_state.feature +37 -0
- data/lib/cucumber/tcl.rb +4 -2
- data/lib/cucumber/tcl/activate_steps.rb +9 -5
- data/lib/cucumber/tcl/data_table.rb +24 -0
- data/lib/cucumber/tcl/framework.tcl +0 -1
- data/lib/cucumber/tcl/step_definitions.rb +12 -0
- data/lib/cucumber/tcl/version +1 -1
- data/spec/cucumber/tcl/data_table_spec.rb +13 -0
- data/spec/cucumber/tcl/fixtures/{everything_is_defined.tcl → everything_ok.tcl} +3 -0
- data/spec/cucumber/tcl/step_definitions_spec.rb +6 -8
- metadata +29 -17
- checksums.yaml +0 -7
- data/spec/cucumber/tcl/fixtures/everything_passes.tcl +0 -3
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
## Running tests
|
2
|
+
|
3
|
+
gem install bundler
|
4
|
+
bundle install
|
5
|
+
bundle exec rake
|
6
|
+
|
7
|
+
This runs tests on both the Ruby and Tcl code.
|
8
|
+
|
9
|
+
## Release Process
|
10
|
+
|
11
|
+
* Bump the version number in `lib/cucumber/tcl/version`.
|
12
|
+
|
13
|
+
Now release it
|
14
|
+
|
15
|
+
bundle update && bundle exec rake # check all tests are passing
|
16
|
+
git commit -m "Release `cat lib/cucumber/tcl/version`"
|
17
|
+
rake release
|
18
|
+
|
19
|
+
## Gaining Release Karma
|
20
|
+
|
21
|
+
To become a release manager, create a pull request adding your name to the list below, and include your [Rubygems email address](https://rubygems.org/sign_up) in the ticket. One of the existing Release managers will then add you.
|
22
|
+
|
23
|
+
Current release managers:
|
24
|
+
* [Matt Wynne](https://rubygems.org/profiles/mattwynne)
|
25
|
+
* [Jonathan Owers](https://rubygems.org/profiles/jowers)
|
26
|
+
|
27
|
+
To grant release karma, issue the following command:
|
28
|
+
|
29
|
+
gem owner cucumber-tcl --add <NEW OWNER RUBYGEMS EMAIL>
|
data/README.md
CHANGED
@@ -12,7 +12,6 @@ You'll need the following:
|
|
12
12
|
|
13
13
|
* tcl8.5 and dev libraries
|
14
14
|
* ruby > 1.9.1 along with its dev libraries
|
15
|
-
* [Cucumber-Ruby](https://github.com/cucumber/cucumber)
|
16
15
|
|
17
16
|
How to use
|
18
17
|
----------
|
@@ -53,3 +52,39 @@ If your regular expression captures any matches, you should provide a list of va
|
|
53
52
|
puts "$quantity cucumbers bought. Price was $price"
|
54
53
|
}
|
55
54
|
|
55
|
+
You can use basic tables in your scenarios. The data from the table s made available to your step definition, via the last variable name you pass into the capture list. For example, if you had the following step in your feature:
|
56
|
+
|
57
|
+
Given I have added the following products to my shopping cart:
|
58
|
+
| apple | £2.00 |
|
59
|
+
| orange | £3.00 |
|
60
|
+
| banana | £1.50 |
|
61
|
+
|
62
|
+
I could write the step definition for the Given step as:
|
63
|
+
|
64
|
+
Given {^I have added the following products to my shopping cart:$} {table_data} {
|
65
|
+
puts "$table_data"
|
66
|
+
}
|
67
|
+
|
68
|
+
The data in the table is provided as a list of lists, so in the above example, table data would look like:
|
69
|
+
|
70
|
+
{"apple" "£2.00"} {"orange" "£3.00"} {"banana" "£1.50"}
|
71
|
+
|
72
|
+
meaning you can access each element using `lindex`, e.g.
|
73
|
+
|
74
|
+
puts [lindex [lindex $table_data 0] 0]
|
75
|
+
apple
|
76
|
+
|
77
|
+
If your step definition captures a match in the step definition as well as has a table, the table variable will always be last, e.g.
|
78
|
+
|
79
|
+
When I buy the following items from Tesco:
|
80
|
+
| cabbage |
|
81
|
+
| potato |
|
82
|
+
| onion |
|
83
|
+
|
84
|
+
and in your step definition, you might have
|
85
|
+
|
86
|
+
Given {^I buy the following items from (\w+):$} {store items} {
|
87
|
+
puts "I've been shopping at $store"
|
88
|
+
puts "The first item I bought was [lindex $items 0]"
|
89
|
+
}
|
90
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Feature: DataTables
|
2
|
+
|
3
|
+
@wip
|
4
|
+
Scenario: Match a step with a DataTable
|
5
|
+
Given a file named "features/test.feature" with:
|
6
|
+
"""
|
7
|
+
Feature:
|
8
|
+
Scenario:
|
9
|
+
Given passing with a DataTable:
|
10
|
+
| a | b |
|
11
|
+
| c | d |
|
12
|
+
"""
|
13
|
+
And a file named "features/support/env.rb" with:
|
14
|
+
"""
|
15
|
+
require 'cucumber/tcl'
|
16
|
+
"""
|
17
|
+
And a file named "features/step_defintions/steps.tcl" with:
|
18
|
+
"""
|
19
|
+
Given {^passing with a DataTable:$} {content} {
|
20
|
+
puts $content
|
21
|
+
}
|
22
|
+
"""
|
23
|
+
When I run `cucumber`
|
24
|
+
Then it should pass with:
|
25
|
+
"""
|
26
|
+
{{a} {b}} {{c} {d}}
|
27
|
+
"""
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Feature: Reset state
|
2
|
+
|
3
|
+
In order to keep state from leaking between scenarios, by default,
|
4
|
+
we create a new Tcl interpreter for each test case.
|
5
|
+
|
6
|
+
Scenario: Set a global variable in one scenario and access it in another
|
7
|
+
Given a file named "features/test.feature" with:
|
8
|
+
"""
|
9
|
+
Feature:
|
10
|
+
Scenario:
|
11
|
+
Given I set a global variable
|
12
|
+
When I print the global variable
|
13
|
+
|
14
|
+
Scenario:
|
15
|
+
When I print the global variable
|
16
|
+
"""
|
17
|
+
And a file named "features/step_definitions/steps.tcl" with:
|
18
|
+
"""
|
19
|
+
global g
|
20
|
+
|
21
|
+
Given {^I set a global variable$} {
|
22
|
+
set ::g value
|
23
|
+
}
|
24
|
+
|
25
|
+
When {^I print the global variable$} {
|
26
|
+
puts $::g
|
27
|
+
}
|
28
|
+
"""
|
29
|
+
And a file named "features/support/env.rb" with:
|
30
|
+
"""
|
31
|
+
require 'cucumber/tcl'
|
32
|
+
"""
|
33
|
+
When I run `cucumber`
|
34
|
+
Then it should fail with:
|
35
|
+
"""
|
36
|
+
can't read "::g": no such variable
|
37
|
+
"""
|
data/lib/cucumber/tcl.rb
CHANGED
@@ -3,7 +3,9 @@ require 'cucumber/tcl/step_definitions'
|
|
3
3
|
|
4
4
|
if respond_to?(:AfterConfiguration)
|
5
5
|
AfterConfiguration do |config|
|
6
|
-
|
7
|
-
|
6
|
+
create_step_definitions = lambda {
|
7
|
+
Cucumber::Tcl::StepDefinitions.new(File.dirname(__FILE__) + '/tcl/framework.tcl')
|
8
|
+
}
|
9
|
+
config.filters << Cucumber::Tcl::ActivateSteps.new(create_step_definitions)
|
8
10
|
end
|
9
11
|
end
|
@@ -3,19 +3,23 @@ require 'cucumber/core/filter'
|
|
3
3
|
module Cucumber
|
4
4
|
module Tcl
|
5
5
|
|
6
|
-
ActivateSteps = Cucumber::Core::Filter.new(:
|
6
|
+
ActivateSteps = Cucumber::Core::Filter.new(:create_step_definitions) do
|
7
7
|
def test_case(test_case)
|
8
8
|
activated_steps = test_case.test_steps.map do |test_step|
|
9
|
-
attempt_to_activate(test_step)
|
9
|
+
step_definitions.attempt_to_activate(test_step)
|
10
10
|
end
|
11
11
|
test_case.with_steps(activated_steps).describe_to receiver
|
12
|
+
reset_step_definitons
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
17
|
+
def reset_step_definitons
|
18
|
+
@step_definitions = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def step_definitions
|
22
|
+
@step_definitions ||= create_step_definitions.call
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Tcl
|
3
|
+
|
4
|
+
# Wraps the Cucumber DataTable so that when passed through to tcl, its
|
5
|
+
# string representation is easy to parse into a tcl list.
|
6
|
+
class DataTable
|
7
|
+
def initialize(original)
|
8
|
+
@raw = original.raw
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
to_tcl_list(@raw.map { |row| to_tcl_list(row) })
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def to_tcl_list(array)
|
18
|
+
array.map { |element| "{" + element + "}" }.join(" ")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'tcl'
|
2
|
+
require 'cucumber/tcl/data_table'
|
2
3
|
|
3
4
|
module Cucumber
|
4
5
|
module Tcl
|
@@ -9,6 +10,13 @@ module Cucumber
|
|
9
10
|
@tcl = ::Tcl::Interp.load_from_file(path)
|
10
11
|
end
|
11
12
|
|
13
|
+
def attempt_to_activate(test_step)
|
14
|
+
return test_step unless match?(test_step)
|
15
|
+
test_step.with_action &action_for(test_step)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
12
20
|
def match?(test_step)
|
13
21
|
step_name = test_step.name
|
14
22
|
@tcl.proc('step_definition_exists').call(step_name) == "1"
|
@@ -30,6 +38,10 @@ module Cucumber
|
|
30
38
|
@arguments << arg.content
|
31
39
|
end
|
32
40
|
|
41
|
+
def data_table(arg)
|
42
|
+
@arguments << DataTable.new(arg)
|
43
|
+
end
|
44
|
+
|
33
45
|
def to_a
|
34
46
|
@arguments
|
35
47
|
end
|
data/lib/cucumber/tcl/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'cucumber/tcl/data_table'
|
2
|
+
require 'cucumber/core/ast/data_table'
|
3
|
+
|
4
|
+
module Cucumber::Tcl
|
5
|
+
describe DataTable do
|
6
|
+
it "#to_s converts to Tcl list of lists" do
|
7
|
+
raw = [["a", "b"], ["c", "d"]]
|
8
|
+
original = Cucumber::Core::Ast::DataTable.new(raw, Cucumber::Core::Ast::Location.new(__FILE__, 8))
|
9
|
+
table = DataTable.new(original)
|
10
|
+
expect(table.to_s).to eq '{{a} {b}} {{c} {d}}'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,18 +1,16 @@
|
|
1
1
|
require 'cucumber/tcl'
|
2
2
|
require 'cucumber/core/ast'
|
3
|
+
require 'cucumber/core/test/step'
|
3
4
|
|
4
5
|
module Cucumber::Tcl
|
5
6
|
describe StepDefinitions do
|
6
|
-
it "can query for a step definition" do
|
7
|
-
step_definitions = StepDefinitions.new(File.dirname(__FILE__) + '/fixtures/everything_is_defined.tcl')
|
8
|
-
expect(step_definitions.match?(double(name: 'passing'))).to be_truthy
|
9
|
-
end
|
10
7
|
|
11
8
|
it "can activate a passing tcl step" do
|
12
|
-
step_definitions = StepDefinitions.new(File.dirname(__FILE__) + '/fixtures/
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
step_definitions = StepDefinitions.new(File.dirname(__FILE__) + '/fixtures/everything_ok.tcl')
|
10
|
+
location = double
|
11
|
+
ast_step = double(name: double, location: location, multiline_arg: Cucumber::Core::Ast::EmptyMultilineArgument.new)
|
12
|
+
test_step = Cucumber::Core::Test::Step.new([ ast_step ])
|
13
|
+
expect(step_definitions.attempt_to_activate(test_step).location).to eq location
|
16
14
|
end
|
17
15
|
end
|
18
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
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.4
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Matt Wynne
|
@@ -10,11 +11,12 @@ authors:
|
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2015-02
|
14
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: ruby-tcl
|
17
18
|
requirement: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
18
20
|
requirements:
|
19
21
|
- - ~>
|
20
22
|
- !ruby/object:Gem::Version
|
@@ -22,6 +24,7 @@ dependencies:
|
|
22
24
|
type: :runtime
|
23
25
|
prerelease: false
|
24
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
25
28
|
requirements:
|
26
29
|
- - ~>
|
27
30
|
- !ruby/object:Gem::Version
|
@@ -29,6 +32,7 @@ dependencies:
|
|
29
32
|
- !ruby/object:Gem::Dependency
|
30
33
|
name: cucumber
|
31
34
|
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
32
36
|
requirements:
|
33
37
|
- - ~>
|
34
38
|
- !ruby/object:Gem::Version
|
@@ -36,6 +40,7 @@ dependencies:
|
|
36
40
|
type: :runtime
|
37
41
|
prerelease: false
|
38
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
39
44
|
requirements:
|
40
45
|
- - ~>
|
41
46
|
- !ruby/object:Gem::Version
|
@@ -43,6 +48,7 @@ dependencies:
|
|
43
48
|
- !ruby/object:Gem::Dependency
|
44
49
|
name: rspec
|
45
50
|
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
46
52
|
requirements:
|
47
53
|
- - ~>
|
48
54
|
- !ruby/object:Gem::Version
|
@@ -50,6 +56,7 @@ dependencies:
|
|
50
56
|
type: :development
|
51
57
|
prerelease: false
|
52
58
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
53
60
|
requirements:
|
54
61
|
- - ~>
|
55
62
|
- !ruby/object:Gem::Version
|
@@ -57,6 +64,7 @@ dependencies:
|
|
57
64
|
- !ruby/object:Gem::Dependency
|
58
65
|
name: aruba
|
59
66
|
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
60
68
|
requirements:
|
61
69
|
- - ~>
|
62
70
|
- !ruby/object:Gem::Version
|
@@ -64,6 +72,7 @@ dependencies:
|
|
64
72
|
type: :development
|
65
73
|
prerelease: false
|
66
74
|
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
67
76
|
requirements:
|
68
77
|
- - ~>
|
69
78
|
- !ruby/object:Gem::Version
|
@@ -71,6 +80,7 @@ dependencies:
|
|
71
80
|
- !ruby/object:Gem::Dependency
|
72
81
|
name: yard
|
73
82
|
requirement: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
74
84
|
requirements:
|
75
85
|
- - ~>
|
76
86
|
- !ruby/object:Gem::Version
|
@@ -78,6 +88,7 @@ dependencies:
|
|
78
88
|
type: :development
|
79
89
|
prerelease: false
|
80
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
81
92
|
requirements:
|
82
93
|
- - ~>
|
83
94
|
- !ruby/object:Gem::Version
|
@@ -85,6 +96,7 @@ dependencies:
|
|
85
96
|
- !ruby/object:Gem::Dependency
|
86
97
|
name: rake
|
87
98
|
requirement: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
88
100
|
requirements:
|
89
101
|
- - ~>
|
90
102
|
- !ruby/object:Gem::Version
|
@@ -92,6 +104,7 @@ dependencies:
|
|
92
104
|
type: :development
|
93
105
|
prerelease: false
|
94
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
95
108
|
requirements:
|
96
109
|
- - ~>
|
97
110
|
- !ruby/object:Gem::Version
|
@@ -103,53 +116,52 @@ extensions: []
|
|
103
116
|
extra_rdoc_files: []
|
104
117
|
files:
|
105
118
|
- .rspec
|
119
|
+
- CONTRIBUTING.md
|
106
120
|
- Gemfile
|
107
121
|
- README.md
|
108
122
|
- Rakefile
|
109
123
|
- circle.yml
|
110
124
|
- cucumber-tcl.gemspec
|
125
|
+
- features/data_tables.feature
|
111
126
|
- features/define_a_step.feature
|
112
127
|
- features/doc_strings.feature
|
128
|
+
- features/reset_state.feature
|
113
129
|
- features/support/aruba.rb
|
114
130
|
- lib/cucumber/tcl.rb
|
115
131
|
- lib/cucumber/tcl/activate_steps.rb
|
132
|
+
- lib/cucumber/tcl/data_table.rb
|
116
133
|
- lib/cucumber/tcl/framework.tcl
|
117
134
|
- lib/cucumber/tcl/step_definitions.rb
|
118
135
|
- lib/cucumber/tcl/test/test_framework.tcl
|
119
136
|
- lib/cucumber/tcl/version
|
120
|
-
- spec/cucumber/tcl/
|
121
|
-
- spec/cucumber/tcl/fixtures/
|
137
|
+
- spec/cucumber/tcl/data_table_spec.rb
|
138
|
+
- spec/cucumber/tcl/fixtures/everything_ok.tcl
|
122
139
|
- spec/cucumber/tcl/step_definitions_spec.rb
|
123
140
|
homepage: https://github.com/cucumber/cucumber-ruby-tcl
|
124
141
|
licenses:
|
125
142
|
- MIT
|
126
|
-
metadata: {}
|
127
143
|
post_install_message:
|
128
144
|
rdoc_options:
|
129
145
|
- --charset=UTF-8
|
130
146
|
require_paths:
|
131
147
|
- lib
|
132
148
|
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
133
150
|
requirements:
|
134
|
-
- - '>='
|
151
|
+
- - ! '>='
|
135
152
|
- !ruby/object:Gem::Version
|
136
153
|
version: 1.9.3
|
137
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
138
156
|
requirements:
|
139
|
-
- - '>='
|
157
|
+
- - ! '>='
|
140
158
|
- !ruby/object:Gem::Version
|
141
159
|
version: '0'
|
142
160
|
requirements: []
|
143
161
|
rubyforge_project:
|
144
|
-
rubygems_version:
|
162
|
+
rubygems_version: 1.8.23
|
145
163
|
signing_key:
|
146
|
-
specification_version:
|
147
|
-
summary: cucumber-tcl-0.0.
|
148
|
-
test_files:
|
149
|
-
- features/define_a_step.feature
|
150
|
-
- features/doc_strings.feature
|
151
|
-
- features/support/aruba.rb
|
152
|
-
- spec/cucumber/tcl/fixtures/everything_is_defined.tcl
|
153
|
-
- spec/cucumber/tcl/fixtures/everything_passes.tcl
|
154
|
-
- spec/cucumber/tcl/step_definitions_spec.rb
|
164
|
+
specification_version: 3
|
165
|
+
summary: cucumber-tcl-0.0.4
|
166
|
+
test_files: []
|
155
167
|
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: defc8ca2dc36af1dbba2a7401d5d29166fe4e717
|
4
|
-
data.tar.gz: 565ada350e542eac6379c4fe5b018694b8160f86
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: d614a61d2673340c6aeaa4802f869d98c9d999900a4c0ca295d91a79de7a30aaff1d08ac74d8280c3d135e32ae4f5901b2d8535c5e256fd0d671bc5d3770c5f6
|
7
|
-
data.tar.gz: 8853b3a1ad2474a20f4fdd4dea049b3f047990721f64afcb17fd1ebf2786287526154af9cb33c8bf997132d3d8fd44dfc1c89a5dd37652d5fe3cd1e31da9336d
|