Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Second spec passing

  • Loading branch information...
commit 03e8dec4d9ab2528e3f184b75736adfa5074479c 1 parent 4e6bc35
Jack Chen authored
6 lib/metlinkr/step.rb
@@ -11,6 +11,7 @@ def parse(row_set)
11 11 @row_set = row_set
12 12
13 13 parse_method
  14 + parse_origin
14 15
15 16 self
16 17 end
@@ -23,5 +24,10 @@ def parse_method
23 24 :tram
24 25 end
25 26 end
  27 +
  28 + def parse_origin
  29 + @origin = @row_set[0].xpath("td/strong/a").first.content
  30 + @origin.gsub!(/(\d+)-/, 'Stop \1 - ')
  31 + end
26 32 end
27 33 end
2  spec/fixtures/tram_snippet.html
... ... @@ -1,3 +1,3 @@
1   -<table width="100%" border="0" cellpadding="2" cellspacing="2" text-align="top"><tr class="h3"><th width="12%" colspan="2">Travel by</th><th width="5%"></th><th width="8%">Time</th><th width="37%">Details</th><th width="8%">Map</th><th width="30%" colspan="2">Information</th></tr><tr class="p2_results"><td width="12%" colspan="2" style="text-align:center;"><img src="images/metlink/means/TramIcon30px.gif" alt="Metro Tram"></td><td width="5%" style="text-align:right;" alt="Departure" title="Departure">DEP:</td><td width="8%" style="text-align:left;"><span>Mon, 8:39 pm</span></td><td width="37%"><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19742" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="29-Barkers Rd/High St (Kew)" border="0" class="dontprint"></a></span><strong>From Stop <a href="http://www.metlinkmelbourne.com.au/stop/view/19742" class="soi" target="_blank">29-Barkers Rd/High St (Kew)</a></strong></td><td width="8%" style="vertical-align:top;text-align:center;"><a href="FILELOAD?Filename=VIC_4EDC940C1.pdf" target="_blank"><img src="images/metlink/jp/stopmap.gif" alt="Stop Map" width="38" height="29" border="0"></a></td><td colspan="2" width="30%">
  1 +<tr class="p2_results"><td width="12%" colspan="2" style="text-align:center;"><img src="images/metlink/means/TramIcon30px.gif" alt="Metro Tram"></td><td width="5%" style="text-align:right;" alt="Departure" title="Departure">DEP:</td><td width="8%" style="text-align:left;"><span>Mon, 8:39 pm</span></td><td width="37%"><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19742" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="29-Barkers Rd/High St (Kew)" border="0" class="dontprint"></a></span><strong>From Stop <a href="http://www.metlinkmelbourne.com.au/stop/view/19742" class="soi" target="_blank">29-Barkers Rd/High St (Kew)</a></strong></td><td width="8%" style="vertical-align:top;text-align:center;"><a href="FILELOAD?Filename=VIC_4EDC940C1.pdf" target="_blank"><img src="images/metlink/jp/stopmap.gif" alt="Stop Map" width="38" height="29" border="0"></a></td><td colspan="2" width="30%">
2 2
3 3 </td></tr><tr class="p2_results"><td colspan="2"></td><td><div></div></td><td><div></div></td><td>Take the Route<strong> 109 tram towards Port Melbourne</strong></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2">Time 9 min<br>Zone(s): 1<br>Operator: Yarra Trams<br><br><a href="XSLT_TRIP_REQUEST2?language=en&amp;command=loadLegTT_1_1&amp;sessionID=VICWA06_732007765&amp;requestID=1&amp;tripSelection=on&amp;tripSelector1=1&amp;itdLPxx_view=detail&amp;itdLPxx_legTT=:1_1">Leg Timetable</a></td></tr><tr class="p2_results"><td colspan="2"><div align="center"></div></td><td><div align="right" alt="Arrival" title="Arrival">ARR:</div></td><td><div align="left"><span>Mon, 8:48 pm</span></div></td><td><span style="padding: 1px; margin-top: 2px;"><a href="http://www.metlinkmelbourne.com.au/stop/view/19732" target="_blank"><img src="images/metlink/jp/info.gif" height="12" width="12" alt="19-North Richmond Railway Station/Victoria St (Richmond)" border="0" class="dontprint"></a></span>Get off at stop <a href="http://www.metlinkmelbourne.com.au/stop/view/19732" class="soi" target="_blank">19-North Richmond Railway Station/Victoria St (Richmond)</a></td><td style="vertical-align:top;text-align:center;"></td><td colspan="2"></td></tr>
4 spec/step_spec.rb
@@ -17,5 +17,9 @@
17 17 it "parses the mode of transport" do
18 18 subject.method.should == :tram
19 19 end
  20 +
  21 + it "parses the origin name" do
  22 + subject.origin.should == "Stop 29 - Barkers Rd/High St (Kew)"
  23 + end
20 24 end
21 25 end

0 comments on commit 03e8dec

Please sign in to comment.
Something went wrong with that request. Please try again.