vertebrae 0.7.0 → 0.8.0

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: 03be6678c9ce04755fe5c66703664b7faaeab9a8a17f80ee656c7e3d462e9c08
4
+ data.tar.gz: 729b2386d9e34cdc5876be23f0057afdc0fe77966332d0ca5b3eeba49712cd1c
5
5
  SHA512:
6
- metadata.gz: 9d42d282cd5c63cedbe256b2eb565309f7dc32864fbf446f6e0335eb8b3e0a66b0b70c5dba93a7070708ca5e37d7a9b2d6766fa9ef3840fd8c4e8eb6cde4dafe
7
- data.tar.gz: a5bc410b164b79d37ce3cf8c0dbf8638d182d26baaa9ca3b14db31579b7b6ab0059045ac4823b25e0335b9e04afc92715fd061a9a52f35c919ce5f9fde7ed7b0
6
+ metadata.gz: 846315913ccbd3e2ce3a844649e6d05fc778ed4d42c4e7a1820bb272cd692c3dda82394eb8728bcab49d7c462075c4c97c22c4e878bf54518a6fa3dd2c141808
7
+ data.tar.gz: 41b1c00b5b8ef6958897ec86fdfc4b3464984d06a053050e9d182a500e11aef84a08b24e6b1052d064c9cf7090fa64ba6c84dfc24d26bfd6f3f2091bbff34a94
@@ -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@v1
10
+ with:
11
+ ruby-version: 3.2
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@v1
20
+ with:
21
+ ruby-version: 3.2
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,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'activesupport', '>= 5.1.4'
4
- gem 'faraday', '> 0.9.2'
4
+ gem 'faraday', '~> 1'
5
5
  gem 'faraday_middleware', '> 0.12.2'
6
6
  gem 'hashie', '> 3.5.7'
7
7
 
@@ -9,9 +9,9 @@ gem 'hashie', '> 3.5.7'
9
9
  # Include everything needed to run rake, tests, features, etc.
10
10
  group :development do
11
11
  gem "rspec"
12
+ gem "rake"
12
13
  gem "bundler"
13
14
  gem "webmock"
14
15
  gem "rspec-its"
15
- gem "juwelier", git: 'https://github.com/flajann2/juwelier.git'
16
16
  gem "rubocop"
17
17
  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,8 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'bundler'
5
+ require 'bundler/gem_tasks'
6
+
5
7
  begin
6
8
  Bundler.setup(:default, :development)
7
9
  rescue Bundler::BundlerError => e
@@ -11,21 +13,6 @@ rescue Bundler::BundlerError => e
11
13
  end
12
14
  require 'rake'
13
15
 
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
16
  require 'rspec/core'
30
17
  require 'rspec/core/rake_task'
31
18
  RSpec::Core::RakeTask.new(:spec) do |spec|
@@ -2,8 +2,8 @@
2
2
 
3
3
  require 'faraday'
4
4
  require 'faraday_middleware'
5
- require 'response/raise_error'
6
- require 'authorization'
5
+ require 'vertebrae/response/raise_error'
6
+ require 'vertebrae/authorization'
7
7
 
8
8
  module Vertebrae
9
9
  class Connection
@@ -44,6 +44,7 @@ module Vertebrae
44
44
  end
45
45
 
46
46
  builder.use Faraday::Response::Logger if ENV['DEBUG']
47
+
47
48
  unless options[:raw]
48
49
  builder.use FaradayMiddleware::Mashify
49
50
  builder.use FaradayMiddleware::ParseJson
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vertebrae
4
+ VERSION = '0.8.0'
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
- require 'railties' if defined? Rails
16
+ require 'vertebrae/railties' if defined? Rails
16
17
 
17
18
  module Vertebrae
18
19
 
19
- end
20
+ end
data/vertebrae.gemspec CHANGED
@@ -1,98 +1,58 @@
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 = "2023-09-28"
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
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ s.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+
55
27
  s.homepage = "http://github.com/controlshift/vertebrae".freeze
56
28
  s.licenses = ["MIT".freeze]
57
- s.rubygems_version = "3.0.8".freeze
58
29
  s.summary = "API Client Infrastructure".freeze
59
30
 
60
31
  if s.respond_to? :specification_version then
61
32
  s.specification_version = 4
33
+ end
62
34
 
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
35
+ if s.respond_to? :add_runtime_dependency then
36
+ s.add_runtime_dependency(%q<activesupport>.freeze, [">= 5.1.4"])
37
+ s.add_runtime_dependency(%q<faraday>.freeze, ["~> 1"])
38
+ s.add_runtime_dependency(%q<faraday_middleware>.freeze, ["> 0.12.2"])
39
+ s.add_runtime_dependency(%q<hashie>.freeze, ["> 3.5.7"])
40
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
41
+ s.add_development_dependency(%q<rake>.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<rubocop>.freeze, [">= 0"])
86
46
  else
87
47
  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"])
48
+ s.add_dependency(%q<faraday>.freeze, ["~> 1"])
49
+ s.add_dependency(%q<faraday_middleware>.freeze, ["> 0.12.2"])
90
50
  s.add_dependency(%q<hashie>.freeze, ["> 3.5.7"])
91
51
  s.add_dependency(%q<rspec>.freeze, [">= 0"])
52
+ s.add_dependency(%q<rake>.freeze, [">= 0"])
92
53
  s.add_dependency(%q<bundler>.freeze, [">= 0"])
93
54
  s.add_dependency(%q<webmock>.freeze, [">= 0"])
94
55
  s.add_dependency(%q<rspec-its>.freeze, [">= 0"])
95
- s.add_dependency(%q<juwelier>.freeze, [">= 0"])
96
56
  s.add_dependency(%q<rubocop>.freeze, [">= 0"])
97
57
  end
98
58
  end
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: 0.8.0
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: 2023-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -28,30 +28,30 @@ 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: '1'
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: '1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faraday_middleware
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.12.2
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.12.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: hashie
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: bundler
84
+ name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: webmock
98
+ name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rspec-its
112
+ name: webmock
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: juwelier
126
+ name: rspec-its
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -157,39 +157,33 @@ 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
- - 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
173
  - 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
174
  - 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
175
+ - lib/vertebrae/api.rb
176
+ - lib/vertebrae/authorization.rb
177
+ - lib/vertebrae/base.rb
178
+ - lib/vertebrae/configuration.rb
179
+ - lib/vertebrae/connection.rb
180
+ - lib/vertebrae/constants.rb
181
+ - lib/vertebrae/model.rb
182
+ - lib/vertebrae/railties.rb
183
+ - lib/vertebrae/request.rb
184
+ - lib/vertebrae/response/raise_error.rb
185
+ - lib/vertebrae/response_error.rb
186
+ - lib/vertebrae/version.rb
193
187
  - vertebrae.gemspec
194
188
  homepage: http://github.com/controlshift/vertebrae
195
189
  licenses:
@@ -210,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
204
  - !ruby/object:Gem::Version
211
205
  version: '0'
212
206
  requirements: []
213
- rubygems_version: 3.0.8
207
+ rubygems_version: 3.4.15
214
208
  signing_key:
215
209
  specification_version: 4
216
210
  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/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.6.2
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