From 99f5d892b3295fffd3cdab377b955d773f3c9792 Mon Sep 17 00:00:00 2001 From: Arturo Reuschenbach Puncernau Date: Mon, 30 May 2022 15:15:23 +0200 Subject: [PATCH] upgraded libs and ruby version --- .ruby-version | 2 +- .travis.yml | 4 ++-- README.md | 9 +++++++++ lib/lyra_client.rb | 4 +++- lib/lyra_client/version.rb | 2 +- lyra_client.gemspec | 10 +++++----- spec/lyra_client_spec.rb | 10 +++++++++- 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.ruby-version b/.ruby-version index ccbccc3..49cdd66 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.2.0 +2.7.6 diff --git a/.travis.yml b/.travis.yml index c5324ae..14a8334 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ sudo: false language: ruby rvm: - - 2.2.0 -before_install: gem install bundler -v 1.13.1 + - 2.7.6 +before_install: gem install bundler -v 2.3.13 diff --git a/README.md b/README.md index c9e1ece..d8b86cc 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,11 @@ # lyra-client + Ruby client to use the Lyra API + +# Testing + +Run following command: + +```bash +bundle exec rspec +``` diff --git a/lib/lyra_client.rb b/lib/lyra_client.rb index 2d052fd..e80ab9d 100644 --- a/lib/lyra_client.rb +++ b/lib/lyra_client.rb @@ -106,7 +106,9 @@ def instantiate_collection(response) end def singleton_path(id, query_options = nil) - "#{path_prefix}/#{collection_name}/#{URI.escape(id.to_s)}#{query_string(query_options)}" + # changed URI.scape to CGI.escape as proposed here + # https://ruby-doc.org/stdlib-2.7.0/libdoc/uri/rdoc/URI/Escape.html + "#{path_prefix}/#{collection_name}/#{CGI.escape(id.to_s)}#{query_string(query_options)}" end def collection_path(query_options = nil) diff --git a/lib/lyra_client/version.rb b/lib/lyra_client/version.rb index 3261e28..9864e05 100644 --- a/lib/lyra_client/version.rb +++ b/lib/lyra_client/version.rb @@ -1,3 +1,3 @@ module LyraClient - VERSION = "0.1.1" + VERSION = "0.2.0" end diff --git a/lyra_client.gemspec b/lyra_client.gemspec index 2055ad1..fb73dba 100644 --- a/lyra_client.gemspec +++ b/lyra_client.gemspec @@ -19,9 +19,9 @@ Gem::Specification.new do |spec| end spec.require_paths = ["lib"] - spec.add_development_dependency "bundler", "~> 1.13" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" - spec.add_development_dependency 'pry', '~> 0.10.3' - spec.add_development_dependency 'excon', '~> 0.52.0' + spec.add_development_dependency "bundler", "~> 2.3.13" + spec.add_development_dependency "rake", "~> 13.0.6" + spec.add_development_dependency "rspec", "~> 3.11.0" + spec.add_development_dependency 'pry', '~> 0.14.1' + spec.add_development_dependency 'excon', '~> 0.92.3' end diff --git a/spec/lyra_client_spec.rb b/spec/lyra_client_spec.rb index fca98c9..f821326 100644 --- a/spec/lyra_client_spec.rb +++ b/spec/lyra_client_spec.rb @@ -83,6 +83,14 @@ class LyraClientTestFindClass < LyraClient::Base expect(one.attributes).to be == element end + it "should encode the id" do + element = FakeFactory.automation('id' => "test test") + Excon.stub({path: "/api/v1/automations/test+test", method: 'get'}, {:body => element.to_json, :status => 200}) + + one = LyraClientTestFindClass.find("test test", {"X-Auth-Token" => 'this_is_a_token'}) + expect(one.attributes).to be == element + end + end end @@ -236,7 +244,7 @@ class LyraClientTestCollectionClass < LyraClient::Base it "should raise an exception when no 200 or 201" do Excon.stub({}, {:body => "Not found", :status => 404}) - expect { LyraClientTestFindClass.find("1") }.to raise_error + expect { LyraClientTestFindClass.find("1") }.to raise_error(Excon::Error::NotFound) end end