gares 2.0.0.pre.dev3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -25
- data/gares.gemspec +3 -2
- data/lib/attribute_accessors.rb +22 -0
- data/lib/gares/base.rb +68 -41
- data/lib/gares/errors.rb +14 -0
- data/lib/gares/search.rb +42 -12
- data/lib/gares/station.rb +1 -1
- data/lib/gares/train.rb +43 -18
- data/lib/gares/version.rb +1 -1
- data/lib/gares.rb +3 -3
- data/lib/string_extensions.rb +20 -0
- data/spec/fixtures/87723197.json +21 -0
- data/spec/fixtures/LYD-arrivals.json +17 -0
- data/spec/fixtures/LYD-departures.json +17 -0
- data/spec/fixtures/bls.csv +21484 -0
- data/spec/fixtures/get-train-12345 +219 -0
- data/spec/fixtures/post-train-12345 +0 -0
- data/spec/gares/search_spec.rb +94 -57
- data/spec/gares/station_spec.rb +61 -0
- data/spec/gares/train_spec.rb +25 -4
- data/spec/spec_helper.rb +14 -16
- data/tasks/fixtures.rake +4 -3
- metadata +31 -21
- data/lib/gares/sales.rb +0 -15
- data/lib/gares/services.rb +0 -15
- data/lib/gares/string_extensions.rb +0 -22
- data/spec/fixtures/frabt +0 -330
- data/spec/fixtures/frabt-services-vente +0 -12
- data/spec/fixtures/frhco +0 -346
- data/spec/fixtures/frlpd +0 -349
- data/spec/fixtures/frlpd-services +0 -462
- data/spec/fixtures/frlpd-services-vente +0 -399
- data/spec/fixtures/frqxb-services +0 -386
- data/spec/fixtures/frqxb-services-vente +0 -367
- data/spec/fixtures/frxag +0 -333
- data/spec/fixtures/search +0 -5254
- data/spec/gares/gare_spec.rb +0 -79
- data/spec/gares/sales_spec.rb +0 -11
@@ -0,0 +1,219 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: text/html;charset=UTF-8
|
3
|
+
X-UA-Compatible: IE=edge
|
4
|
+
Date: Fri, 01 May 2015 10:35:36 GMT
|
5
|
+
Content-Length: 17178
|
6
|
+
Connection: keep-alive
|
7
|
+
Set-Cookie: SNC_city=SDN_PRD6; path=/; domain=.sncf.com
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
13
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
14
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" data-placeholder-focus="false">
|
15
|
+
|
16
|
+
<head>
|
17
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
18
|
+
<title>List of trains - Traffic & timetable updates | SNCF</title>
|
19
|
+
<link rel="canonical" href="http://www.sncf.com/en/horaires-info-trafic/train/resultats" />
|
20
|
+
<meta name="revisit-after" content="1 day" />
|
21
|
+
<link rel="shortcut icon" href="/theme/favicon.ico" type="image/x-icon" />
|
22
|
+
<link href="http://www.sncf.com/fr/info-trafic" rel="canonical" />
|
23
|
+
<meta http-equiv="Content-Language" content="en" /> <link type="text/css" rel="stylesheet" media="all" href="/ressources/menu_icons/menu_icons_en.css?1" />
|
24
|
+
<link type="text/css" rel="stylesheet" media="all" href="/ressources/css/css_fa8eef945cc8331059f2b2fe01e8b03b.css" />
|
25
|
+
<link type="text/css" rel="stylesheet" media="all" href="/ressources/css/css_ec8154e529f1ae274507ee7da445a16c.css" />
|
26
|
+
<link type="text/css" rel="stylesheet" media="print" href="/ressources/css/css_37cfb2f93b571bec4cf2ecfe43124557.css" />
|
27
|
+
<!--[if IE 6]>
|
28
|
+
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/sncfninesixty/styles/ie6.css?1" />
|
29
|
+
<![endif]-->
|
30
|
+
<!--[if lte IE 7]>
|
31
|
+
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/sncfninesixty/styles/ie7-and-below.css?1" />
|
32
|
+
<![endif]-->
|
33
|
+
<!--[if IE 8]>
|
34
|
+
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/sncfninesixty/styles/ie8.css?1" />
|
35
|
+
<![endif]-->
|
36
|
+
<!--[if gte IE 9]>
|
37
|
+
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/sncfninesixty/styles/ie9-and-above.css?1" />
|
38
|
+
<![endif]-->
|
39
|
+
<link href="/css/Generic-transac.css" media="all" type="text/css" rel="stylesheet" />
|
40
|
+
<link href="/css/itineraries.css" media="all" type="text/css" rel="stylesheet" /><link href="/css/train.css" media="all" type="text/css" rel="stylesheet" />
|
41
|
+
<script type="text/javascript" src="/ressources/js/js_89f43c3221c41b67e6924fff9b6a7908.js"></script>
|
42
|
+
<script type="text/javascript">
|
43
|
+
<!--//--><![CDATA[//><!--
|
44
|
+
jQuery.extend(Drupal.settings, { "basePath": "/", "googleanalytics": { "trackOutgoing": 1, "trackMailto": 1, "trackDownload": 1, "trackDownloadExtensions": "7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip" }, "sncfcom_search_hours": { "list": { "form_start": "1", "form_end": "3" }, "calendar": { "form_start": "1", "form_end": "90" } }, "user_connected": false, "user_rights": { "1": "anonymous user" }, "user_valid": false, "site_language": "en", "site_country": null, "sncfcom_feature_id_chartes": { "nid": "32510" }, "radio": { "height": "400", "width": "632" }, "sncfcom_satisfaction": { "campaigns": [ { "sid": "1", "page": "/fr/contacts/foire-aux-questions", "height_delta": "0", "width_delta": "0", "campaign_url": "", "count_url": "" }, { "sid": "2", "page": "/fr/promotions-billets-train", "height_delta": "317", "width_delta": "25", "campaign_url": "http://www.monavis.sncf.com/website/4v0voyconet0BChH0/form/86/100?responsive=0\x26toolbar=0", "count_url": "http://jcvd.myfeelback.com/indicator/monavis_feedback_dircom?campaign=86\x26formsubmissiontag=Like" }, { "sid": "3", "page": "/fr/gare-", "height_delta": "230", "width_delta": "17", "campaign_url": "http://www.monavis.sncf.com/website/4v0vosh9h4RHM3cUM/form/85/99?responsive=0\x26toolbar=0", "count_url": "http://jcvd.myfeelback.com/indicator/monavis_feedback_dircom?campaign=85\x26formsubmissiontag=Like" }, { "sid": "4", "page": "/fr/itineraire/resultats", "height_delta": "318", "width_delta": "10", "campaign_url": "http://www.monavis.sncf.com/website/4v0voobke4qGav23I/form/84/98?responsive=0\x26toolbar=0", "count_url": "http://jcvd.myfeelback.com/indicator/monavis_feedback_dircom?campaign=84\x26formsubmissiontag=Like" } ] }, "sncfcom_tagcarrier_widget": "", "addthis": { "config_default": { "services_compact": "email,facebook,twitter,google_plusone_share,linkedin,viadeo,more", "ui_language": "en", "ui_click": true, "ui_508_compliant": false, "ui_use_css": true, "data_ga_tracker": "UA-1308810-1", "data_track_clickback": true, "pubid": "xa-4e2cfd1147868c4e" }, "share_default": null, "localize": { "share_caption": "Share with friends" } }, "campaigns_tracking": { "ttl": 90, "cname": "snc_links_id" } });
|
45
|
+
//--><!]]>
|
46
|
+
</script>
|
47
|
+
<script type="text/javascript">
|
48
|
+
<!--//--><![CDATA[//><!--
|
49
|
+
var popupradio_autoplay = true;
|
50
|
+
//--><!]]>
|
51
|
+
</script>
|
52
|
+
<script src="/js/Generic-transac.js" type="text/javascript"></script>
|
53
|
+
<script src="/js/itineraries.js" type="text/javascript"></script>
|
54
|
+
<script src="/js/ga_dynamic.js" type="text/javascript"></script>
|
55
|
+
<script src="/js/map-links.js" type="text/javascript"></script>
|
56
|
+
</head>
|
57
|
+
|
58
|
+
<body class="not-front not-logged-in page-node node-type-transac-page no-sidebars sncfcom-b2c sncfcom-colors-cb0044 i18n-en not-js">
|
59
|
+
|
60
|
+
|
61
|
+
<ul id="skip-links"><li><a href="#navbar-wrapper">Go to main menu</a></li><li><a href="#left-menu">Go to secondary menu</a></li><li><a href="#content">Go to content</a></li><li><a href="#footer">Go to footer</a></li></ul>
|
62
|
+
|
63
|
+
<div id='bubble_print' class='out'>Print this page</div><div id='bubble_share' class='out'>Share this page</div>
|
64
|
+
|
65
|
+
<div id="navbar-wrapper">
|
66
|
+
<div id="navbar">
|
67
|
+
<div id="sncf-barre-galactique" class="grid_d">
|
68
|
+
|
69
|
+
<div id="primary-menu">
|
70
|
+
<ul class="links"><li class="menu-12124 active-trail first"><a href="/en/passengers" title=" (Active section)"><span><span>Passengers</span></span></a></li>
|
71
|
+
<li class="menu-12126"><a href="/en/businesses-communities"><span><span>Businesses & Communities</span></span></a></li>
|
72
|
+
<li class="menu-15545 last"><a href="/en/group"><span><span>SNCF Group</span></span></a></li>
|
73
|
+
</ul> </div>
|
74
|
+
|
75
|
+
<div class="barre_right">
|
76
|
+
|
77
|
+
<div id="radio-menu">
|
78
|
+
<a href="#" class="open_radio"><span class="bold">SNCF</span> LA RADIO</a>
|
79
|
+
</div>
|
80
|
+
|
81
|
+
|
82
|
+
<div id="menu-langue">
|
83
|
+
<div><span>en</span></div><ul class="links" title="Change language"><li class="menu-1521 first"><a href="/voyageurs"><span class="js">Français</span><span class="no-js">Fr</span></a></li>
|
84
|
+
<li class="menu-1522"><a href="/en/passengers"><span class="js">English</span><span class="no-js">En</span></a></li>
|
85
|
+
<li class="menu-1523 last"><a href="/de/fahrgaste"><span class="js">Deutsch</span><span class="no-js">De</span></a></li>
|
86
|
+
</ul> </div>
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
</div> </div>
|
91
|
+
</div>
|
92
|
+
<div id="navbar-spacer"></div>
|
93
|
+
|
94
|
+
<div class="container_d">
|
95
|
+
|
96
|
+
|
97
|
+
<div class="grid_a" id="sidebar-left">
|
98
|
+
<div id="left-menu">
|
99
|
+
<div class="telecommand"><div class="arrow"></div><div class="content"><div class="logo"><a href="/en/passengers" title="Logo SNCF"><img src="/theme/images/logo-sncf.png" alt="Logo SNCF" title="Logo SNCF" width="131" height="76" /></a></div><ul><li class="menu-17388 active "><div class="text"><span><span>Tickets & <span class="sncfcom-colors-automatic">train status</span></span></span></div><div class="submenu"><ul class="tc-content-2"><li class="menu-17393 no-icon first "><a href="http://en.voyages-sncf.com/en/" class=" " title="" target=""><span><span>Reservations</span></span></a></li><li class="menu-67100 no-icon last "><a href="http://www.infolignes.com/index.php?lang=en" class=" " title="" target=""><span><span class='double_line'>Timetables & real-time <br />traffic updates</span></span></a></li></ul></div></li><li class="menu-58934 "><div class="text"><span><span>Passenger services</span></span></div><div class="submenu"><ul class="tc-content-2"><li class="menu-58935 first "><a href="/en/sub-home/58935" class=" has_sub-home sub-home-mlid-58935 " title="" target=""><span><span>All <span class="sncfcom-colors-automatic">passengers</span></span></span></a></li><li class="menu-58942 "><a href="/en/sub-home/58942" class=" has_sub-home sub-home-mlid-58942 " title="" target=""><span><span>Business <span class="sncfcom-colors-automatic">travel</span></span></span></a></li><li class="menu-58943 "><a href="/en/sub-home/58943" class=" has_sub-home sub-home-mlid-58943 " title="" target=""><span><span>Disability <span class="sncfcom-colors-automatic">access</span></span></span></a></li><li class="menu-58944 last "><a href="/en/sub-home/58944" class=" has_sub-home sub-home-mlid-58944 " title="" target=""><span><span>Group <span class="sncfcom-colors-automatic">travel</span></span></span></a></li></ul></div></li><li class="menu-58939 "><div class="text"><span><span>Trains & coaches</span></span></div><div class="submenu"><ul class="tc-content-2"><li class="menu-58945 first "><a href="/en/sub-home/58945" class=" has_sub-home sub-home-mlid-58945 " title="" target=""><span><span>French <span class="sncfcom-colors-automatic">regions</span></span></span></a></li><li class="menu-58946 "><a href="/en/trains/transilien" class=" " title="" target=""><span><span>Paris <span class="sncfcom-colors-automatic">region</span></span></span></a></li><li class="menu-58947 "><a href="/en/sub-home/58947" class=" has_sub-home sub-home-mlid-58947 " title="" target=""><span><span>France</span></span></a></li><li class="menu-58948 last "><a href="/en/sub-home/58948" class=" has_sub-home sub-home-mlid-58948 " title="" target=""><span><span>Europe</span></span></a></li></ul></div></li><li class="menu-58940 "><div class="text"><span><span>Fares & cards</span></span></div><div class="submenu"><ul class="tc-content-2"><li class="menu-17377 first "><a href="/en/special-deals" class=" " title="" target=""><span><span>Special Deals</span></span></a></li><li class="menu-58949 "><a href="/en/sub-home/58949" class=" has_sub-home sub-home-mlid-58949 " title="" target=""><span><span>Cards & <span class="sncfcom-colors-automatic">discounts</span></span></span></a></li><li class="menu-58950 "><a href="/en/sub-home/58950" class=" has_sub-home sub-home-mlid-58950 " title="" target=""><span><span>Special <span class="sncfcom-colors-automatic">fares</span></span></span></a></li><li class="menu-58951 last "><a href="/en/sub-home/58951" class=" has_sub-home sub-home-mlid-58951 " title="" target=""><span><span>Loyalty <span class="sncfcom-colors-automatic">programmes</span></span></span></a></li></ul></div></li><li class="menu-58941 "><div class="text"><span><span>Customer relations</span></span></div><div class="submenu"><ul class="tc-content-2"><li class="menu-58990 first "><a href="/en/sub-home/58990" class=" has_sub-home sub-home-mlid-58990 " title="" target=""><span><span>Talk to us <span class="sncfcom-colors-automatic">on line</span></span></span></a></li><li class="menu-58952 "><a href="/en/sub-home/58952" class=" has_sub-home sub-home-mlid-58952 " title="" target=""><span><span>Contact <span class="sncfcom-colors-automatic">us</span></span></span></a></li><li class="menu-58953 "><a href="/en/sub-home/58953" class=" has_sub-home sub-home-mlid-58953 " title="" target=""><span><span>Our <span class="sncfcom-colors-automatic">commitments</span></span></span></a></li><li class="menu-58954 last "><a href="/en/sub-home/58954" class=" has_sub-home sub-home-mlid-58954 " title="" target=""><span><span class='double_line'>After-sales service <br /><span class="sncfcom-colors-automatic">& Ombudsman</span></span></span></a></li></ul></div></li></ul></div></div>
|
100
|
+
</div>
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
<div class="grid_c container_content_12" id="content">
|
105
|
+
|
106
|
+
<div id="sncf-logo-print" class="grid_12"><img src="/theme/images/logo.png" alt ="" /></div>
|
107
|
+
|
108
|
+
|
109
|
+
<div class="content_text">
|
110
|
+
<div class="breadcrumb grid_10"><ul><li>Passengers</li> / <li>Tickets & train status</li> / <li>Timetables & real-time traffic updates</li> / <li title="Active page" class="last">Résultat de recherche : fiche train (en)</li></ul></div><div class="action-links grid_2"> <span> <a class="print" target="_blank" href="/en/jprint/train/resultats">
|
111
|
+
</a>
|
112
|
+
<a role="button" class="addthis_button share" href="/en/horaires-info-trafic/train/resultats#">Share this page</a></span></div><div id="node-32510" class=" node clear-block">
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
<div class="content">
|
117
|
+
<div id="block-itineraires" class="transac-block transac-header">
|
118
|
+
|
119
|
+
<div class="container_12">
|
120
|
+
<h1 class="grid_9">
|
121
|
+
Timetables & real-time <br/><span class="sncfcom-colors-automatic">traffic updates</span>
|
122
|
+
</h1>
|
123
|
+
<div id="description" class="grid_8">
|
124
|
+
<h2>
|
125
|
+
Your <span class="sncfcom-colors-automatic">
|
126
|
+
search </span>
|
127
|
+
</h2>
|
128
|
+
|
129
|
+
<p class="search_summary">
|
130
|
+
Train no. : <strong>12345</strong><br/>
|
131
|
+
Travel date :
|
132
|
+
<strong> Saturday 25 April </strong>
|
133
|
+
</p>
|
134
|
+
|
135
|
+
<div class="search_modify">
|
136
|
+
<a href="/sncf/train/displayForm" id="lien-modifiere" class="sncfcom-colors-action-automatic">
|
137
|
+
Modify your search </a>
|
138
|
+
</div>
|
139
|
+
|
140
|
+
</div>
|
141
|
+
</div>
|
142
|
+
|
143
|
+
|
144
|
+
<div id="results" class="grid_12">
|
145
|
+
<div id="no_results">
|
146
|
+
<hr class="border" />
|
147
|
+
<h2>
|
148
|
+
no <span class="sncfcom-colors-automatic">
|
149
|
+
results </span>
|
150
|
+
</h2>
|
151
|
+
<div class="sncfcom-colors-automatic"><b>We’re sorry. There are no results for your search.</b></div>
|
152
|
+
<div class="details">Please change your search criteria.</div>
|
153
|
+
</div>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
</div>
|
161
|
+
</div>
|
162
|
+
|
163
|
+
|
164
|
+
<div class="grid_c alpha omega" id="footer">
|
165
|
+
<div class="footer_content">
|
166
|
+
|
167
|
+
<div id="forgotten_password_block">
|
168
|
+
<a id="lb-close" tabindex="2">Fermer la popin</a>
|
169
|
+
<div class="forgotten_password identity">
|
170
|
+
<h3>Mot de passe oublié ?</h3>
|
171
|
+
<hr class="clear-border" />
|
172
|
+
<span class="identity-message">Indiquez l'adresse électronique utilisée lors de la création<br /> de votre compte. Un courriel vous sera envoyé pour définir<br /> votre mot de passe.</span>
|
173
|
+
<div class="form-item mail">
|
174
|
+
<label for="forgotten_password_email">Adresse électronique :</label>
|
175
|
+
<div class="message_fpw sncfcom-colors-error-automatic sncfcom-colors-automatic"></div>
|
176
|
+
<input type="text" maxlength="60" size="60" name="email_link" id="forgotten_password_email" value="" />
|
177
|
+
</div>
|
178
|
+
<div class="form-item">
|
179
|
+
<input type="submit" name="op" id="edit-send-mail-retrieve-password" value="Envoyer" class="form-submit sncfcom-colors-action-automatic sncfcom-colors-internal-caps-automatic" />
|
180
|
+
</div>
|
181
|
+
<div class="response-forgotten-password sncfcom-colors-automatic"></div>
|
182
|
+
</div>
|
183
|
+
</div>
|
184
|
+
<div id="block-sncfcom_navigation-footer" class="block block-sncfcom_navigation">
|
185
|
+
|
186
|
+
<div class="content">
|
187
|
+
|
188
|
+
<h2 class="grid_3 omega">Quick access : </h2>
|
189
|
+
<div id="quick-access" class="grid_10 alpha omega"><ul class="menu"><li class="leaf first"><a href="/en/education/schools">Teachers</a></li>
|
190
|
+
<li class="leaf last"><a href="/en/meet-sncf/finance/news">Finance</a></li>
|
191
|
+
</ul></div>
|
192
|
+
|
193
|
+
<hr class="clear border grid_12 no-margin" />
|
194
|
+
|
195
|
+
<div id="universes" class="grid_12"><ul class="menu"><li class="grid_4 first "><span><span>Passengers</span></span><ul class="menu"><li><a href="/en/reductions/lowest-fares">Travel at the lowest fares</a></li><li><a href="/en/services/mobile-apps-old">Mobile apps</a></li><li><a href="/en/services/after-sales-services">After-sales service</a></li></ul></li><li class="grid_4 "><span><span>Business and local communities</span></span><ul class="menu"><li><a href="/en/sub-home/15515">For business</a></li><li><a href="/en/sub-home/15518">For local communities</a></li><li><a href="/en/railway-companies">Railway Companies</a></li></ul></li><li class="grid_4 last "><span><span>SNCF Group</span></span><ul class="menu"><li><a href="/en/businesses/global-presence">Our global presence</a></li><li><a href="/en/our-commitments/sncf-foundation">SNCF Foundation</a></li></ul></li></ul></div>
|
196
|
+
|
197
|
+
<div id="radio-link" class="grid_4"><a href="http://laradio.sncf.com" target="_blank"><span class="bold">SNCF</span> LA RADIO</a></div>
|
198
|
+
<div id="about" class="grid_8"><ul class="menu"><li class="leaf first"><a href="/en/footer/legal-notice">Legal notice</a></li>
|
199
|
+
<li class="leaf last"><a href="http://sncf.com/cil/registre/">Contact for IT & civil liberties issues</a></li>
|
200
|
+
</ul></div>
|
201
|
+
|
202
|
+
<hr class="clear" /> </div>
|
203
|
+
</div>
|
204
|
+
</div>
|
205
|
+
</div>
|
206
|
+
|
207
|
+
</div>
|
208
|
+
<div class="clear"></div>
|
209
|
+
|
210
|
+
</div>
|
211
|
+
<script type="text/javascript">
|
212
|
+
<!--//--><![CDATA[//><!--
|
213
|
+
var _gaq = _gaq || [];_gaq.push(["_setAccount", "UA-1308810-17"]);_gaq.push(["b._setAccount", "UA-1308810-1"]);(function() {var ga = document.createElement("script");ga.type = "text/javascript";ga.async = true;ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(ga, s);})();
|
214
|
+
//--><!]]>
|
215
|
+
</script>
|
216
|
+
|
217
|
+
</body>
|
218
|
+
</html>
|
219
|
+
|
Binary file
|
data/spec/gares/search_spec.rb
CHANGED
@@ -1,90 +1,127 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Gares::Search do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
describe "search by station name" do
|
5
|
+
context 'with multiple search results' do
|
6
|
+
subject do
|
7
|
+
Gares::Search.new('saint étienne')
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
it 'should remember the query' do
|
11
|
+
expect(subject.query).to eql('saint étienne')
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
it 'should find 11 results' do
|
15
|
+
expect(subject.stations.size).to eql(11)
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
it 'should return Gares::Station objects only' do
|
19
|
+
expect(subject.stations).to all(be_an(Gares::Station))
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
it 'should not return gares with no name' do
|
23
|
+
subject.stations.each { |gare| expect(gare.name).to_not be_blank }
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
it 'should return only the name of the result' do
|
27
|
+
expect(subject.stations.first.name).to eql('St-Étienne-du-Rouvray')
|
28
|
+
end
|
27
29
|
end
|
28
|
-
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
expect do
|
33
|
-
@search = Gares::Search.new('Paris Austerlitz').stations
|
34
|
-
end.not_to raise_error
|
35
|
-
end
|
31
|
+
describe 'with name that has utf-8 characters' do
|
32
|
+
subject { Gares::Station.search('Saone').first }
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
it 'should give the proper name' do
|
35
|
+
expect(subject.name).to eql('Saône')
|
36
|
+
end
|
40
37
|
end
|
41
|
-
end
|
42
38
|
|
43
|
-
|
44
|
-
|
45
|
-
expect do
|
46
|
-
@search = Gares::Search.new('CULMONT CHALINDREY').stations
|
47
|
-
end.not_to raise_error
|
48
|
-
end
|
39
|
+
context 'with an exact match' do
|
40
|
+
subject { Gares::Search.new('Paris Austerlitz') }
|
49
41
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
42
|
+
it 'should not raise an exception' do
|
43
|
+
expect do
|
44
|
+
subject.stations
|
45
|
+
end.not_to raise_error
|
46
|
+
end
|
54
47
|
|
55
|
-
context 'with a "st" searching for "saint"' do
|
56
48
|
it 'should return the gare sncf_id.downcase correctly' do
|
57
|
-
|
58
|
-
expect(@search.stations.first.sncf_id.downcase).to eql('frhhd')
|
49
|
+
expect(subject.stations.first.sncf_id.downcase).to eql('frpaz')
|
59
50
|
end
|
60
51
|
end
|
61
52
|
|
62
|
-
context 'with a
|
63
|
-
|
64
|
-
|
65
|
-
expect
|
53
|
+
context 'with a fuzzy match' do
|
54
|
+
subject { Gares::Search.new('CULMONT CHALINDREY') }
|
55
|
+
it 'should not raise an exception' do
|
56
|
+
expect do
|
57
|
+
subject.stations
|
58
|
+
end.not_to raise_error
|
66
59
|
end
|
67
60
|
|
68
61
|
it 'should return the gare sncf_id.downcase correctly' do
|
69
|
-
|
70
|
-
expect(@search.stations.first.sncf_id.downcase).to eql('frapm')
|
62
|
+
expect(subject.stations.first.sncf_id.downcase).to eql('frccy')
|
71
63
|
end
|
72
64
|
|
73
|
-
|
74
|
-
|
75
|
-
|
65
|
+
context 'with a "st" searching for "saint"' do
|
66
|
+
it 'should return the gare sncf_id.downcase correctly' do
|
67
|
+
subject = Gares::Search.new('ST ETIENNE CHATEAUCREUX')
|
68
|
+
expect(subject.stations.first.sncf_id.downcase).to eql('frhhd')
|
69
|
+
end
|
76
70
|
end
|
77
71
|
|
78
|
-
|
79
|
-
|
80
|
-
|
72
|
+
context 'with a multi-terms search' do
|
73
|
+
it 'should return the gare sncf_id.downcase correctly' do
|
74
|
+
subject = Gares::Search.new('BAR SUR AUBE')
|
75
|
+
expect(subject.stations.first.sncf_id.downcase).to eql('frapx')
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should return the gare sncf_id.downcase correctly' do
|
79
|
+
subject = Gares::Search.new('NOGENT SUR SEINE')
|
80
|
+
expect(subject.stations.first.sncf_id.downcase).to eql('frapm')
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should return the gare sncf_id.downcase correctly' do
|
84
|
+
subject = Gares::Station.search('MONTELIMAR GARE SNCF')
|
85
|
+
expect(subject.first.sncf_id.downcase).to eql('frmtl')
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should return the gare sncf_id.downcase correctly' do
|
89
|
+
subject = Gares::Station.search('MONTPELLIER SAINT-ROCH')
|
90
|
+
expect(subject.first.sncf_id.downcase).to eql('frmpl')
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should return the gare sncf_id.downcase correctly' do
|
94
|
+
subject = Gares::Station.search('CHALON SUR SAONE')
|
95
|
+
expect(subject.first.sncf_id.downcase).to eql('frxcd')
|
96
|
+
end
|
97
|
+
|
81
98
|
end
|
99
|
+
end
|
100
|
+
end
|
82
101
|
|
83
|
-
|
84
|
-
|
85
|
-
|
102
|
+
describe "search by sncf_id" do
|
103
|
+
context 'with an exact match' do
|
104
|
+
subject { Gares::Search.new('frlpd', :sncf_id) }
|
105
|
+
|
106
|
+
it 'should not raise an exception' do
|
107
|
+
expect do
|
108
|
+
subject.stations
|
109
|
+
end.not_to raise_error
|
86
110
|
end
|
87
111
|
|
112
|
+
it 'returns the good station' do
|
113
|
+
expect(subject.stations.first.sncf_id.downcase).to eql('frlpd')
|
114
|
+
expect(subject.stations.first.name).to eql('Lyon Part-Dieu')
|
115
|
+
end
|
88
116
|
end
|
89
117
|
end
|
118
|
+
|
119
|
+
describe "search by unsupported field" do
|
120
|
+
it 'raises an exception' do
|
121
|
+
expect do
|
122
|
+
Gares::Search.new('Paris Austerlitz', :foo)
|
123
|
+
end.to raise_error
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
90
127
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# This test uses "Lyon Part-Dieu" as a testing sample:
|
4
|
+
#
|
5
|
+
describe Gares::Station do
|
6
|
+
|
7
|
+
describe 'valid gare' do
|
8
|
+
|
9
|
+
subject do
|
10
|
+
# Get gare de Lyon Part-Dieu
|
11
|
+
Gares::Station.find_by_sncf_id('frlpd')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should find the name' do
|
15
|
+
expect(subject.name).to eql('Lyon Part-Dieu')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should find the sncf_id' do
|
19
|
+
expect(subject.sncf_id).to eql('FRLPD')
|
20
|
+
# Still supports deprecated fields
|
21
|
+
expect(subject.slug).to eql(subject.sncf_id.downcase)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should find the TVS number' do
|
25
|
+
expect(subject.send(:tvs)).to eql('LYD')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should find the geolocation coordinates' do
|
29
|
+
expect(subject.latitude).to eql(45.760568)
|
30
|
+
expect(subject.longitude).to eql(4.859991)
|
31
|
+
# Still supports deprecated fields
|
32
|
+
expect(subject.lat).to eql(subject.latitude)
|
33
|
+
expect(subject.long).to eql(subject.longitude)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'has a list of departure trains' do
|
37
|
+
expect(subject.departures.size).to eq(20)
|
38
|
+
expect(subject.departures.first.origdest.name).to eq('Bruxelles')
|
39
|
+
expect(subject.departures.first.heure).to eq('05:50')
|
40
|
+
expect(subject.departures.first.type).to eq('TGV')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'has a list of arrivals' do
|
44
|
+
expect(subject.arrivals.last.origdest.name).to eq('Chambéry Challes-les-Eaux')
|
45
|
+
expect(subject.arrivals.last.voie).to eq('')
|
46
|
+
expect(subject.arrivals.last.platform).to eq(subject.arrivals.last.voie)
|
47
|
+
expect(subject.arrivals.last.num).to eq(18542)
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'Station of Agde' do
|
51
|
+
subject do
|
52
|
+
# Get gare de Agde
|
53
|
+
Gares::Station.find_by_sncf_id('frxag')
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'a gare with a BLS' do
|
57
|
+
it { expect(subject.has_borne?).to be(true) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/gares/train_spec.rb
CHANGED
@@ -3,6 +3,27 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Gares::Train do
|
6
|
+
|
7
|
+
subject do
|
8
|
+
Gares::Train.new(num: train_number, date: date)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'no results' do
|
12
|
+
|
13
|
+
let (:train_number) { 12345 }
|
14
|
+
let (:date) { Time.parse("2015-04-25") }
|
15
|
+
|
16
|
+
before do
|
17
|
+
# See tasks/fixtures.rake to change dataset
|
18
|
+
fake_response_for_train(train_number)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "raises an error for any method called on it" do
|
22
|
+
expect { subject.departure }.to raise_error
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
6
27
|
describe 'a delayed train' do
|
7
28
|
|
8
29
|
let (:train_number) { 17709 }
|
@@ -14,7 +35,7 @@ describe Gares::Train do
|
|
14
35
|
end
|
15
36
|
|
16
37
|
subject do
|
17
|
-
Gares::Train.new(train_number, date)
|
38
|
+
Gares::Train.new(num: train_number, date: date)
|
18
39
|
end
|
19
40
|
|
20
41
|
it "is delayed" do
|
@@ -61,7 +82,7 @@ describe Gares::Train do
|
|
61
82
|
end
|
62
83
|
|
63
84
|
subject do
|
64
|
-
Gares::Train.new(train_number, date)
|
85
|
+
Gares::Train.new(num: train_number, date: date)
|
65
86
|
end
|
66
87
|
|
67
88
|
it "is delayed" do
|
@@ -77,7 +98,7 @@ describe Gares::Train do
|
|
77
98
|
expect(subject.departure.delayed?).to be(false)
|
78
99
|
end
|
79
100
|
|
80
|
-
it "has stops"
|
101
|
+
it "has stops" do
|
81
102
|
expect(subject.stops.size).to eq(7)
|
82
103
|
expect(subject.stops.first.station.name).to eq('Nogent-sur-Seine')
|
83
104
|
|
@@ -104,7 +125,7 @@ describe Gares::Train do
|
|
104
125
|
end
|
105
126
|
|
106
127
|
subject do
|
107
|
-
Gares::Train.new(train_number, date)
|
128
|
+
Gares::Train.new(num: train_number, date: date)
|
108
129
|
end
|
109
130
|
|
110
131
|
it "selects always the first itinerary", focus: true do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# By default if you have the FakeWeb gem installed when the specs are
|
2
2
|
# run they will hit recorded responses. However, if you don't have
|
3
3
|
# the FakeWeb gem installed or you set the environment variable
|
4
|
-
# LIVE_TEST then the tests will hit the live site gares-
|
4
|
+
# LIVE_TEST then the tests will hit the live site gares-sncf.com and sncf.com.
|
5
5
|
#
|
6
6
|
# Having both methods available for testing allows you to quickly
|
7
7
|
# refactor and add features, while also being able to make sure that
|
8
|
-
# no changes to the gares-
|
8
|
+
# no changes to the gares-sncf.com interface have affected the parser.
|
9
9
|
###
|
10
10
|
|
11
11
|
require 'simplecov'
|
@@ -16,24 +16,17 @@ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
|
16
16
|
]
|
17
17
|
SimpleCov.start
|
18
18
|
|
19
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
20
|
-
require 'gares'
|
21
|
-
|
22
19
|
def read_fixture(path)
|
23
20
|
File.read(File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', path)))
|
24
21
|
end
|
25
22
|
|
26
23
|
# Fixtures for Gares
|
27
24
|
GARES_SAMPLES = {
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'
|
31
|
-
'http://www.gares-
|
32
|
-
'http://www.gares-
|
33
|
-
'http://www.gares-en-mouvement.com/fr/frxag/votre-gare' => 'frxag',
|
34
|
-
'http://www.gares-en-mouvement.com/fr/frlpd/votre-gare' => 'frlpd',
|
35
|
-
'http://www.gares-en-mouvement.com/fr/frhco/votre-gare' => 'frhco',
|
36
|
-
'https://raw.githubusercontent.com/capitainetrain/stations/master/stations.csv' => 'stations.csv'
|
25
|
+
'https://raw.githubusercontent.com/capitainetrain/stations/master/stations.csv' => 'stations.csv',
|
26
|
+
'https://raw.githubusercontent.com/paulrbr/stations/stations-with-bls/stations.csv' => 'bls.csv',
|
27
|
+
'https://ressources.data.sncf.com/api/records/1.0/search?dataset=referentiel-gares-voyageurs&q=0087723197' => '87723197.json',
|
28
|
+
'http://www.gares-sncf.com/fr/train-times/arrival/LYD/gl' => 'LYD-arrivals.json',
|
29
|
+
'http://www.gares-sncf.com/fr/train-times/departure/LYD/gl' => 'LYD-departures.json'
|
37
30
|
}
|
38
31
|
|
39
32
|
# Sample fixtures for Trains
|
@@ -41,6 +34,7 @@ TRAINS_SAMPLES = [
|
|
41
34
|
{ 17709 => 'train-17709' },
|
42
35
|
{ 11641 => 'train-11641' },
|
43
36
|
{ 17495 => 'train-17495' },
|
37
|
+
{ 12345 => 'train-12345' },
|
44
38
|
{ 6815 => 'train-6815' }, # Multi-itinerary see MULTI_TRAINS_SAMPLES
|
45
39
|
]
|
46
40
|
|
@@ -58,7 +52,7 @@ unless ENV['LIVE_TEST']
|
|
58
52
|
FakeWeb.register_uri(:get, url, response: read_fixture(response))
|
59
53
|
end
|
60
54
|
rescue LoadError
|
61
|
-
puts 'Could not load FakeWeb, these tests will hit gares-
|
55
|
+
puts 'Could not load FakeWeb, these tests will hit gares-sncf.com and sncf.com'
|
62
56
|
puts 'You can run `gem install fakeweb` to stub out the responses.'
|
63
57
|
end
|
64
58
|
end
|
@@ -80,8 +74,12 @@ def fake_response_for_train(number)
|
|
80
74
|
FakeWeb.register_uri(:get, sncf_get_data_url, response: read_fixture("get-#{multi_response}-data"))
|
81
75
|
end
|
82
76
|
rescue LoadError
|
83
|
-
puts 'Could not load FakeWeb, these tests will hit gares-
|
77
|
+
puts 'Could not load FakeWeb, these tests will hit gares-sncf.com and sncf.com'
|
84
78
|
puts 'You can run `gem install fakeweb` to stub out the responses.'
|
85
79
|
end
|
86
80
|
end
|
87
81
|
end
|
82
|
+
|
83
|
+
# Now that we mocked http requests, load the gem
|
84
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
85
|
+
require 'gares'
|