Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get quote if stock_symbol have "^" #14

Open
ironsand opened this issue Apr 25, 2014 · 2 comments
Open

Can't get quote if stock_symbol have "^" #14

ironsand opened this issue Apr 25, 2014 · 2 comments

Comments

@ironsand
Copy link

Like ^GSPC, some stock symbol have a charactor ^, that causes YahooStock::Interface::InterfaceError: bad URI(is not URI?): error.

I fixed the by replacing in lib/yahoo_stock/interface.rb

response = Net::HTTP.get_response(URI.parse(uri))

to

response = Net::HTTP.get_response(URI.parse(URI.encode(uri)))

I wanted to send Pull Request, but rspec test fails with this code.

rspec ./spec/yahoo_stock/interface/quote_spec.rb:199 # YahooStock::Interface::Quote get should use uri to get the content
rspec ./spec/yahoo_stock/interface/quote_spec.rb:204 # YahooStock::Interface::Quote get should get response for the uri
rspec ./spec/yahoo_stock/interface/quote_spec.rb:209 # YahooStock::Interface::Quote get should parse the uri
rspec ./spec/yahoo_stock/interface/quote_spec.rb:214 # YahooStock::Interface::Quote get should check the response code
rspec ./spec/yahoo_stock/interface/quote_spec.rb:219 # YahooStock::Interface::Quote get should get the body of the response if returned code is 200, ie success
rspec ./spec/yahoo_stock/interface/scrip_symbol_spec.rb:23 # YahooStock::Interface::ScripSymbol get should find or generate the uri once in the get method and once in the et method of the super class

How can I fix uri problem without breaking Rspec test?

@nas
Copy link
Owner

nas commented May 7, 2014

sorry for the late reply, do you have a PR for the fix? then I might be able to give the right suggestion, OTOH I don't think its just the specs but I think your changes are actually breaking the code

@ironsand
Copy link
Author

ironsand commented May 7, 2014

Thanks for answering. I've just sent a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants