Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-05-10 19:37:12 -0400 using RuboCop version 0.81.0.
# on 2020-05-14 17:08:39 -0400 using RuboCop version 0.81.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -59,7 +59,7 @@ Style/MethodMissingSuper:
Exclude:
- 'lib/hyperclient/collection.rb'

# Offense count: 91
# Offense count: 94
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Expand Down
15 changes: 7 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ sudo: false
matrix:
include:
- rvm: 2.6.6
- rvm: 2.5.5
- rvm: 2.4.6
- rvm: 2.4.6
env: FARADAY_VERSION=0.9.0
- rvm: 2.6.6
env: FARADAY_VERSION=0.17.0
- rvm: 2.6.6
env: FARADAY_VERSION="~> 1.0"
- rvm: 2.6.6
script:
- bundle exec danger
- rvm: 2.3.8
- rvm: jruby-9.2.7.0
- rvm: jruby-head
- rvm: 2.3.8
- rvm: ruby-head
allow_failures:
- rvm: ruby-head
- rvm: jruby-head

before_install:
- gem update --system
- gem install bundler

bundler_args: --without development
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### 0.9.4 (Next)

* [#163](https://github.com/codegram/hyperclient/pull/163): Test against Faraday 0.9, 0.17 and 1.0+ - [@dblock](https://github.com/dblock).
* Your contribution here.

### 0.9.3 (2020/05/14)
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ git_source(:github) { |repo| "https://github.com/#{repo['/'] ? repo : "#{repo}/#

source 'https://rubygems.org'

gem 'faraday', ENV['FARADAY_VERSION'] if ENV.key?('FARADAY_VERSION')

gemspec

group :development do
Expand Down
2 changes: 1 addition & 1 deletion test/faraday/connection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Faraday
it 'inserts the DigestAuth middleware at the top' do
connection.digest_auth('user', 'password')

connection.builder.handlers.first.klass.must_equal Faraday::Request::DigestAuth
_(connection.builder.handlers.first.klass).must_equal Faraday::Request::DigestAuth
end

it 'passes the user and password to the middleware' do
Expand Down
18 changes: 9 additions & 9 deletions test/hyperclient/attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ module Hyperclient
end

it 'does not set _links as an attribute' do
attributes.wont_respond_to :_links
_(attributes).wont_respond_to :_links
end

it 'does not set _embedded as an attribute' do
attributes.wont_respond_to :_embedded
_(attributes).wont_respond_to :_embedded
end

it 'sets normal attributes' do
attributes.must_respond_to :permitted
attributes.permitted.must_equal true
_(attributes).must_respond_to :permitted
_(attributes.permitted).must_equal true

attributes.must_respond_to :title
attributes.title.must_equal 'Real World ASP.NET MVC3'
_(attributes).must_respond_to :title
_(attributes.title).must_equal 'Real World ASP.NET MVC3'
end

# Underscores should be allowed per http://tools.ietf.org/html/draft-kelly-json-hal#appendix-B.4
it 'sets _hidden_attribute as an attribute' do
attributes.must_respond_to :_hidden_attribute
attributes._hidden_attribute.must_equal 'useful value'
_(attributes).must_respond_to :_hidden_attribute
_(attributes._hidden_attribute).must_equal 'useful value'
end

it 'is a collection' do
Attributes.ancestors.must_include Collection
_(Attributes.ancestors).must_include Collection
end
end
end
30 changes: 15 additions & 15 deletions test/hyperclient/collection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,61 @@ module Hyperclient
end

it 'exposes the collection as methods' do
collection.title.must_equal 'Real World ASP.NET MVC3'
collection.description.must_match(/production/)
collection.permitted.must_equal true
_(collection.title).must_equal 'Real World ASP.NET MVC3'
_(collection.description).must_match(/production/)
_(collection.permitted).must_equal true
end

it 'exposes collection as a hash' do
collection['title'].must_equal 'Real World ASP.NET MVC3'
collection['description'].must_match(/production/)
collection['permitted'].must_equal true
_(collection['title']).must_equal 'Real World ASP.NET MVC3'
_(collection['description']).must_match(/production/)
_(collection['permitted']).must_equal true
end

it 'correctly responds to methods' do
collection.must_respond_to :title
_(collection).must_respond_to :title
end

it 'acts as enumerable' do
names = collection.map do |name, _value|
name
end

names.must_equal %w[_links title description permitted _hidden_attribute _embedded]
_(names).must_equal %w[_links title description permitted _hidden_attribute _embedded]
end

describe '#to_hash' do
it 'returns the wrapped collection as a hash' do
collection.to_hash.must_be_kind_of Hash
_(collection.to_hash).must_be_kind_of Hash
end
end

describe 'include?' do
it 'returns true for keys that exist' do
collection.include?('_links').must_equal true
_(collection.include?('_links')).must_equal true
end

it 'returns false for missing keys' do
collection.include?('missing key').must_equal false
_(collection.include?('missing key')).must_equal false
end
end

describe '#fetch' do
it 'returns the value for keys that exist' do
collection.fetch('title').must_equal 'Real World ASP.NET MVC3'
_(collection.fetch('title')).must_equal 'Real World ASP.NET MVC3'
end

it 'raises an error for missing keys' do
proc { collection.fetch('missing key') }.must_raise KeyError
_(proc { collection.fetch('missing key') }).must_raise KeyError
end

describe 'with a default value' do
it 'returns the value for keys that exist' do
collection.fetch('title', 'default').must_equal 'Real World ASP.NET MVC3'
_(collection.fetch('title', 'default')).must_equal 'Real World ASP.NET MVC3'
end

it 'returns the default value for missing keys' do
collection.fetch('missing key', 'default').must_equal 'default'
_(collection.fetch('missing key', 'default')).must_equal 'default'
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/hyperclient/curie_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ module Hyperclient
it 'returns true if the curie is templated' do
curie = Curie.new({ 'name' => 'image', 'templated' => true }, entry_point)

curie.templated?.must_equal true
_(curie.templated?).must_equal true
end

it 'returns false if the curie is not templated' do
curie = Curie.new({ 'name' => 'image' }, entry_point)

curie.templated?.must_equal false
_(curie.templated?).must_equal false
end
end

Expand All @@ -26,12 +26,12 @@ module Hyperclient
end
describe '_name' do
it 'returns curie name' do
curie.name.must_equal 'image'
_(curie.name).must_equal 'image'
end
end
describe 'expand' do
it 'expands link' do
curie.expand('thumbnail').must_equal '/images/thumbnail'
_(curie.expand('thumbnail')).must_equal '/images/thumbnail'
end
end
end
Expand Down
Loading