Sha256: 1ed1cca5172800c6fa9cf12f51792dc0d6af0a73e9725666017655db5e5f570b
Contents?: true
Size: 1.43 KB
Versions: 4
Compression:
Stored size: 1.43 KB
Contents
# encoding: utf-8 require 'spec_helper' describe BikePOA::MapParser do include FixtureHelper context 'given a full map page' do let(:map_page) { fixture('full_page.html').unpack('C*').pack('U*') } # gambi pattern around encoding silliness let(:result) { subject.parse(map_page) } it 'extracts relevant lines out of a map page' do result.should have(40).stations end %w[id name address online status size available].each do |field| it "extracted data for #{field} in all entries" do result.map { |h| h.has_key? field }.should == [true] * 40 end end end context 'given a certain area of a map page' do let(:content) { <<EOF trash trash function criaPonto() { blabla } trash trash trash map.addOverlay( criaPonto(point,4,'Usina do Gasômetro','Avenida Presidente João Goulart, 551','','12x0',23,'A','EO',12,6,0,50) ); EOF } it 'extracts one relevant line containing a station' do result = subject.parse(content) result.should have(1).station end end context 'given a line that has items with commas' do let(:content) { "map.addOverlay( criaPonto(point,4,'Usina, na frente do cachorro-quente','Rua, 551','','12x0',23,'A','EO',12,6,0,50) );" } it 'should not break those items into two items' do entry = subject.parse(content).first entry.should have(7).items entry.values.should include('Usina, na frente do cachorro-quente') end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
bikepoa-tools-0.3.1 | spec/map_parser_spec.rb |
bikepoa-tools-0.3.0 | spec/map_parser_spec.rb |
bikepoa-tools-0.2.0 | spec/map_parser_spec.rb |
bikepoa-tools-0.1.0 | spec/map_parser_spec.rb |