File tree Expand file tree Collapse file tree 3 files changed +8
-18
lines changed Expand file tree Collapse file tree 3 files changed +8
-18
lines changed Original file line number Diff line number Diff line change 1
- require 'httparty '
2
- require 'addressable/uri '
1
+ require 'net/http '
2
+ require 'json '
3
3
4
4
module OpenWeather
5
5
class Base
@@ -37,16 +37,16 @@ def extract_options!(options)
37
37
end
38
38
39
39
def parse_response
40
- @weather_info = @response
40
+ @weather_info = JSON . parse ( @response )
41
41
@status = @weather_info [ "cod" ]
42
42
@message = @weather_info [ "message" ] unless @status
43
43
@weather_info
44
44
end
45
45
46
46
def send_request ( request )
47
- uri = Addressable :: URI . parse ( request . url )
48
- uri . query_values = request . options
49
- HTTParty . get ( uri . to_s )
47
+ uri = URI ( request . url )
48
+ uri . query = URI . encode_www_form ( request . options )
49
+ Net :: HTTP . get ( uri )
50
50
end
51
51
end
52
52
end
Original file line number Diff line number Diff line change @@ -14,7 +14,5 @@ Gem::Specification.new do |gem|
14
14
gem . executables = gem . files . grep ( /^bin/ ) . map { |f | File . basename ( f ) }
15
15
gem . require_paths = [ "lib" ]
16
16
gem . add_development_dependency "rspec"
17
-
18
- gem . add_runtime_dependency 'httparty'
19
- gem . add_runtime_dependency 'addressable'
17
+ gem . add_runtime_dependency 'json'
20
18
end
Original file line number Diff line number Diff line change 1
1
require 'spec_helper'
2
2
3
3
# success response
4
- #
4
+ #
5
5
# {"coord"=>{"lon"=>76.26, "lat"=>9.94},
6
6
# "sys"=>
7
7
# {"message"=>0.1938,
31
31
#
32
32
# {"message"=>"Error: Not found city", "cod"=>"404"}
33
33
34
- describe 'Connection Error' do
35
- it 'return error when the network is unreachable' do
36
- response = OpenWeather ::Current . city ( 'Cochin, In' )
37
- response [ 'cod' ] . should eq ( 200 )
38
- end
39
- end
40
-
41
-
42
34
describe 'Open weather Current API' do
43
35
context '.city' do
44
36
it 'return current weather for cochi' do
You can’t perform that action at this time.
0 commit comments