spbus 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/spec/request_spec.rb CHANGED
@@ -2,18 +2,37 @@ require "spec_helper"
2
2
 
3
3
  describe SpBus::Request do
4
4
 
5
- describe "#get", vcr: { cassette_name: "simple_request" } do
5
+ describe "#get" do
6
6
 
7
- subject { described_class.new("http://200.99.150.170/PlanOperWeb/linhaselecionada.asp?Linha=6450-10") }
7
+ context "authenticated request", vcr: { cassette_name: "auth_request" } do
8
8
 
9
- it "does not raise any error" do
10
- expect {
11
- subject.get
12
- }.to_not raise_error
9
+ subject { described_class.new("http://olhovivo.sptrans.com.br/v0/Linha/Buscar?termosBusca=6400-10") }
10
+
11
+ it "does not raise any error when fetching an authenticated resource" do
12
+ expect {
13
+ subject.get
14
+ }.to_not raise_error
15
+ end
16
+
17
+ it "returns expected content" do
18
+ expect(subject.get).to match(/CodigoLinha/)
19
+ end
13
20
  end
14
21
 
15
- it "returns expected content" do
16
- expect(subject.get).to match(/Selecione abaixo o resultado desejado/)
22
+ context "unauthenticated request", vcr: { cassette_name: "normal_request" } do
23
+
24
+ subject { described_class.new("http://200.99.150.170/PlanOperWeb/linhaselecionada.asp?Linha=6450-10") }
25
+ before { subject.authenticated = false }
26
+
27
+ it "does not raise any error" do
28
+ expect {
29
+ subject.get
30
+ }.to_not raise_error
31
+ end
32
+
33
+ it "returns expected content" do
34
+ expect(subject.get).to match(/Selecione abaixo o resultado desejado/)
35
+ end
17
36
  end
18
37
  end
19
38
  end
@@ -8,16 +8,16 @@ describe SpBus::Scrapers::Locations do
8
8
  before { subject.fetch }
9
9
 
10
10
  it "creates a Bus object for every position" do
11
- expect(subject.buses).to have(7).item
11
+ expect(subject.buses).to have(3).item
12
12
  expect(subject.buses.first).to be_kind_of(SpBus::Bus)
13
13
  end
14
14
 
15
15
  it "sets bus latitude" do
16
- expect(subject.buses.first.latitude).to eql(-23.576496125)
16
+ expect(subject.buses.first.latitude).to eql(-23.604221250000002)
17
17
  end
18
18
 
19
19
  it "sets bus longitude" do
20
- expect(subject.buses.first.longitude).to eql(-46.67068125)
20
+ expect(subject.buses.first.longitude).to eql(-46.6749935)
21
21
  end
22
22
  end
23
23
  end
@@ -7,7 +7,7 @@ describe SpBus::Scrapers::Routes do
7
7
  before { subject.fetch }
8
8
 
9
9
  it "returns all bus routes" do
10
- expect(subject.routes).to have(1305).items
10
+ expect(subject.routes).to have(1315).items
11
11
  end
12
12
 
13
13
  it "returns a Route object for every found route" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spbus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lenon Marcel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-09 00:00:00.000000000 Z
11
+ date: 2013-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -133,12 +133,13 @@ files:
133
133
  - lib/spbus/version.rb
134
134
  - spbus.gemspec
135
135
  - spec/bus_spec.rb
136
+ - spec/cassettes/auth_request.yml
136
137
  - spec/cassettes/bus_routes.yml
137
138
  - spec/cassettes/buses_locations.yml
138
139
  - spec/cassettes/invalid_route_detail.yml
140
+ - spec/cassettes/normal_request.yml
139
141
  - spec/cassettes/normal_route_detail.yml
140
142
  - spec/cassettes/one_way_route_detail.yml
141
- - spec/cassettes/simple_request.yml
142
143
  - spec/request_spec.rb
143
144
  - spec/route_spec.rb
144
145
  - spec/scrapers/locations_scraper_spec.rb
@@ -173,12 +174,13 @@ summary: A gem to easily retrieve information about São Paulo bus routes, numbe
173
174
  location, etc using SPTrans web services.
174
175
  test_files:
175
176
  - spec/bus_spec.rb
177
+ - spec/cassettes/auth_request.yml
176
178
  - spec/cassettes/bus_routes.yml
177
179
  - spec/cassettes/buses_locations.yml
178
180
  - spec/cassettes/invalid_route_detail.yml
181
+ - spec/cassettes/normal_request.yml
179
182
  - spec/cassettes/normal_route_detail.yml
180
183
  - spec/cassettes/one_way_route_detail.yml
181
- - spec/cassettes/simple_request.yml
182
184
  - spec/request_spec.rb
183
185
  - spec/route_spec.rb
184
186
  - spec/scrapers/locations_scraper_spec.rb