yet-another-cucumber-tcl 0.0.9

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7702ff40bce2ca9b6d7b46f3295037a97a91af61b39d82091021b6bb67d49f78
4
+ data.tar.gz: 507b0fd3aff1588875256620fdffbee7ffffcdc12992a92fd81d53b0b16ce9d4
5
+ SHA512:
6
+ metadata.gz: 8847973edb86c68d6a7f0339bfe738c424d4c58322ef962d20f2d602dfc21fab77c28a1025e937b7c775b233791f45e88adf2a033a2e1d55529cf62d715cebba
7
+ data.tar.gz: 69e9638942adc193fe00993023df4e631793b668c12cc16379b74095b13377b1803ca053e3fe10be4eee157c2d97f6caa0ff6be4520ea7be4d1e91485b288eb8
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ plugins:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ NewCops: enable
7
+
8
+ Style/FrozenStringLiteralComment:
9
+ Enabled: false
10
+
11
+ # to be removed if/when done
12
+ Style/Documentation:
13
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # CHANGELOG
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ This project adheres to [Semantic Versioning](http://semver.org).
6
+
7
+ This document is formatted according to the principles of [Keep A CHANGELOG](http://keepachangelog.com).
8
+
9
+ Please visit [cucumber/CONTRIBUTING.md](CONTRIBUTING.md) for more info on how to contribute to Cucumber.
10
+
11
+ ----
12
+ ## [0.0.9] - 2026-07-17
13
+
14
+ ### Added
15
+
16
+ - Rubocop Linting
17
+ - Rake tasks (clean, spec, cucumber, rubocop, build, install)
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,6 @@
1
+ ## Running tests
2
+
3
+ bundle install
4
+ bundle exec rake
5
+
6
+ This runs tests on both the Ruby and Tcl code.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'aruba'
7
+ gem 'irb'
8
+ gem 'rake'
9
+ gem 'rspec'
10
+ gem 'rubocop'
11
+ gem 'rubocop-rake'
12
+ gem 'rubocop-rspec'
13
+ gem 'yard'
14
+ end
data/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # Cucumber Tcl
2
+
3
+ Drive your Tcl code with Cucumber.
4
+
5
+ ## Dependencies
6
+
7
+ You'll need the following:
8
+
9
+ * tcl8.5 and dev libraries
10
+ * ruby > 3.0.0 along with its dev libraries
11
+
12
+ ## How to use
13
+
14
+ First, add the `cucumber-tcl` plugin to your Gemfile:
15
+
16
+ gem 'cucumber-tcl'
17
+
18
+ Install it:
19
+
20
+ bundle install
21
+
22
+ In a file in Cucumber's load path, like `features/support/env.rb`, add the following line:
23
+
24
+ require 'cucumber/tcl'
25
+
26
+ You should now be able to start writing features, and implementing the step definitions in Tcl. These should be placed in `.tcl` files below the features directory. To create the step definitions, you're provided with `Given`, `When`, `Then` and `And` procs for you to call, for example:
27
+
28
+ Given {^I am a logged in user$} {
29
+ puts "I'm a logged in user
30
+ }
31
+
32
+ When {^I purchase a ticket$} {
33
+ puts "Purchase a ticket"
34
+ }
35
+
36
+ Then {^I receive confirmation of the purchase$} {
37
+ puts "Purchase confirmation"
38
+ }
39
+
40
+ If your regular expression captures any matches, you should provide a list of variable names as the second parameter to any of these procedure calls. These will then be available to your script, for example:
41
+
42
+ Given {^I am logged in with username (\w+)$} {username} {
43
+ puts "Username is $username"
44
+ }
45
+
46
+ Given {^I buy (\d+) cucumbers for $(\d+)$} {quantity price} {
47
+ puts "$quantity cucumbers bought. Price was $price"
48
+ }
49
+
50
+ 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:
51
+
52
+ Given I have added the following products to my shopping cart:
53
+ | apple | £2.00 |
54
+ | orange | £3.00 |
55
+ | banana | £1.50 |
56
+
57
+ I could write the step definition for the Given step as:
58
+
59
+ Given {^I have added the following products to my shopping cart:$} {table_data} {
60
+ puts "$table_data"
61
+ }
62
+
63
+ The data in the table is provided as a list of lists, so in the above example, table data would look like:
64
+
65
+ {"apple" "£2.00"} {"orange" "£3.00"} {"banana" "£1.50"}
66
+
67
+ meaning you can access each element using `lindex`, e.g.
68
+
69
+ puts [lindex [lindex $table_data 0] 0]
70
+ apple
71
+
72
+ 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.
73
+
74
+ When I buy the following items from Tesco:
75
+ | cabbage |
76
+ | potato |
77
+ | onion |
78
+
79
+ and in your step definition, you might have
80
+
81
+ Given {^I buy the following items from (\w+):$} {store items} {
82
+ puts "I've been shopping at $store"
83
+ puts "The first item I bought was [lindex $items 0]"
84
+ }
85
+
86
+ ## Resetting state between scenarios
87
+
88
+ Depending on how your test and/or application code is structured, there may be a chance of data persisting between scenarios, which could result in tests that pass or fail unexpectedly. To eliminate the risk of this, Cucumber TCL will start a new TCL interpreter between every scenario by creating a new instance of the 'framework' object, meaning that the env.tcl file is loaded each time. Whilst this will remove the data leakage risk, it may also cause your scenarios to run slowly if there is a lot of setup required for a scenario to run (eg, setting up fixture data, building a database or loading large amounts of data into memory). To override the default behaviour of starting up a new interpreter, an environment variable can be passed into the 'cucumber' command enabling the sharing of the TCL interpreter via the 'framework' object:
89
+
90
+ cucumber SHARE_FRAMEWORK=1
91
+
92
+ It's also possible to make the default behaviour of starting up a new interpreter explicit:
93
+
94
+ cucumber SHARE_FRAMEWORK=0
95
+
96
+ When wrapping Cucumber around legacy Tcl code, you can speed up local development by sharing the framework object to avoid starting a new Tcl interpreter for every test. However, you should keep the default behavior in your CI build to prevent potential data leakage between tests.
97
+
98
+ ## Returning Test Step Results
99
+
100
+ Cucumber knows different types of results defined in:
101
+
102
+ lib/cucumber/core/test/result.rb
103
+
104
+ Passed, Failed are the most common test results, while Skipped, Pending and Undefined are "exceptions that can be raised in a step definition causing the step to have that result."
105
+
106
+ To make a test step "Passed", use:
107
+
108
+ return -code ok
109
+
110
+ in your tcl implementation. (tcl automatically returns that at the end of each step)
111
+
112
+ To make a test step "Failed", raise an error:
113
+
114
+ error "The shopping cart is empty"
115
+
116
+ To trigger the exceptions "Skipped", "Pending" or "Undefined", use these keywords as error message.
117
+
118
+ error "skipped"; # this test step shall appeared as "Skipped" (=blue in reports)
119
+ error "pending; # this test step shall appeared as "Pending" (= unimplemented)
120
+ error "undefined"; # this test step shall appeared as "Undefined"
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ require 'bundler/gem_tasks'
5
+
6
+ task default: %i[clean spec cucumber tcltest rubocop build install]
7
+
8
+ require 'rspec/core/rake_task'
9
+ RSpec::Core::RakeTask.new(:spec)
10
+
11
+ require 'cucumber/rake/task'
12
+
13
+ Cucumber::Rake::Task.new(:cucumber) do |t|
14
+ t.cucumber_opts = %w[--format pretty --publish-quiet]
15
+ end
16
+
17
+ desc 'runs tcl test'
18
+ task :tcltest do
19
+ sh({ 'TEST' => '1' }, 'tclsh lib/cucumber/tcl/test/test_framework.tcl')
20
+ end
21
+
22
+ require 'rubocop/rake_task'
23
+
24
+ RuboCop::RakeTask.new do |task|
25
+ task.fail_on_error = false
26
+ end
27
+
28
+ CLEAN.include %w[pkg/ tmp/]
@@ -0,0 +1,23 @@
1
+ require_relative 'lib/cucumber/tcl/version'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'yet-another-cucumber-tcl'
5
+ s.version = Cucumber::Tcl::VERSION
6
+ s.authors = ['Matt Wynne', 'Jon Owers', 'Barney Fisher']
7
+ s.description = 'TCL plugin for Cucumber'
8
+ s.summary = "cucumber-tcl-#{s.version}"
9
+ s.email = 'pedro.miranda@gmail.com'
10
+ s.license = 'MIT'
11
+ s.homepage = 'https://github.com/p3t3ru5/yet-another-cucumber-ruby-tcl#'
12
+ s.platform = Gem::Platform::RUBY
13
+ s.required_ruby_version = '>= 3.0.0'
14
+
15
+ s.add_dependency 'cucumber'
16
+ s.add_dependency 'yet-another-ruby-tcl', '~> 0.1.2'
17
+
18
+ # s.rubygems_version = ">= 1.6.1"
19
+ s.files = `git ls-files`.split("\n").grep_v(/\.gitignore$/)
20
+ s.rdoc_options = ['--charset=UTF-8']
21
+ s.require_path = 'lib'
22
+ s.metadata['rubygems_mfa_required'] = 'true'
23
+ end
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: --publish-quiet
@@ -0,0 +1,26 @@
1
+ Feature: DataTables
2
+
3
+ Scenario: Match a step with a DataTable
4
+ Given a file named "features/test.feature" with:
5
+ """
6
+ Feature:
7
+ Scenario:
8
+ Given passing with a DataTable:
9
+ | a | b |
10
+ | c | d |
11
+ """
12
+ And a file named "features/support/env.rb" with:
13
+ """
14
+ require 'cucumber/tcl'
15
+ """
16
+ And a file named "features/step_definitions/steps.tcl" with:
17
+ """
18
+ Given {^passing with a DataTable:$} {content} {
19
+ puts $content
20
+ }
21
+ """
22
+ When I run `cucumber`
23
+ Then it should pass with:
24
+ """
25
+ {{a} {b}} {{c} {d}}
26
+ """
@@ -0,0 +1,155 @@
1
+ Feature: Define a step
2
+
3
+ Scenario: Define a passing step
4
+ Given a file named "features/test.feature" with:
5
+ """
6
+ Feature:
7
+ Scenario:
8
+ Given passing
9
+ """
10
+ And a file named "features/support/env.rb" with:
11
+ """
12
+ require 'cucumber/tcl'
13
+ """
14
+ And a file named "features/step_definitions/steps.tcl" with:
15
+ """
16
+ Given {^passing$} {
17
+ puts "Hello world"
18
+ }
19
+ """
20
+ When I run `cucumber`
21
+ Then it should pass with:
22
+ """
23
+ Hello world
24
+ """
25
+
26
+ Scenario: Define a step with a parameter
27
+ Given a file named "features/test.feature" with:
28
+ """
29
+ Feature:
30
+ Scenario:
31
+ Given passing 123
32
+ """
33
+ And a file named "features/support/env.rb" with:
34
+ """
35
+ require 'cucumber/tcl'
36
+ """
37
+ And a file named "features/step_definitions/steps.tcl" with:
38
+ """
39
+ Given {^passing (\d+)$} {num} {
40
+ puts "Hello $num"
41
+ }
42
+ """
43
+ When I run `cucumber`
44
+ Then it should pass with:
45
+ """
46
+ Hello 123
47
+ """
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_definitions/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 `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_definitions/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 `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,27 @@
1
+ Feature: DocStrings
2
+
3
+ Scenario: Match a step with a DocString
4
+ Given a file named "features/test.feature" with:
5
+ """
6
+ Feature:
7
+ Scenario:
8
+ Given passing with a DocString:
9
+ \"\"\"
10
+ DocString content
11
+ \"\"\"
12
+ """
13
+ And a file named "features/support/env.rb" with:
14
+ """
15
+ require 'cucumber/tcl'
16
+ """
17
+ And a file named "features/step_definitions/steps.tcl" with:
18
+ """
19
+ Given {^passing with a DocString:$} {content} {
20
+ puts "Hello $content"
21
+ }
22
+ """
23
+ When I run `cucumber`
24
+ Then it should pass with:
25
+ """
26
+ Hello DocString content
27
+ """
@@ -0,0 +1,137 @@
1
+ Feature: Sourcing tcl files
2
+
3
+ Scenario: Source files in the appropriate order (no command line options)
4
+ Given a file named "features/test.feature" with:
5
+ """
6
+ Feature:
7
+ Scenario:
8
+ Given testing file sourcing
9
+ """
10
+ And a file named "features/step_definitions/steps_a.tcl" with:
11
+ """
12
+ puts "Sourced step_definitions/steps_a.tcl"
13
+ """
14
+ And a file named "features/step_definitions/steps_b.tcl" with:
15
+ """
16
+ puts "Sourced step_definitions/steps_b.tcl"
17
+ """
18
+ And a file named "features/support/db.tcl" with:
19
+ """
20
+ puts "Sourced support/db.tcl"
21
+ """
22
+ And a file named "features/support/env.rb" with:
23
+ """
24
+ require 'cucumber/tcl'
25
+ """
26
+ And a file named "features/support/env.tcl" with:
27
+ """
28
+ puts "Sourced support/env.tcl"
29
+ """
30
+ When I run `cucumber`
31
+ Then it should pass with:
32
+ """
33
+ Sourced support/env.tcl
34
+ Sourced support/db.tcl
35
+ Sourced step_definitions/steps_a.tcl
36
+ Sourced step_definitions/steps_b.tcl
37
+ """
38
+
39
+ Scenario: Source files in the appropriate order (with command line options)
40
+ Given a file named "myfeatures/group one/test.feature" with:
41
+ """
42
+ Feature:
43
+ Scenario:
44
+ Given testing file sourcing
45
+ """
46
+ And a file named "myfeatures/step definitions/steps.tcl" with:
47
+ """
48
+ puts "Sourced step definitions/steps.tcl"
49
+ """
50
+ And a file named "myfeatures/support/db.tcl" with:
51
+ """
52
+ puts "Sourced support/db.tcl"
53
+ """
54
+ And a file named "myfeatures/support/debug.tcl" with:
55
+ """
56
+ puts "Sourced support/debug.tcl"
57
+ """
58
+ And a file named "myfeatures/support/env.rb" with:
59
+ """
60
+ require 'cucumber/tcl'
61
+ """
62
+ And a file named "myfeatures/support/env.tcl" with:
63
+ """
64
+ puts "Sourced support/env.tcl"
65
+ """
66
+ When I run `cucumber 'myfeatures/group one/test.feature' --require myfeatures --exclude 'debug.*'`
67
+ Then it should pass with:
68
+ """
69
+ Sourced support/env.tcl
70
+ Sourced support/db.tcl
71
+ Sourced step definitions/steps.tcl
72
+ """
73
+
74
+ Scenario: Display stack trace when there is an error in a sourced file
75
+ Given a file named "features/test.feature" with:
76
+ """
77
+ Feature:
78
+ Scenario:
79
+ Given testing file sourcing
80
+ """
81
+ And a file named "features/support/env.rb" with:
82
+ """
83
+ require 'cucumber/tcl'
84
+ """
85
+ And a file named "features/support/helper.tcl" with:
86
+ """
87
+ error "Fail sourcing"
88
+ """
89
+ When I run `cucumber`
90
+ Then it should fail with:
91
+ """
92
+ Fail sourcing
93
+ while executing
94
+ "error "Fail sourcing""
95
+ (file "features/support/helper.tcl" line 1)
96
+ invoked from within
97
+ "source features/support/helper.tcl"
98
+ ("uplevel" body line 1)
99
+ invoked from within
100
+ "uplevel #0 [list source $file]" (Tcl::Error)
101
+ """
102
+
103
+ Scenario: Display stack trace with multiple levels
104
+ Given a file named "features/test.feature" with:
105
+ """
106
+ Feature:
107
+ Scenario:
108
+ Given testing file sourcing
109
+ """
110
+ And a file named "features/support/env.rb" with:
111
+ """
112
+ require 'cucumber/tcl'
113
+ """
114
+ And a file named "features/support/helper.tcl" with:
115
+ """
116
+ proc test_proc args {
117
+ proc_doesnt_exist
118
+ }
119
+
120
+ test_proc
121
+ """
122
+ When I run `cucumber`
123
+ Then it should fail with:
124
+ """
125
+ invalid command name "proc_doesnt_exist"
126
+ while executing
127
+ "proc_doesnt_exist"
128
+ (procedure "test_proc" line 2)
129
+ invoked from within
130
+ "test_proc"
131
+ (file "features/support/helper.tcl" line 5)
132
+ invoked from within
133
+ "source features/support/helper.tcl"
134
+ ("uplevel" body line 1)
135
+ invoked from within
136
+ "uplevel #0 [list source $file]" (Tcl::Error)
137
+ """
@@ -0,0 +1,39 @@
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_definitions/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
+
36
+ 1 scenario (1 pending)
37
+ 1 step (1 pending)
38
+ """
39
+