diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..badcd35 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,19 @@ +name: CI + +on: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: .ruby-version + bundler-cache: true + + - name: Run RSpec + run: bundle exec rspec diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..fcdb2e1 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +4.0.0 diff --git a/Gemfile b/Gemfile index 3273628..72ff1c6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,9 @@ source 'http://rubygems.org' gem 'rake', '>= 10.1' +gem 'ostruct' +gem 'logger' +gem 'base64' group :test do gem 'rspec', '>= 3' diff --git a/Gemfile.lock b/Gemfile.lock index 790c916..8bfd684 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,12 +4,14 @@ PATH soundcloud (0.3.4.1) hashie httparty (>= 0.16.4) + logger GEM remote: http://rubygems.org/ specs: - addressable (2.8.4) - public_suffix (>= 2.0.2, < 6.0) + addressable (2.9.0) + public_suffix (>= 2.0.2, < 8.0) + base64 (0.3.0) bigdecimal (4.0.1) crack (0.4.5) rexml @@ -22,10 +24,12 @@ GEM csv mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) + logger (1.7.0) mini_mime (1.1.5) multi_xml (0.8.0) bigdecimal (>= 3.1, < 5) - public_suffix (5.0.1) + ostruct (0.6.3) + public_suffix (7.0.5) rake (13.0.6) rexml (3.4.2) rspec (3.12.0) @@ -56,7 +60,10 @@ PLATFORMS ruby DEPENDENCIES - bundler (~> 2.1) + base64 + bundler (>= 2.1) + logger + ostruct rake (>= 10.1) rspec (>= 3) simplecov (>= 0.7) @@ -64,4 +71,4 @@ DEPENDENCIES webmock (>= 1.13) BUNDLED WITH - 2.1.4 + 4.0.3 diff --git a/lib/soundcloud/client.rb b/lib/soundcloud/client.rb index 210ffd1..53bf042 100644 --- a/lib/soundcloud/client.rb +++ b/lib/soundcloud/client.rb @@ -102,7 +102,7 @@ def authorize_url(options={}) "#{param_name}=#{CGI.escape value}" unless value.nil? end.compact.join("&") store_options(options) - "https://#{host}#{AUTHORIZE_PATH}?response_type=code_and_token&client_id=#{client_id}&redirect_uri=#{URI.escape(redirect_uri)}&#{additional_params}" + "https://#{host}#{AUTHORIZE_PATH}?response_type=code_and_token&client_id=#{client_id}&redirect_uri=#{CGI.escape(redirect_uri)}&#{additional_params}" end def exchange_token(options={}) diff --git a/soundcloud.gemspec b/soundcloud.gemspec index 3de682e..6b3e66b 100644 --- a/soundcloud.gemspec +++ b/soundcloud.gemspec @@ -17,8 +17,9 @@ Gem::Specification.new do |spec| spec.add_dependency('httparty', '>= 0.16.4') spec.add_dependency('hashie') + spec.add_dependency('logger') - spec.add_development_dependency('bundler', '~> 2.1') + spec.add_development_dependency('bundler', '>= 2.1') spec.files = Dir.glob("lib/**/*") + %w(LICENSE.md README.md) spec.require_path = 'lib' diff --git a/spec/soundcloud_spec.rb b/spec/soundcloud_spec.rb index f06a4c4..0b3caf9 100644 --- a/spec/soundcloud_spec.rb +++ b/spec/soundcloud_spec.rb @@ -140,23 +140,23 @@ describe "#authorize_url" do it "generates a authorize_url" do - expect(subject.authorize_url(:redirect_uri => "http://come.back.to/me")).to eq("https://soundcloud.com/connect?response_type=code_and_token&client_id=client&redirect_uri=http://come.back.to/me&") + expect(subject.authorize_url(:redirect_uri => "http://come.back.to/me")).to eq("https://soundcloud.com/connect?response_type=code_and_token&client_id=client&redirect_uri=http%3A%2F%2Fcome.back.to%2Fme&") end it "generates a authorize_url and include the passed display parameter" do - expect(subject.authorize_url(:redirect_uri => "http://come.back.to/me", :display => "popup")).to eq("https://soundcloud.com/connect?response_type=code_and_token&client_id=client&redirect_uri=http://come.back.to/me&display=popup") + expect(subject.authorize_url(:redirect_uri => "http://come.back.to/me", :display => "popup")).to eq("https://soundcloud.com/connect?response_type=code_and_token&client_id=client&redirect_uri=http%3A%2F%2Fcome.back.to%2Fme&display=popup") end it "generates a authorize_url and include the passed state parameter" do - expect(subject.authorize_url(:redirect_uri => "http://come.back.to/me", :state => "hell&yeah")).to eq("https://soundcloud.com/connect?response_type=code_and_token&client_id=client&redirect_uri=http://come.back.to/me&state=hell%26yeah") + expect(subject.authorize_url(:redirect_uri => "http://come.back.to/me", :state => "hell&yeah")).to eq("https://soundcloud.com/connect?response_type=code_and_token&client_id=client&redirect_uri=http%3A%2F%2Fcome.back.to%2Fme&state=hell%26yeah") end it "generates a authorize_url and include the passed scope parameter" do - expect(subject.authorize_url(:redirect_uri => "http://come.back.to/me", :scope => "non-expiring")).to eq("https://soundcloud.com/connect?response_type=code_and_token&client_id=client&redirect_uri=http://come.back.to/me&scope=non-expiring") + expect(subject.authorize_url(:redirect_uri => "http://come.back.to/me", :scope => "non-expiring")).to eq("https://soundcloud.com/connect?response_type=code_and_token&client_id=client&redirect_uri=http%3A%2F%2Fcome.back.to%2Fme&scope=non-expiring") end it "generates a authorize_url and include the passed scope and state parameter" do - expect(subject.authorize_url(:redirect_uri => "http://come.back.to/me", :scope => "non-expiring", :state => "blub")).to eq("https://soundcloud.com/connect?response_type=code_and_token&client_id=client&redirect_uri=http://come.back.to/me&state=blub&scope=non-expiring") + expect(subject.authorize_url(:redirect_uri => "http://come.back.to/me", :scope => "non-expiring", :state => "blub")).to eq("https://soundcloud.com/connect?response_type=code_and_token&client_id=client&redirect_uri=http%3A%2F%2Fcome.back.to%2Fme&state=blub&scope=non-expiring") end end