betagouv-cucumber-steps 0.0.1
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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +12 -0
- data/lib/betagouv/cucumber/steps/version.rb +9 -0
- data/lib/betagouv/cucumber/steps.rb +177 -0
- data/sig/betagouv/cucumber/steps.rbs +8 -0
- metadata +51 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d25b49caf9af571492d08dbcecbd139f9af1f36810670b9b08784df0e78fd771
|
|
4
|
+
data.tar.gz: 7fbb8d38d7fa338732b3c61232c67f9aadb3277a8317cc1261019e0c8f78da56
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4dd9572c4a3d7656b6c4639bb2d2ab3bdf3fb365b57c23efe2ca82cf0a4e3adaf19ba1f0f717afe1172029b6e3a3a7ed649f56487aa86bf38f33e358288d9591
|
|
7
|
+
data.tar.gz: cf1b729b5e9c001674c48d3bf78a05f4e68e7a1b553b688a63c1251415a76f16836ad485494f45ba577c9de98da8c7990b38d66360cfb03d5b376312c0775a05
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Stéphane Maniaci
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Betagouv::Cucumber::Steps
|
|
2
|
+
|
|
3
|
+
Cette gem contient des [steps
|
|
4
|
+
Cucumber](https://cucumber.io/docs/gherkin/reference#steps)
|
|
5
|
+
génériques, surcouche française des matchers Capybara qui vous permet
|
|
6
|
+
de contruire votre propre librairie d'actions pour vos tests Cucumber.
|
|
7
|
+
|
|
8
|
+
Par exemple :
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
Alors("la page contient {string}") do |content|
|
|
12
|
+
expect(page).to have_content(content)
|
|
13
|
+
end
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
et
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
Quand("je me rends sur la page d'accueil") do
|
|
20
|
+
visit "/"
|
|
21
|
+
end
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
vous permet ensuite d'écrire :
|
|
25
|
+
|
|
26
|
+
```feature
|
|
27
|
+
Scénario: la page d'accueil contient le nom du produit
|
|
28
|
+
Quand je me rends sur la page d'accueil
|
|
29
|
+
Alors la page contient "foobar"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```ruby
|
|
35
|
+
gem "betagouv-cucumber-steps"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Dans un fichier `features/support/base-steps.rb` (ou autre fichier
|
|
39
|
+
chargé par Cucumber) :
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
require 'betagouv/cucumber/steps'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Liste des steps
|
|
46
|
+
|
|
47
|
+
FIXME: trouver une meilleur doc que [le fichier des
|
|
48
|
+
steps](./lib/betagouv/cucumber/steps.rb).
|
|
49
|
+
|
|
50
|
+
## Debug / Contribution
|
|
51
|
+
|
|
52
|
+
Cette gem est fraîchement extraite de plusieurs projets Beta et
|
|
53
|
+
nécessite probablement plus de travail.
|
|
54
|
+
|
|
55
|
+
Si un step ne fonctionne pas vous pouvez :
|
|
56
|
+
|
|
57
|
+
* utilisez le step `Alors debugger` pour debugger votre page en live
|
|
58
|
+
* overridez le step en question dans votre code `Alors("custom je clique sur {string}")`
|
|
59
|
+
* trafiquer la gem directement avec bundle open ou [dans Docker](https://freesteph.info/posts/local-gem-development-with-docker.html).
|
|
60
|
+
|
|
61
|
+
N'oubliez pas de ramener vos contributions ici !
|
data/Rakefile
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "steps/version"
|
|
4
|
+
|
|
5
|
+
Quand("je me rends sur la page d'accueil") do
|
|
6
|
+
visit "/"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Alors("la page contient {string}") do |content|
|
|
10
|
+
expect(page).to have_content(content)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Alors("l'en-tête contient {string}") do |content|
|
|
14
|
+
within(".fr-header") do
|
|
15
|
+
step(%(la page contient "#{content}"))
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Quand("print the page") do
|
|
20
|
+
log page.body
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Quand("je clique sur {string}") do |label|
|
|
24
|
+
click_link_or_button label
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Quand("je clique sur le premier lien ou bouton {string}") do |label|
|
|
28
|
+
click_link_or_button(label, match: :first)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
Alors("la page contient un bouton {string}") do |label|
|
|
32
|
+
expect(page).to have_button(label)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
Alors("la page ne contient pas de bouton {string}") do |title|
|
|
36
|
+
expect(page).not_to have_button(title)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
Alors("la page contient un bouton {string} désactivé") do |content|
|
|
40
|
+
expect(page).to have_button(content, disabled: true)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
Alors("la page ne contient pas {string}") do |content|
|
|
44
|
+
expect(page).to have_no_content(content)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
Alors("la page contient un lien {string}") do |text|
|
|
48
|
+
expect(page).to have_link(text)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
Alors("le titre de la page contient {string}") do |text|
|
|
52
|
+
expect(page.title.gsub(" ", " ")).to include text
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
Alors("il y a un titre de premier niveau contenant {string}") do |text|
|
|
56
|
+
# le titre est soit le premier h1 ou la légende du premier tableau
|
|
57
|
+
element = page.first("h1") || page.first("table caption")
|
|
58
|
+
|
|
59
|
+
expect(element.text).to include(text)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
Alors("la page est titrée {string}") do |text|
|
|
63
|
+
steps %(
|
|
64
|
+
Alors il y a un titre de premier niveau contenant "#{text}"
|
|
65
|
+
Et le titre de la page contient "#{text}"
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
Quand("je remplis {string} avec {string}") do |label, value|
|
|
70
|
+
fill_in label, with: value
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
Quand("je remplis le champ {string} avec {string} dans les champs de {string}") do |label, value, fieldset_legend|
|
|
74
|
+
within_fieldset(fieldset_legend) do
|
|
75
|
+
fill_in label, with: value
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
Quand("je coche {string}") do |label|
|
|
80
|
+
check label
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
Quand("je décoche {string}") do |label|
|
|
84
|
+
uncheck label
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
Quand('je coche toutes les cases') do
|
|
88
|
+
page
|
|
89
|
+
.all('input[type="checkbox"]')
|
|
90
|
+
.map { |node| node.sibling("label").text }
|
|
91
|
+
.each { |label| step(%(je coche "#{label}")) }
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
Quand("je clique sur {string} dans la rangée {string}") do |link, row|
|
|
96
|
+
within("tr", text: row) do
|
|
97
|
+
click_link_or_button(link)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
Alors("la rangée {string} contient {string}") do |row, content|
|
|
102
|
+
within("tr", text: row) do
|
|
103
|
+
expect(page).to have_content(content)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
Quand("je clique sur {string} dans la dernière rangée") do |link|
|
|
108
|
+
within(all("tr").last) do
|
|
109
|
+
click_link_or_button(link)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
Quand("je clique sur {string} dans la classe {string}") do |link, title|
|
|
114
|
+
within("section", text: title) do
|
|
115
|
+
click_link_or_button(link)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
Quand("je remplis le champ {string} dans la rangée {string} avec {string}") do |locator, row, value|
|
|
120
|
+
within("tr", text: row) do
|
|
121
|
+
fill_in locator, with: value
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
Quand("je sélectionne {string} pour {string}") do |option, name|
|
|
126
|
+
select option, from: name
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
Quand("je choisis {string}") do |option|
|
|
130
|
+
choose option
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
Quand("je choisis {string} pour {string}") do |option, fieldset|
|
|
134
|
+
within("fieldset", text: fieldset) do
|
|
135
|
+
choose option
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
Quand("j'attache le fichier {string} pour le champ {string}") do |path, field|
|
|
140
|
+
attach_file(field, path)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
Alors("je peux voir dans le tableau {string}") do |caption, table|
|
|
144
|
+
expect(page).to have_table(caption, with_rows: table.rows)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
Alors("je peux voir dans le tableau {string} dans cet ordre :") do |caption, table_data|
|
|
148
|
+
within_table(caption) do
|
|
149
|
+
table_data.rows.each_with_index do |row, row_number|
|
|
150
|
+
row.each_with_index do |cel, cel_number|
|
|
151
|
+
expect(find("tr[#{row_number + 1}]/td[#{cel_number + 1}]")).to have_text(cel)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
Alors("debugger") do
|
|
158
|
+
debugger # rubocop:disable Lint/Debugger
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
Quand("je rafraîchis la page") do
|
|
162
|
+
visit current_path
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
Alors("le fil d'Ariane affiche {string}") do |path|
|
|
166
|
+
components = path.split(" > ")
|
|
167
|
+
|
|
168
|
+
breadcrumbs = page.all("nav.fr-breadcrumb li").map(&:text)
|
|
169
|
+
|
|
170
|
+
expect(breadcrumbs).to eq components
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
Quand("je clique sur {string} dans le menu principal") do |item|
|
|
174
|
+
within("nav#main-nav") do
|
|
175
|
+
click_link_or_button(item)
|
|
176
|
+
end
|
|
177
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: betagouv-cucumber-steps
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Stéphane Maniaci
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2025-07-10 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: These helpers provide a (French) human syntax to drive a browser
|
|
13
|
+
email:
|
|
14
|
+
- stephane.maniaci@beta.gouv.fr
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- ".rspec"
|
|
20
|
+
- ".rubocop.yml"
|
|
21
|
+
- LICENSE.txt
|
|
22
|
+
- README.md
|
|
23
|
+
- Rakefile
|
|
24
|
+
- lib/betagouv/cucumber/steps.rb
|
|
25
|
+
- lib/betagouv/cucumber/steps/version.rb
|
|
26
|
+
- sig/betagouv/cucumber/steps.rbs
|
|
27
|
+
homepage: https://github.com/betagouv/cucumber-steps
|
|
28
|
+
licenses:
|
|
29
|
+
- MIT
|
|
30
|
+
metadata:
|
|
31
|
+
homepage_uri: https://github.com/betagouv/cucumber-steps
|
|
32
|
+
source_code_uri: https://github.com/betagouv/cucumber-steps
|
|
33
|
+
changelog_uri: https://github.com/betagouv/cucumber-steps
|
|
34
|
+
rdoc_options: []
|
|
35
|
+
require_paths:
|
|
36
|
+
- lib
|
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: 3.1.0
|
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
requirements: []
|
|
48
|
+
rubygems_version: 3.6.2
|
|
49
|
+
specification_version: 4
|
|
50
|
+
summary: Generic Cucumber/Capybara steps for beta.gouv.fr projects
|
|
51
|
+
test_files: []
|