diff --git a/README.md b/README.md index 5c838ad..27def72 100755 --- a/README.md +++ b/README.md @@ -58,10 +58,11 @@ This is a 2 step process. First get the link to redirect the user. This is very easy! Just: ```ruby -redirectUrl = meli.auth_url("http://somecallbackurl") +redirect_url = meli.auth_url("http://somecallbackurl", "AR") ``` -This will give you the url to redirect the user. You need to specify a callback url which will be the one that the user will redirected after a successfull authrization process. +This will give you the url to redirect the user. You need to specify a callback url which will be the one that the user will redirected after a successfull authrization process. +The country code param (`"AR"`) is optional, it’s set to `"BR"` by default. Take into account that if you don’t specify this, it will only work if your MercadoLibre app is from Brazil. Once the user is redirected to your callback url, you'll receive in the query string, a parameter named ```code```. You'll need this for the second part of the process. diff --git a/lib/config.yml b/lib/config.yml deleted file mode 100755 index 5fdc814..0000000 --- a/lib/config.yml +++ /dev/null @@ -1,21 +0,0 @@ -config: - sdk_version: MELI-RUBY-SDK-1.0.1 - api_root_url: https://api.mercadolibre.com - auth_url: https://auth.mercadolivre.com.br/authorization # # Don't forget to set the URL of your country. - oauth_url: /oauth/token - -# Set the auth_url according to your country - -#MLA https://auth.mercadolibre.com.ar/authorization # Argentina -#MLB https://auth.mercadolivre.com.br/authorization # Brasil -#MCO https://auth.mercadolibre.com.co/authorization # Colombia -#MCR https://auth.mercadolibre.com.cr/authorization # Costa Rica -#MEC https://auth.mercadolibre.com.ec/authorization # Ecuador -#MLC https://auth.mercadolibre.cl/authorization # Chile -#MLM https://auth.mercadolibre.com.mx/authorization # Mexico -#MLU https://auth.mercadolibre.com.uy/authorization # Uruguay -#MLV https://auth.mercadolibre.com.ve/authorization # Venezuela -#MPA https://auth.mercadolibre.com.pa/authorization # Panama -#MPE https://auth.mercadolibre.com.pe/authorization # Peru -#MPT https://auth.mercadolibre.com.pt/authorization # Prtugal -#MRD https://auth.mercadolibre.com.do/authorization # Dominicana diff --git a/lib/constants.rb b/lib/constants.rb new file mode 100644 index 0000000..37cd40d --- /dev/null +++ b/lib/constants.rb @@ -0,0 +1,17 @@ +SDK_VERSION = "MELI-RUBY-SDK-1.0.1".freeze +API_ROOT_URL = "https://api.mercadolibre.com".freeze +OAUTH_URL = "/oauth/token".freeze + +AUTH_URL_AR = "https://auth.mercadolibre.com.ar/authorization".freeze +AUTH_URL_BR = "https://auth.mercadolivre.com.br/authorization".freeze +AUTH_URL_CO = "https://auth.mercadolibre.com.co/authorization".freeze +AUTH_URL_CR = "https://auth.mercadolibre.com.cr/authorization".freeze +AUTH_URL_EC = "https://auth.mercadolibre.com.ec/authorization".freeze +AUTH_URL_CL = "https://auth.mercadolibre.cl/authorization".freeze +AUTH_URL_MX = "https://auth.mercadolibre.com.mx/authorization".freeze +AUTH_URL_UY = "https://auth.mercadolibre.com.uy/authorization".freeze +AUTH_URL_VE = "https://auth.mercadolibre.com.ve/authorization".freeze +AUTH_URL_PA = "https://auth.mercadolibre.com.pa/authorization".freeze +AUTH_URL_PE = "https://auth.mercadolibre.com.pe/authorization".freeze +AUTH_URL_PT = "https://auth.mercadolibre.com.pt/authorization".freeze +AUTH_URL_DO = "https://auth.mercadolibre.com.do/authorization".freeze diff --git a/lib/meli.rb b/lib/meli.rb index 6626a2a..f087a00 100644 --- a/lib/meli.rb +++ b/lib/meli.rb @@ -5,157 +5,155 @@ require 'net/https' require 'json' require 'uri' -require 'yaml' +require 'constants' class Meli - attr_accessor :access_token, :refresh_token - attr_reader :secret, :app_id, :https - - config = YAML.load_file(File.expand_path(File.dirname(__FILE__) + "/config.yml")) - SDK_VERSION = config["config"]["sdk_version"] - API_ROOT_URL = config["config"]["api_root_url"] - AUTH_URL = config["config"]["auth_url"] - OAUTH_URL = config["config"]["oauth_url"] - - #constructor - def initialize(app_id = nil, secret = nil, access_token = nil, refresh_token = nil) - @access_token = access_token - @refresh_token = refresh_token - @app_id = app_id - @secret = secret - api_url = URI.parse API_ROOT_URL - @https = Net::HTTP.new(api_url.host, api_url.port) - @https.use_ssl = true - @https.verify_mode = OpenSSL::SSL::VERIFY_PEER - @https.ssl_version = :TLSv1 - end - - #AUTH METHODS - def auth_url(redirect_URI) - params = {:client_id => @app_id, :response_type => 'code', :redirect_uri => redirect_URI} - url = "#{AUTH_URL}?#{to_url_params(params)}" - end - - def authorize(code, redirect_URI) - params = { :grant_type => 'authorization_code', :client_id => @app_id, :client_secret => @secret, :code => code, :redirect_uri => redirect_URI} - - uri = make_path(OAUTH_URL, params) - - req = Net::HTTP::Post.new(uri.path) - req['Accept'] = 'application/json' - req['User-Agent'] = SDK_VERSION - req['Content-Type'] = "application/x-www-form-urlencoded" - req.set_form_data(params) - response = @https.request(req) - - case response - when Net::HTTPSuccess - response_info = JSON.parse response.body - #convert hash keys to symbol - response_info = Hash[response_info.map{ |k, v| [k.to_sym, v] }] - - @access_token = response_info[:access_token] - if response_info.has_key?(:refresh_token) - @refresh_token = response_info[:refresh_token] - else - @refresh_token = '' # offline_access not set up - end - @access_token - else - # response code isn't a 200; raise an exception - response.error! - end - - end - - def get_refresh_token() - if !@refresh_token.nil? and !@refresh_token.empty? - params = {:grant_type => 'refresh_token', :client_id => @app_id, :client_secret => @secret, :refresh_token => @refresh_token} - - uri = make_path(OAUTH_URL, params) - - req = Net::HTTP::Post.new(uri.path) - req['Accept'] = 'application/json' - req['User-Agent'] = SDK_VERSION - req['Content-Type'] = "application/x-www-form-urlencoded" - req.set_form_data(params) - response = @https.request(req) - - case response - when Net::HTTPSuccess - response_info = JSON.parse response.body - - #convert hash keys to symbol - response_info = Hash[response_info.map{ |k, v| [k.to_sym, v] }] - - @access_token = response_info[:access_token] - @refresh_token = response_info[:refresh_token] - else - # response code isn't a 200; raise an exception - response.error! - end - else - raise "Offline-Access is not allowed." - end + attr_accessor :access_token, :refresh_token + attr_reader :secret, :app_id, :https + + #constructor + def initialize(app_id = nil, secret = nil, access_token = nil, refresh_token = nil) + @access_token = access_token + @refresh_token = refresh_token + @app_id = app_id + @secret = secret + api_url = URI.parse API_ROOT_URL + @https = Net::HTTP.new(api_url.host, api_url.port) + @https.use_ssl = true + @https.verify_mode = OpenSSL::SSL::VERIFY_PEER + @https.ssl_version = :TLSv1 + end + + def self.auth_url_country(iso_country_code) + const_get "AUTH_URL_#{iso_country_code}" + end + + #AUTH METHODS + def auth_url(redirect_URI, iso_country_code = "BR") + params = {:client_id => @app_id, :response_type => 'code', :redirect_uri => redirect_URI} + url = "#{Meli.auth_url_country(iso_country_code)}?#{to_url_params(params)}" + end + + def authorize(code, redirect_URI) + params = { :grant_type => 'authorization_code', :client_id => @app_id, :client_secret => @secret, :code => code, :redirect_uri => redirect_URI} + + uri = make_path(OAUTH_URL, params) + + req = Net::HTTP::Post.new(uri.path) + req['Accept'] = 'application/json' + req['User-Agent'] = SDK_VERSION + req['Content-Type'] = "application/x-www-form-urlencoded" + req.set_form_data(params) + response = @https.request(req) + + case response + when Net::HTTPSuccess + response_info = JSON.parse response.body + #convert hash keys to symbol + response_info = Hash[response_info.map{ |k, v| [k.to_sym, v] }] + + @access_token = response_info[:access_token] + if response_info.has_key?(:refresh_token) + @refresh_token = response_info[:refresh_token] + else + @refresh_token = '' # offline_access not set up + end + @access_token + else + # response code isn't a 200; raise an exception + response.error! end + end - #REQUEST METHODS - def execute(req) - req['Accept'] = 'application/json' - req['User-Agent'] = SDK_VERSION - req['Content-Type'] = 'application/json' - response = @https.request(req) - end + def get_refresh_token() + if !@refresh_token.nil? and !@refresh_token.empty? + params = {:grant_type => 'refresh_token', :client_id => @app_id, :client_secret => @secret, :refresh_token => @refresh_token} - def get(path, params = {}) - uri = make_path(path, params) - req = Net::HTTP::Get.new("#{uri.path}?#{uri.query}") - execute req - end + uri = make_path(OAUTH_URL, params) - def post(path, body, params = {}) - uri = make_path(path, params) - req = Net::HTTP::Post.new("#{uri.path}?#{uri.query}") - req.set_form_data(params) - req.body = body.to_json unless body.nil? - execute req - end + req = Net::HTTP::Post.new(uri.path) + req['Accept'] = 'application/json' + req['User-Agent'] = SDK_VERSION + req['Content-Type'] = "application/x-www-form-urlencoded" + req.set_form_data(params) + response = @https.request(req) - def put(path, body, params = {}) - uri = make_path(path, params) - req = Net::HTTP::Put.new("#{uri.path}?#{uri.query}") - req.set_form_data(params) - req.body = body.to_json unless body.nil? - execute req - end + case response + when Net::HTTPSuccess + response_info = JSON.parse response.body - def delete(path, params = {}) - uri = make_path(path, params) - req = Net::HTTP::Delete.new("#{uri.path}?#{uri.query}") - execute req - end + #convert hash keys to symbol + response_info = Hash[response_info.map{ |k, v| [k.to_sym, v] }] - def options(path, params = {}) - uri = make_path(path, params) - req = Net::HTTP::Options.new("#{uri.path}?#{uri.query}") - execute req + @access_token = response_info[:access_token] + @refresh_token = response_info[:refresh_token] + else + # response code isn't a 200; raise an exception + response.error! + end + else + raise "Offline-Access is not allowed." end + end + + + #REQUEST METHODS + def execute(req) + req['Accept'] = 'application/json' + req['User-Agent'] = SDK_VERSION + req['Content-Type'] = 'application/json' + response = @https.request(req) + end + + def get(path, params = {}) + uri = make_path(path, params) + req = Net::HTTP::Get.new("#{uri.path}?#{uri.query}") + execute req + end + + def post(path, body, params = {}) + uri = make_path(path, params) + req = Net::HTTP::Post.new("#{uri.path}?#{uri.query}") + req.set_form_data(params) + req.body = body.to_json unless body.nil? + execute req + end + + def put(path, body, params = {}) + uri = make_path(path, params) + req = Net::HTTP::Put.new("#{uri.path}?#{uri.query}") + req.set_form_data(params) + req.body = body.to_json unless body.nil? + execute req + end + + def delete(path, params = {}) + uri = make_path(path, params) + req = Net::HTTP::Delete.new("#{uri.path}?#{uri.query}") + execute req + end + + def options(path, params = {}) + uri = make_path(path, params) + req = Net::HTTP::Options.new("#{uri.path}?#{uri.query}") + execute req + end private - def to_url_params(params) - URI.escape(params.collect{|k,v| "#{k}=#{v}"}.join('&')) - end - - def make_path(path, params = {}) - # Making Path and add a leading / if not exist - unless path =~ /^http/ - path = "/#{path}" unless path =~ /^\// - path = "#{API_ROOT_URL}#{path}" - end - path = "#{path}?#{to_url_params(params)}" if params.keys.size > 0 - uri = URI.parse path + def to_url_params(params) + URI.escape(params.collect{|k,v| "#{k}=#{v}"}.join('&')) + end + + def make_path(path, params = {}) + # Making Path and add a leading / if not exist + unless path =~ /^http/ + path = "/#{path}" unless path =~ /^\// + path = "#{API_ROOT_URL}#{path}" end + path = "#{path}?#{to_url_params(params)}" if params.keys.size > 0 + uri = URI.parse path + end end #class diff --git a/meli.gemspec b/meli.gemspec index 591550a..88679e4 100644 --- a/meli.gemspec +++ b/meli.gemspec @@ -19,11 +19,13 @@ Gem::Specification.new do |spec| spec.homepage = "http://developers.mercadolibre.com" spec.license = "MIT" - spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|examples)/}) } spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] spec.add_development_dependency "bundler", "~> 1.8" spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency "rspec", "~> 2.99.0" + spec.add_development_dependency "json", "~> 1.8" end diff --git a/spec/meli_spec.rb b/spec/meli_spec.rb index 8173f40..9c556d0 100644 --- a/spec/meli_spec.rb +++ b/spec/meli_spec.rb @@ -4,169 +4,179 @@ describe Meli do - before(:each) do - @client_id = "1234567" - @secret_code = "a secret" - @access_token = "access_token" - @refresh_token = "refresh_token" - @new_access_token = "a new access_token" - @new_refresh_token = "a new refresh_token" + before do + @client_id = "1234567" + @secret_code = "a secret" + @access_token = "access_token" + @refresh_token = "refresh_token" + @new_access_token = "a new access_token" + @new_refresh_token = "a new refresh_token" - @meli = Meli.new @client_id, @secret_code, @access_token, @refresh_token + @meli = Meli.new @client_id, @secret_code, @access_token, @refresh_token - @meli.https.stub(:request) do |req| - case req.method - when "GET" - if req.path =~ /\/users\/me/ - if req.path =~ /access_token/ - Net::HTTPOK.new(1, 200, "OK") - else - Net::HTTPForbidden.new(1, 403, "Forbidden") - end - else - Net::HTTPOK.new(1, 200, "OK") - end - when "POST" - if req.path =~ /\/oauth\/token/ - if !req.path =~ /grant_type/ || !req.path =~ /client_id/ || !req.path =~ /client_secret/ - Net::HTTPForbidden.new(1, 403, "Forbidden") - else - response = Net::HTTPOK.new(1, 200, "OK") - if req.body =~ /grant_type=authorization_code/ - def response.body - {:access_token => 'access_token', :refresh_token => 'refresh_token'}.to_json - end - elsif req.body =~ /grant_type=refresh_token/ - def response.body - {:access_token => 'a new access_token', :refresh_token => 'a new refresh_token'}.to_json - end - end - end - response - else - if req.path =~ /access_token/ - Net::HTTPOK.new(1, 200, "OK") - else - Net::HTTPForbidden.new(1, 403, "Forbidden") - end - end - when "PUT" - if req.path =~ /access_token/ - Net::HTTPOK.new(1, 200, "OK") - else - Net::HTTPForbidden.new(1, 403, "Forbidden") - end - when "DELETE" - if req.path =~ /access_token/ - Net::HTTPOK.new(1, 200, "OK") - else - Net::HTTPForbidden.new(1, 403, "Forbidden") - end - else - Net::HTTPInternalServerError.new(1, 500, "Internal Server Error") + @meli.https.stub(:request) do |req| + case req.method + when "GET" + if req.path =~ /\/users\/me/ + if req.path =~ /access_token/ + Net::HTTPOK.new(1, 200, "OK") + else + Net::HTTPForbidden.new(1, 403, "Forbidden") + end + else + Net::HTTPOK.new(1, 200, "OK") + end + when "POST" + if req.path =~ /\/oauth\/token/ + if !req.path =~ /grant_type/ || !req.path =~ /client_id/ || !req.path =~ /client_secret/ + Net::HTTPForbidden.new(1, 403, "Forbidden") + else + response = Net::HTTPOK.new(1, 200, "OK") + if req.body =~ /grant_type=authorization_code/ + def response.body + {:access_token => 'access_token', :refresh_token => 'refresh_token'}.to_json + end + elsif req.body =~ /grant_type=refresh_token/ + def response.body + {:access_token => 'a new access_token', :refresh_token => 'a new refresh_token'}.to_json + end end - end #stub - end #before each + end + response + else + if req.path =~ /access_token/ + Net::HTTPOK.new(1, 200, "OK") + else + Net::HTTPForbidden.new(1, 403, "Forbidden") + end + end + when "PUT" + if req.path =~ /access_token/ + Net::HTTPOK.new(1, 200, "OK") + else + Net::HTTPForbidden.new(1, 403, "Forbidden") + end + when "DELETE" + if req.path =~ /access_token/ + Net::HTTPOK.new(1, 200, "OK") + else + Net::HTTPForbidden.new(1, 403, "Forbidden") + end + else + Net::HTTPInternalServerError.new(1, 500, "Internal Server Error") + end + end #stub + end #before each - describe "Requireds Gems" do - it "should have json gem version 1.8.0" do - Gem::Specification::find_all_by_name('json').any?.should be_true - end + describe "Requireds Gems" do + it "should have json gem version 1.8.0" do + expect(Gem::Specification::find_all_by_name('json').any?).to be_truthy end + end - describe "#new" do - it "should return a Meli object" do - @meli.should be_an_instance_of Meli - end - it "should return corret app_id" do - @meli.app_id.should == @client_id - end - it "should return corret secret" do - @meli.secret.should == @secret_code - end - it "should return correct access_token" do - @meli.access_token.should == @access_token - end - it "should return correct refresh_token" do - @meli.refresh_token.should == @refresh_token - end - it "should return a net/http service" do - @meli.https.should be_an_instance_of Net::HTTP - end - it "should have a http service with ssl" do - @meli.https.use_ssl?.should be_true - end + describe "#new" do + it "should return a Meli object" do + expect(@meli).to be_an_instance_of Meli end + it "should return corret app_id" do + expect(@meli.app_id).to eq @client_id + end + it "should return corret secret" do + expect(@meli.secret).to eq @secret_code + end + it "should return correct access_token" do + expect(@meli.access_token).to eq @access_token + end + it "should return correct refresh_token" do + expect(@meli.refresh_token).to eq @refresh_token + end + it "should return a net/http service" do + expect(@meli.https).to be_an_instance_of Net::HTTP + end + it "should have a http service with ssl" do + expect(@meli.https.use_ssl?).to be_truthy + end + end - describe "http methods" do - it "should return a reponse from get" do - response = @meli.get("/items/test1") - response.should be_an_instance_of Net::HTTPOK - end - it "should return a reponse from post" do - body = {"condition"=>"new", - "warranty"=>"60 dias", - "currency_id"=>"BRL", - "accepts_mercadopago"=>true, - "description"=>"Lindo Ray_Ban_Original_Wayfarer", - "listing_type_id"=>"bronze", - "title"=>"\303\223culos Ray Ban Aviador Que Troca As Lentes Lan\303\247amento!", - "available_quantity"=>64, - "price"=>289, - "subtitle"=>"Acompanha 3 Pares De Lentes!! Compra 100% Segura", - "buying_mode"=>"buy_it_now", - "category_id"=>"MLB5125", - "pictures"=>[{"source"=>"http://upload.wikimedia.org/wikipedia/commons/f/fd/Ray_Ban_Original_Wayfarer.jpg"}, - {"source"=>"http://en.wikipedia.org/wiki/File:Teashades.gif"}] - } - response = @meli.post("/items/test1", body, {:access_token => @meli.access_token}) - response.should be_an_instance_of Net::HTTPOK - end - it "should return a reponse from put" do - body = {"title"=>"New Title", "price"=>1000} - response = @meli.put("/items/test1", body, {:access_token => @meli.access_token}) - response.should be_an_instance_of Net::HTTPOK - end - it "should return a reponse from delete" do - response = @meli.delete("/questions/123", {:access_token => @meli.access_token}) - response.should be_an_instance_of Net::HTTPOK - end - it "get should return forbidden without access_token" do - response = @meli.get("/users/me") - response.should be_an_instance_of Net::HTTPForbidden - end - it "get should return OK with access_token" do - response = @meli.get("/users/me", {:access_token => @meli.access_token}) - response.should be_an_instance_of Net::HTTPOK - end + describe "http methods" do + it "should return a reponse from get" do + response = @meli.get("/items/test1") + expect(response).to be_an_instance_of Net::HTTPOK + end + it "should return a reponse from post" do + body = {"condition"=>"new", + "warranty"=>"60 dias", + "currency_id"=>"BRL", + "accepts_mercadopago"=>true, + "description"=>"Lindo Ray_Ban_Original_Wayfarer", + "listing_type_id"=>"bronze", + "title"=>"\303\223culos Ray Ban Aviador Que Troca As Lentes Lan\303\247amento!", + "available_quantity"=>64, + "price"=>289, + "subtitle"=>"Acompanha 3 Pares De Lentes!! Compra 100% Segura", + "buying_mode"=>"buy_it_now", + "category_id"=>"MLB5125", + "pictures"=>[{"source"=>"http://upload.wikimedia.org/wikipedia/commons/f/fd/Ray_Ban_Original_Wayfarer.jpg"}, + {"source"=>"http://en.wikipedia.org/wiki/File:Teashades.gif"}] + } + response = @meli.post("/items/test1", body, {:access_token => @meli.access_token}) + expect(response).to be_an_instance_of Net::HTTPOK + end + it "should return a reponse from put" do + body = {"title"=>"New Title", "price"=>1000} + response = @meli.put("/items/test1", body, {:access_token => @meli.access_token}) + expect(response).to be_an_instance_of Net::HTTPOK end + it "should return a reponse from delete" do + response = @meli.delete("/questions/123", {:access_token => @meli.access_token}) + expect(response).to be_an_instance_of Net::HTTPOK + end + it "get should return forbidden without access_token" do + response = @meli.get("/users/me") + expect(response).to be_an_instance_of Net::HTTPForbidden + end + it "get should return OK with access_token" do + response = @meli.get("/users/me", {:access_token => @meli.access_token}) + expect(response).to be_an_instance_of Net::HTTPOK + end + end - describe "Auth Url" do - it "should return the correct auth url" do - callback = "http://test.com/callback" - @meli.auth_url(callback).should match "^https\:\/\/auth.mercadolibre.com\/authorization" - @meli.auth_url(callback).should match callback - @meli.auth_url(callback).should match @client_id - @meli.auth_url(callback).should match "response_type" - end + describe "Auth Url" do + let(:callback) { "http://test.com/callback" } + it "should return the correct default auth url (for Brazil)" do + expect(@meli.auth_url(callback)).to match "^https\:\/\/auth.mercadolivre.com.br\/authorization" + expect(@meli.auth_url(callback)).to match callback + expect(@meli.auth_url(callback)).to match @client_id + expect(@meli.auth_url(callback)).to match "response_type" end + + context "with two parameters" do + let(:iso_country_code) { "AR" } + it "should return the correct auth url according to the country" do + expect(@meli.auth_url(callback, iso_country_code)).to match "^https\:\/\/auth.mercadolibre.com.ar\/authorization" + expect(@meli.auth_url(callback, iso_country_code)).to match callback + expect(@meli.auth_url(callback, iso_country_code)).to match @client_id + expect(@meli.auth_url(callback, iso_country_code)).to match "response_type" + end + end + end - describe "Authorize" do - it "should return Access Token" do - @meli.access_token = nil - @meli.refresh_token = nil - @meli.authorize("a code from get param", "A redirect Uri") - @meli.access_token.should == @access_token - @meli.refresh_token.should == @refresh_token - end + describe "Authorize" do + it "should return Access Token" do + @meli.access_token = nil + @meli.refresh_token = nil + @meli.authorize("a code from get param", "A redirect Uri") + expect(@meli.access_token).to eq @access_token + expect(@meli.refresh_token).to eq @refresh_token end + end - describe "Refresh Token" do - it "should return new Access Token and a new Refresh Token" do - response = @meli.get_refresh_token() - @meli.access_token.should == @new_access_token - @meli.refresh_token == @new_refresh_token - end + describe "Refresh Token" do + it "should return new Access Token and a new Refresh Token" do + response = @meli.get_refresh_token + expect(@meli.access_token).to eq @new_access_token + expect(@meli.refresh_token).to eq @new_refresh_token end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 65049f0..3a1910f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1 @@ require File.expand_path(File.dirname(__FILE__) + '/../lib/meli') - -require 'yaml'