1+ require 'capybara/cucumber'
2+ require 'selenium/webdriver'
3+
4+ Capybara . run_server = false
5+ Capybara . default_driver = :selenium_chrome_headless
6+ Capybara . app_host = "http://localhost:3000"
7+ Capybara . default_max_wait_time = 10
8+
9+ # Conditions
10+
11+ Soit ( "l'item {string} rattaché au corpus {string}" ) do |string , string2 |
12+ # On the remote servers
13+ end
14+
15+ Soit ( "le point de vue {string} rattaché à l'item {string}" ) do |string , string2 |
16+ # On the remote servers
17+ end
18+
19+ Soit ( "la catégorie {string} rattaché au point de vue {string}" ) do |string , string2 |
20+ # On the remote servers
21+ end
22+
23+ Soit ( "le fragment {string} rattaché à la catégorie {string}" ) do |string , string2 |
24+ # On the remote servers
25+ end
26+
27+ Alors ( "il doit y avoir au moins {int} items affichés" ) do |int |
28+ expect ( page ) . to have_selector ( '.Items .item' , count : int )
29+ end
30+
31+ Alors ( "l'item {string} est décrit par une date" ) do |item |
32+ node = find ( '.Items .item .name' , text : item )
33+ parent = node . find ( :xpath , '..' )
34+ expect ( parent ) . to have_selector ( '.date' )
35+ end
36+
37+ Alors ( "l'item {string} est décrit par un auteur" ) do |item |
38+ node = find ( '.Items .item .name' , text : item )
39+ parent = node . find ( :xpath , '..' )
40+ expect ( parent ) . to have_selector ( '.author' )
41+ end
42+
43+ # Events
44+
45+ Quand ( "l'item {string} est selectionné" ) do |item |
46+ find ( '.item' , text : item ) . click
47+ expect ( page ) . to have_selector ( '.textSelected' )
48+ end
49+
50+ # Outcomes
51+
52+ Alors ( "la catégorie {string} est affiché" ) do |category |
53+ expect ( page ) . to have_content category
54+ end
55+
56+ Alors ( "le fragment {string} est affiché" ) do |fragment |
57+ expect ( page ) . to have_content fragment
58+ end
59+
60+ Alors ( "le lien vers le texte associé au fragment {string} est affiché" ) do |fragment |
61+ expect ( find ( 'p' , exact_text : fragment ) ) . to have_selector ( 'a' )
62+ end
0 commit comments