vertebrae 0.7.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab95ca1c8df33992dad2838e1ca5cab72d9dcedce828825342dc6346e99efa5c
4
- data.tar.gz: '078f6772ffe31b1150d2d32e240231113e91413faf56da77af6f0657e6957c2f'
3
+ metadata.gz: 12abd176ae617d57fb896828dc31331db3e1d0fad69afbfae446096e2347f409
4
+ data.tar.gz: eef8c6ef2349430d071ba10c66797f2d1c73094a224da831a4c20fe1cf6d5b21
5
5
  SHA512:
6
- metadata.gz: 9d42d282cd5c63cedbe256b2eb565309f7dc32864fbf446f6e0335eb8b3e0a66b0b70c5dba93a7070708ca5e37d7a9b2d6766fa9ef3840fd8c4e8eb6cde4dafe
7
- data.tar.gz: a5bc410b164b79d37ce3cf8c0dbf8638d182d26baaa9ca3b14db31579b7b6ab0059045ac4823b25e0335b9e04afc92715fd061a9a52f35c919ce5f9fde7ed7b0
6
+ metadata.gz: 9ce84790ba0a4982e968146a50295aa97265bc160a0358127ebabb09ff0aaa21b4eb21f005435393d1637feebc26a26a3862d3dc23eb983cbd64305e1da9ffae
7
+ data.tar.gz: 899944270224b32549f430c66f09ae5a30d460e0557c01148947a3273656f2b199ade90fefd7e11af292b05c39f83c0d523ebd861870f199f5e458db1e59adf5
@@ -0,0 +1,24 @@
1
+ name: CI
2
+ on: [push]
3
+
4
+ jobs:
5
+ test:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v2
9
+ - uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
10
+ with:
11
+ ruby-version: 2.7
12
+ bundler-cache: true
13
+ - run: bundle install
14
+ - run: bundle exec rspec
15
+ rubocop:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
20
+ with:
21
+ ruby-version: 2.7
22
+ bundler-cache: true
23
+ - run: bundle install
24
+ - run: bundle exec rubocop
data/.gitignore ADDED
@@ -0,0 +1,26 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+ Gemfile.lock
15
+
16
+ # jeweler generated
17
+ pkg
18
+
19
+ # For MacOS:
20
+ #
21
+ .DS_Store
22
+ .idea
23
+
24
+ # For TextMate
25
+ *.tmproj
26
+ tmtags
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.6
1
+ 3.2.2
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'activesupport', '>= 5.1.4'
4
- gem 'faraday', '> 0.9.2'
5
- gem 'faraday_middleware', '> 0.12.2'
6
- gem 'hashie', '> 3.5.7'
4
+ gem 'faraday', '> 2.0'
5
+ gem 'faraday-mashify'
6
+ gem 'faraday-multipart'
7
7
 
8
8
  # Add dependencies to develop your gem here.
9
9
  # Include everything needed to run rake, tests, features, etc.
@@ -12,6 +12,5 @@ group :development do
12
12
  gem "bundler"
13
13
  gem "webmock"
14
14
  gem "rspec-its"
15
- gem "juwelier", git: 'https://github.com/flajann2/juwelier.git'
16
15
  gem "rubocop"
17
16
  end
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # vertebrae
2
+
3
+ Some basic infrastructure for writing beautiful API clients. See tijuana\_client for a small example.
4
+
5
+ [![CI Status](https://github.com/controlshift/vertebrae/actions/workflows/ci.yml/badge.svg)](https://github.com/controlshift/vertebrae/actions/workflows/ci.yml)
6
+
7
+ ## Development
8
+
9
+ After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
10
+
11
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
12
+
13
+ ## Copyright
14
+
15
+ Copyright (c) 2013 Nathan Woodhull. See LICENSE.txt for
16
+ further details.
17
+
data/Rakefile CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'bundler'
5
+ require 'bundler/gem_tasks'
6
+
7
+
5
8
  begin
6
9
  Bundler.setup(:default, :development)
7
10
  rescue Bundler::BundlerError => e
@@ -11,21 +14,6 @@ rescue Bundler::BundlerError => e
11
14
  end
12
15
  require 'rake'
13
16
 
14
- require 'juwelier'
15
- Juwelier::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
- gem.name = "vertebrae"
18
- gem.homepage = "http://github.com/controlshift/vertebrae"
19
- gem.license = "MIT"
20
- gem.summary = %Q{API Client Infrastructure}
21
- gem.description = %Q{A set of low level infrastructure and reusable code for building API clients}
22
- gem.email = "nathan@controlshiftlabs.com"
23
- gem.authors = ["Nathan Woodhull"]
24
-
25
- # dependencies defined in Gemfile
26
- end
27
- Juwelier::RubygemsDotOrgTasks.new
28
-
29
17
  require 'rspec/core'
30
18
  require 'rspec/core/rake_task'
31
19
  RSpec::Core::RakeTask.new(:spec) do |spec|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.2
1
+ 1.0
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'faraday'
4
- require 'faraday_middleware'
5
- require 'response/raise_error'
6
- require 'authorization'
4
+ require 'faraday/multipart'
5
+ require 'faraday/mashify'
6
+ require 'vertebrae/response/raise_error'
7
+ require 'vertebrae/authorization'
7
8
 
8
9
  module Vertebrae
9
10
  class Connection
@@ -37,16 +38,17 @@ module Vertebrae
37
38
  #
38
39
  def default_middleware
39
40
  Proc.new do |builder|
40
- builder.use Faraday::Request::Multipart
41
+ builder.use Faraday::Multipart::Middleware
41
42
  builder.use Faraday::Request::UrlEncoded
42
43
  if configuration.authenticated?
43
- builder.use Faraday::Request::BasicAuthentication, configuration.username, configuration.password
44
+ builder.use Faraday::Request::Authorization, :basic, configuration.username, configuration.password
44
45
  end
45
46
 
46
47
  builder.use Faraday::Response::Logger if ENV['DEBUG']
48
+
47
49
  unless options[:raw]
48
- builder.use FaradayMiddleware::Mashify
49
- builder.use FaradayMiddleware::ParseJson
50
+ builder.use Faraday::Mashify::Middleware
51
+ builder.use Faraday::Response::Json
50
52
  end
51
53
  builder.use Vertebrae::Response::RaiseError
52
54
  builder.adapter configuration.adapter
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'faraday/response'
4
+
3
5
  module Vertebrae
4
6
  module Response
5
- class RaiseError < Faraday::Response::Middleware
7
+ class RaiseError < Faraday::Middleware
6
8
 
7
9
  def on_complete(response)
8
10
  status_code = response[:status].to_i
@@ -12,4 +14,4 @@ module Vertebrae
12
14
  end
13
15
  end
14
16
  end # Response::RaiseError
15
- end
17
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vertebrae
4
+ VERSION = '1.0.1'
5
+ end
data/lib/vertebrae.rb CHANGED
@@ -2,18 +2,19 @@
2
2
 
3
3
  require 'active_support/all'
4
4
 
5
- require 'constants'
6
- require 'authorization'
7
- require 'configuration'
8
- require 'connection'
9
- require 'request'
10
- require 'response_error'
11
- require 'api'
12
- require 'base'
13
- require 'model'
5
+ require 'vertebrae/constants'
6
+ require 'vertebrae/authorization'
7
+ require 'vertebrae/configuration'
8
+ require 'vertebrae/connection'
9
+ require 'vertebrae/request'
10
+ require 'vertebrae/response_error'
11
+ require 'vertebrae/api'
12
+ require 'vertebrae/base'
13
+ require 'vertebrae/model'
14
+ require 'vertebrae/version'
14
15
 
15
16
  require 'railties' if defined? Rails
16
17
 
17
18
  module Vertebrae
18
19
 
19
- end
20
+ end
data/vertebrae.gemspec CHANGED
@@ -1,99 +1,48 @@
1
- # Generated by juwelier
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: vertebrae 0.7.0 ruby lib
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'vertebrae/version'
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "vertebrae".freeze
9
- s.version = "0.7.0"
9
+ s.version = Vertebrae::VERSION
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Nathan Woodhull".freeze]
14
- s.date = "2021-03-22"
14
+ s.date = "2021-07-23"
15
15
  s.description = "A set of low level infrastructure and reusable code for building API clients".freeze
16
16
  s.email = "nathan@controlshiftlabs.com".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
- "README.rdoc"
20
- ]
21
- s.files = [
22
- ".document",
23
- ".rspec",
24
- ".rubocop.yml",
25
- ".ruby-gemset",
26
- ".ruby-version",
27
- ".travis.yml",
28
- "Gemfile",
29
- "LICENSE.txt",
30
- "README.rdoc",
31
- "Rakefile",
32
- "VERSION",
33
- "lib/api.rb",
34
- "lib/authorization.rb",
35
- "lib/base.rb",
36
- "lib/configuration.rb",
37
- "lib/connection.rb",
38
- "lib/constants.rb",
39
- "lib/core_ext/array.rb",
40
- "lib/model.rb",
41
- "lib/railties.rb",
42
- "lib/request.rb",
43
- "lib/response/raise_error.rb",
44
- "lib/response_error.rb",
45
- "lib/vertebrae.rb",
46
- "spec/api_spec.rb",
47
- "spec/configuration_spec.rb",
48
- "spec/dummy/client.rb",
49
- "spec/dummy/dummy.rb",
50
- "spec/logger_spec.rb",
51
- "spec/request_spec.rb",
52
- "spec/spec_helper.rb",
53
- "vertebrae.gemspec"
19
+ "README.md"
54
20
  ]
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ s.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+
55
28
  s.homepage = "http://github.com/controlshift/vertebrae".freeze
56
29
  s.licenses = ["MIT".freeze]
57
- s.rubygems_version = "3.0.8".freeze
58
30
  s.summary = "API Client Infrastructure".freeze
59
31
 
60
32
  if s.respond_to? :specification_version then
61
33
  s.specification_version = 4
62
-
63
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64
- s.add_runtime_dependency(%q<activesupport>.freeze, [">= 5.1.4"])
65
- s.add_runtime_dependency(%q<faraday>.freeze, [">= 1.0"])
66
- s.add_runtime_dependency(%q<faraday_middleware>.freeze, [">= 1.0"])
67
- s.add_runtime_dependency(%q<hashie>.freeze, ["> 3.5.7"])
68
- s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
69
- s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
70
- s.add_development_dependency(%q<webmock>.freeze, [">= 0"])
71
- s.add_development_dependency(%q<rspec-its>.freeze, [">= 0"])
72
- s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
73
- s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
74
- else
75
- s.add_dependency(%q<activesupport>.freeze, [">= 5.1.4"])
76
- s.add_dependency(%q<faraday>.freeze, [">= 1.0"])
77
- s.add_dependency(%q<faraday_middleware>.freeze, [">= 1.0"])
78
- s.add_dependency(%q<hashie>.freeze, ["> 3.5.7"])
79
- s.add_dependency(%q<rspec>.freeze, [">= 0"])
80
- s.add_dependency(%q<bundler>.freeze, [">= 0"])
81
- s.add_dependency(%q<webmock>.freeze, [">= 0"])
82
- s.add_dependency(%q<rspec-its>.freeze, [">= 0"])
83
- s.add_dependency(%q<juwelier>.freeze, [">= 0"])
84
- s.add_dependency(%q<rubocop>.freeze, [">= 0"])
85
- end
86
- else
87
- s.add_dependency(%q<activesupport>.freeze, [">= 5.1.4"])
88
- s.add_dependency(%q<faraday>.freeze, [">= 1.0"])
89
- s.add_dependency(%q<faraday_middleware>.freeze, [">= 1.0"])
90
- s.add_dependency(%q<hashie>.freeze, ["> 3.5.7"])
91
- s.add_dependency(%q<rspec>.freeze, [">= 0"])
92
- s.add_dependency(%q<bundler>.freeze, [">= 0"])
93
- s.add_dependency(%q<webmock>.freeze, [">= 0"])
94
- s.add_dependency(%q<rspec-its>.freeze, [">= 0"])
95
- s.add_dependency(%q<juwelier>.freeze, [">= 0"])
96
- s.add_dependency(%q<rubocop>.freeze, [">= 0"])
97
34
  end
35
+
36
+ s.add_runtime_dependency(%q<activesupport>.freeze, [">= 5.1.4"])
37
+ s.add_runtime_dependency(%q<faraday>.freeze, ["~> 2"])
38
+ s.add_runtime_dependency(%q<faraday-mashify>.freeze, [">= 0"])
39
+ s.add_runtime_dependency(%q<faraday-multipart>.freeze, [">= 0"])
40
+
41
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
42
+ s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
43
+ s.add_development_dependency(%q<webmock>.freeze, [">= 0"])
44
+ s.add_development_dependency(%q<rspec-its>.freeze, [">= 0"])
45
+ s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
46
+ s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
98
47
  end
99
48
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vertebrae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2021-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -28,44 +28,44 @@ dependencies:
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: faraday_middleware
42
+ name: faraday-mashify
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: hashie
56
+ name: faraday-multipart
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 3.5.7
61
+ version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 3.5.7
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -157,39 +157,34 @@ executables: []
157
157
  extensions: []
158
158
  extra_rdoc_files:
159
159
  - LICENSE.txt
160
- - README.rdoc
160
+ - README.md
161
161
  files:
162
162
  - ".document"
163
+ - ".github/workflows/ci.yml"
164
+ - ".gitignore"
163
165
  - ".rspec"
164
166
  - ".rubocop.yml"
165
167
  - ".ruby-gemset"
166
168
  - ".ruby-version"
167
- - ".travis.yml"
168
169
  - Gemfile
169
170
  - LICENSE.txt
170
- - README.rdoc
171
+ - README.md
171
172
  - Rakefile
172
173
  - VERSION
173
- - lib/api.rb
174
- - lib/authorization.rb
175
- - lib/base.rb
176
- - lib/configuration.rb
177
- - lib/connection.rb
178
- - lib/constants.rb
179
174
  - lib/core_ext/array.rb
180
- - lib/model.rb
181
- - lib/railties.rb
182
- - lib/request.rb
183
- - lib/response/raise_error.rb
184
- - lib/response_error.rb
185
175
  - lib/vertebrae.rb
186
- - spec/api_spec.rb
187
- - spec/configuration_spec.rb
188
- - spec/dummy/client.rb
189
- - spec/dummy/dummy.rb
190
- - spec/logger_spec.rb
191
- - spec/request_spec.rb
192
- - spec/spec_helper.rb
176
+ - lib/vertebrae/api.rb
177
+ - lib/vertebrae/authorization.rb
178
+ - lib/vertebrae/base.rb
179
+ - lib/vertebrae/configuration.rb
180
+ - lib/vertebrae/connection.rb
181
+ - lib/vertebrae/constants.rb
182
+ - lib/vertebrae/model.rb
183
+ - lib/vertebrae/railties.rb
184
+ - lib/vertebrae/request.rb
185
+ - lib/vertebrae/response/raise_error.rb
186
+ - lib/vertebrae/response_error.rb
187
+ - lib/vertebrae/version.rb
193
188
  - vertebrae.gemspec
194
189
  homepage: http://github.com/controlshift/vertebrae
195
190
  licenses:
@@ -210,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
205
  - !ruby/object:Gem::Version
211
206
  version: '0'
212
207
  requirements: []
213
- rubygems_version: 3.0.8
208
+ rubygems_version: 3.4.10
214
209
  signing_key:
215
210
  specification_version: 4
216
211
  summary: API Client Infrastructure
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.6
4
- cache: bundler
5
- before_install:
6
- - gem install bundler
7
- script:
8
- - bundle exec rspec
9
- - bundle exec rubocop
data/README.rdoc DELETED
@@ -1,21 +0,0 @@
1
- = vertebrae
2
-
3
- Some basic infrastructure for writing beautiful API clients. See tijuana_client for a small example.
4
-
5
- [![Build Status](https://travis-ci.org/controlshift/vertebrae.svg)](https://travis-ci.org/controlshift/vertebrae)
6
-
7
- == Contributing to vertebrae
8
-
9
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
10
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
11
- * Fork the project.
12
- * Start a feature/bugfix branch.
13
- * Commit and push until you are happy with your contribution.
14
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
15
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
16
-
17
- == Copyright
18
-
19
- Copyright (c) 2013 Nathan Woodhull. See LICENSE.txt for
20
- further details.
21
-
data/spec/api_spec.rb DELETED
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Vertebrae::API do
6
- subject { described_class.new(options) }
7
-
8
- it { expect(described_class.included_modules).to include Vertebrae::Request }
9
-
10
- describe 'initialize' do
11
- before(:each) do
12
- allow_any_instance_of(Vertebrae::API).to receive(:default_options).and_return({content_type: 'foo'})
13
- end
14
-
15
- context 'with an empty hash' do
16
- let(:options) { {} }
17
- specify { expect(subject.connection.options).to eq({content_type: 'foo'}) }
18
- end
19
-
20
- context 'with a default content-type' do
21
- let(:options) { {content_type: 'text/csv'} }
22
- specify { expect(subject.connection.options).to eq({content_type: 'text/csv'}) }
23
- end
24
- end
25
-
26
- describe 'dummy' do
27
- describe 'should delegate to the client class' do
28
- specify { expect(Dummy.new).to respond_to(:api) }
29
- specify { expect(Dummy).to respond_to(:api) }
30
- end
31
- end
32
- end
@@ -1,128 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Vertebrae::Configuration do
6
-
7
- subject { Vertebrae::Configuration.new({}) }
8
-
9
- {:scheme => described_class::DEFAULT_SCHEME,
10
- :ssl => described_class::DEFAULT_SSL,
11
- :user_agent => described_class::DEFAULT_USER_AGENT,
12
- :username => described_class::DEFAULT_USERNAME,
13
- :password => described_class::DEFAULT_PASSWORD }.each do | key, value |
14
- its(key) { should == value }
15
- its("default_#{key}") { should == value }
16
- end
17
-
18
- its(:connection_options) { should be_a Hash }
19
- its(:connection_options) { should be_empty }
20
-
21
- describe "override" do
22
- subject{ Vertebrae::Configuration.new({username: 'foo', password: 'bar', scheme: 'http'}) }
23
-
24
- its(:default_scheme) { should == described_class::DEFAULT_SCHEME }
25
- its(:default_username) { should == described_class::DEFAULT_USERNAME }
26
- its(:default_password) { should == described_class::DEFAULT_PASSWORD }
27
-
28
- its(:scheme) { should == 'http'}
29
- its(:username) { should == 'foo'}
30
- its(:password) { should == 'bar'}
31
- end
32
-
33
- describe "setter" do
34
- before(:each) do
35
- subject.username = 'foo'
36
- end
37
- its(:username) { should == 'foo'}
38
- its(:default_username) { should == described_class::DEFAULT_USERNAME }
39
- end
40
-
41
- describe 'endpoint' do
42
- context 'with no port specification' do
43
- subject { Vertebrae::Configuration.new({host: 'test.com', prefix: ''}) }
44
-
45
- specify { expect(subject.host).to eq('test.com') }
46
- specify { expect(subject.endpoint).to eq('https://test.com')}
47
- end
48
-
49
- context 'with port specification' do
50
- subject { Vertebrae::Configuration.new({host: 'test.com', prefix: '', port: 8080}) }
51
-
52
- specify { expect(subject.port).to eq(8080) }
53
- specify { expect(subject.endpoint).to eq('https://test.com:8080')}
54
-
55
- context 'with prefix' do
56
- subject { Vertebrae::Configuration.new({host: 'test.com', prefix: '/api/v1', port: 8080}) }
57
-
58
- specify { expect(subject.prefix).to eq('/api/v1') }
59
- specify { expect(subject.endpoint).to eq('https://test.com:8080/api/v1')}
60
- end
61
- end
62
- end
63
-
64
- describe 'adapter' do
65
- it 'should default to :net_http' do
66
- expect(subject.adapter).to eq(:net_http)
67
- end
68
- end
69
-
70
- describe 'adapter=' do
71
- it 'should allow setting and retrieval' do
72
- subject.adapter = :foo
73
- expect(subject.adapter).to eq(:foo)
74
- end
75
- end
76
-
77
- describe '#faraday_options' do
78
- subject { Vertebrae::Configuration.new(host: 'example.com') }
79
-
80
- it 'should include headers, ssl, and url settings by default' do
81
- opts = subject.faraday_options
82
- expect(opts.keys).to contain_exactly(:headers, :ssl, :url)
83
- expect(opts[:headers]).to eq({'Accept' => 'application/json;q=0.1',
84
- 'Accept-Charset' => 'utf-8',
85
- 'User-Agent' => 'Vertebrae REST Gem',
86
- 'Content-Type' => 'application/json'})
87
- expect(opts[:ssl]).to eq({})
88
- expect(opts[:url]).to eq 'https://example.com/'
89
- end
90
-
91
- context 'with connection_options' do
92
- let(:connection_options) { {ssl: {verify: false},
93
- timeout: 5} }
94
-
95
- subject { Vertebrae::Configuration.new(host: 'example.com', connection_options: connection_options) }
96
-
97
- it 'should override and extend the default options' do
98
- opts = subject.faraday_options
99
- expect(opts.keys).to contain_exactly(:headers, :ssl, :timeout, :url)
100
- expect(opts[:headers]).to eq({'Accept' => 'application/json;q=0.1',
101
- 'Accept-Charset' => 'utf-8',
102
- 'User-Agent' => 'Vertebrae REST Gem',
103
- 'Content-Type' => 'application/json'})
104
- expect(opts[:ssl]).to eq({verify: false})
105
- expect(opts[:url]).to eq 'https://example.com/'
106
- expect(opts[:timeout]).to eq 5
107
- end
108
- end
109
-
110
- context 'with additional_headers' do
111
- let(:additional_headers) { {'special-auth-token' => 'abcde12345'} }
112
-
113
- subject { Vertebrae::Configuration.new(host: 'example.com', additional_headers: additional_headers) }
114
-
115
- it 'should add the additional headers to the other headers' do
116
- opts = subject.faraday_options
117
- expect(opts.keys).to contain_exactly(:headers, :ssl, :url)
118
- expect(opts[:headers]).to eq({'Accept' => 'application/json;q=0.1',
119
- 'Accept-Charset' => 'utf-8',
120
- 'User-Agent' => 'Vertebrae REST Gem',
121
- 'Content-Type' => 'application/json',
122
- 'special-auth-token' => 'abcde12345'})
123
- expect(opts[:ssl]).to eq({})
124
- expect(opts[:url]).to eq 'https://example.com/'
125
- end
126
- end
127
- end
128
- end
data/spec/dummy/client.rb DELETED
@@ -1,7 +0,0 @@
1
- module Dummy
2
- class Client < Vertebrae::API
3
- def api(options={}, &block)
4
- @api ||= Vertebrae::API.new(current_options.merge(options), &block)
5
- end
6
- end
7
- end
data/spec/dummy/dummy.rb DELETED
@@ -1,8 +0,0 @@
1
- module Dummy
2
- extend Vertebrae::Base
3
- class << self
4
- def new(options = {}, &block)
5
- Dummy::Client.new(options, &block)
6
- end
7
- end
8
- end
data/spec/logger_spec.rb DELETED
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe 'logging' do
6
- it "should have a logger" do
7
- expect(Dummy).to respond_to(:logger)
8
- end
9
-
10
- it "should be able to log debug methods" do
11
- expect(Dummy.logger).to respond_to(:debug)
12
- end
13
-
14
- it "should be settable" do
15
- expect(Dummy).to respond_to(:logger=)
16
- log = double
17
- Dummy.logger = log
18
- expect(Dummy.logger).to eq(log)
19
- end
20
- end
data/spec/request_spec.rb DELETED
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Vertebrae::Request do
6
- let(:vb) { Vertebrae::API.new }
7
- let(:path) { 'actionkit.api/rest/v1/action' }
8
- let(:params) { {} }
9
- let(:options) { {} }
10
-
11
- it "knows how to make get request" do
12
- expect(vb).to receive(:request).with(:get, path, params, options)
13
- vb.get_request path, params, options
14
- end
15
-
16
- it "knows how to make patch request" do
17
- expect(vb).to receive(:request).with(:patch, path, params, options)
18
- vb.patch_request path, params, options
19
- end
20
-
21
- it "knows how to make post request" do
22
- expect(vb).to receive(:request).with(:post, path, params, options)
23
- vb.post_request path, params, options
24
- end
25
-
26
- it "knows how to make put request" do
27
- expect(vb).to receive(:request).with(:put, path, params, options)
28
- vb.put_request path, params, options
29
- end
30
-
31
- it "knows how to make delete request" do
32
- vb.should_receive(:request).with(:delete, path, params, options)
33
- vb.delete_request path, params, options
34
- end
35
-
36
- describe 'it should result in an appropriately configured connection object when it comes time to run transactions' do
37
- before(:each) do
38
- logger = double
39
- logger.stub(:debug).and_return(true)
40
- allow(Vertebrae::Base).to receive(:logger).and_return(logger)
41
- allow_any_instance_of(Vertebrae::API).to receive(:default_options).and_return({host: 'test.com'})
42
- end
43
-
44
- context 'with an empty hash' do
45
- let(:options) { {} }
46
- it 'should make the request to the default host' do
47
- stub_request(:get, 'https://test.com/path')
48
- vb.request(:get, '/path', {}, options)
49
- end
50
- end
51
-
52
- context 'with a different host' do
53
- let(:options) { {host: 'test2.com'} }
54
- it 'should make the request to the default host' do
55
- stub_request(:get, 'https://test2.com/path')
56
- vb.request(:get, '/path', {}, options)
57
- end
58
- end
59
-
60
- context 'with host specified at client initiation time' do
61
- let(:options) { {} }
62
-
63
- let(:vb) { Vertebrae::API.new host: 'test3.com' }
64
-
65
- it 'should make the request to the default host' do
66
- stub_request(:get, 'https://test3.com/path')
67
- vb.request(:get, '/path', {}, options)
68
- end
69
-
70
- context 'with a different host' do
71
- let(:options) { {host: 'test2.com'} }
72
- it 'should make the request to the default host' do
73
- stub_request(:get, 'https://test2.com/path')
74
- vb.request(:get, '/path', {}, options)
75
- end
76
- end
77
- end
78
-
79
- context 'with basic auth' do
80
- let(:options) { {} }
81
- let(:vb) { Vertebrae::API.new username: 'user', password: 'pass' }
82
-
83
- it 'should make requests with basic auth' do
84
- stub_request(:get, 'https://test3.com/path').with(basic_auth: ['user', 'pass'])
85
- vb.request(:get, '/path', {}, {host: 'test3.com'})
86
- end
87
- end
88
- end
89
- end
data/spec/spec_helper.rb DELETED
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- $LOAD_PATH.unshift(File.dirname(__FILE__))
5
- require 'rspec'
6
- require 'vertebrae'
7
- require 'dummy/dummy'
8
- require 'dummy/client'
9
- require 'webmock/rspec'
10
-
11
- require 'rspec/its'
12
-
13
- # Requires supporting files with custom matchers and macros, etc,
14
- # in ./support/ and its subdirectories.
15
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}
16
-
17
- RSpec.configure do |config|
18
- config.mock_with :rspec do |mocks|
19
- mocks.syntax = [:should, :expect]
20
- end
21
-
22
- config.expect_with :rspec do |c|
23
- c.syntax = [:should, :expect]
24
- end
25
- end
26
-
27
-
28
- def reset_authentication_for(object)
29
- %w[username password].each do |item|
30
- Vertebrae::Base.send("#{item}=", nil)
31
- object.send("#{item}=", nil)
32
- end
33
- end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes