From 2eba4bf388684a143c2d0c07b9903cec52ff4704 Mon Sep 17 00:00:00 2001 From: Joel Courtney Date: Thu, 18 Aug 2016 14:48:04 +1000 Subject: [PATCH 1/7] Updates to add Hyperclient::Resource#to_h, Hyperclient::Resource#to_hash and Hyperclient::Collection#to_h tests; bugfix Hyperclient::Resource#to_h --- lib/hyperclient/resource.rb | 3 ++- test/hyperclient/collection_test.rb | 6 ++++++ test/hyperclient/resource_test.rb | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/hyperclient/resource.rb b/lib/hyperclient/resource.rb index 171b0ae..53c41fd 100644 --- a/lib/hyperclient/resource.rb +++ b/lib/hyperclient/resource.rb @@ -84,9 +84,10 @@ def _self_link def method_missing(method, *args, &block) if args.any? && args.first.is_a?(Hash) _links.send(method, [], &block)._expand(*args) - elsif !Array.method_defined?(method) + else [:_attributes, :_embedded, :_links].each do |target| target = send(target) + puts target.inspect return target.send(method, *args, &block) if target.respond_to?(method.to_s) end super diff --git a/test/hyperclient/collection_test.rb b/test/hyperclient/collection_test.rb index f104367..714c55d 100644 --- a/test/hyperclient/collection_test.rb +++ b/test/hyperclient/collection_test.rb @@ -41,6 +41,12 @@ module Hyperclient end end + describe '#to_h' do + it 'returns the wrapped collection as a hash' do + 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 diff --git a/test/hyperclient/resource_test.rb b/test/hyperclient/resource_test.rb index ef4d5c5..1a46892 100644 --- a/test/hyperclient/resource_test.rb +++ b/test/hyperclient/resource_test.rb @@ -102,6 +102,18 @@ module Hyperclient resource['foo'].must_equal 'bar' end + describe '#to_h' do + it 'returns the resource attributes as a hash' do + resource.to_hash.must_be_kind_of Hash + end + end + + describe '#to_hash' do + it 'returns the resource attributes as a hash' do + resource.to_hash.must_be_kind_of Hash + end + end + describe '#fetch' do it 'returns the value for keys that exist' do resource._attributes.expects(:foo).returns('bar') From 8d9f76560f822e24b373c5d6bfadf2f27fe90261 Mon Sep 17 00:00:00 2001 From: Joel Courtney Date: Thu, 18 Aug 2016 14:49:44 +1000 Subject: [PATCH 2/7] fixed test --- test/hyperclient/resource_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hyperclient/resource_test.rb b/test/hyperclient/resource_test.rb index 1a46892..fa420d3 100644 --- a/test/hyperclient/resource_test.rb +++ b/test/hyperclient/resource_test.rb @@ -110,7 +110,7 @@ module Hyperclient describe '#to_hash' do it 'returns the resource attributes as a hash' do - resource.to_hash.must_be_kind_of Hash + resource.to_h.must_be_kind_of Hash end end From 966f0326c9550f3e487c1a760f0c53ad97b8fb5b Mon Sep 17 00:00:00 2001 From: Joel Courtney Date: Thu, 18 Aug 2016 14:50:38 +1000 Subject: [PATCH 3/7] Corrected test vs. comment --- test/hyperclient/resource_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/hyperclient/resource_test.rb b/test/hyperclient/resource_test.rb index fa420d3..80bcc08 100644 --- a/test/hyperclient/resource_test.rb +++ b/test/hyperclient/resource_test.rb @@ -104,13 +104,13 @@ module Hyperclient describe '#to_h' do it 'returns the resource attributes as a hash' do - resource.to_hash.must_be_kind_of Hash + resource.to_h.must_be_kind_of Hash end end describe '#to_hash' do it 'returns the resource attributes as a hash' do - resource.to_h.must_be_kind_of Hash + resource.to_hash.must_be_kind_of Hash end end From 680e5c6d0a751be728225c8b3f499e146e28c26d Mon Sep 17 00:00:00 2001 From: Joel Courtney Date: Thu, 18 Aug 2016 14:51:14 +1000 Subject: [PATCH 4/7] Corrected collection_test --- test/hyperclient/collection_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hyperclient/collection_test.rb b/test/hyperclient/collection_test.rb index 714c55d..8b125b0 100644 --- a/test/hyperclient/collection_test.rb +++ b/test/hyperclient/collection_test.rb @@ -43,7 +43,7 @@ module Hyperclient describe '#to_h' do it 'returns the wrapped collection as a hash' do - collection.to_hash.must_be_kind_of Hash + collection.to_h.must_be_kind_of Hash end end From 53d3f61f0bf392723a67e9f19062fdb508ccd972 Mon Sep 17 00:00:00 2001 From: Joel Courtney Date: Fri, 19 Aug 2016 08:37:28 +1000 Subject: [PATCH 5/7] Removed stray puts; Updated CHANGELOG.md --- CHANGELOG.md | 2 +- lib/hyperclient/resource.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dbbd46..0915ce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ### 0.8.2 (Next) -Your contribution here. +* [#104](https://github.com/codegram/hyperclient/pull/104): fix #to_h and #to_hash on Hyperclient::Resource - [@jufemaiz](https://github.com/jufemaiz) ### 0.8.1 (March 15, 2016) diff --git a/lib/hyperclient/resource.rb b/lib/hyperclient/resource.rb index 53c41fd..9990964 100644 --- a/lib/hyperclient/resource.rb +++ b/lib/hyperclient/resource.rb @@ -87,7 +87,6 @@ def method_missing(method, *args, &block) else [:_attributes, :_embedded, :_links].each do |target| target = send(target) - puts target.inspect return target.send(method, *args, &block) if target.respond_to?(method.to_s) end super From 62f0adc5d369a2b08d2b2d109863fb204358df6b Mon Sep 17 00:00:00 2001 From: Joel Courtney Date: Mon, 22 Aug 2016 10:59:19 +1000 Subject: [PATCH 6/7] Updated changelog --- CHANGELOG.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e954915..5c17ccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,9 @@ ### 0.8.2 (Next) -<<<<<<< HEAD -* [#104](https://github.com/codegram/hyperclient/pull/104): fix #to_h and #to_hash on Hyperclient::Resource - [@jufemaiz](https://github.com/jufemaiz) -======= This version is no longer tested with Ruby < 2.2. * [#105](https://github.com/codegram/hyperclient/pull/105): Added Danger, PR linter - [@dblock](https://github.com/dblock). -* Your contribution here. ->>>>>>> d448da40f8a3a90c271b7c8db40a437597585fe1 +* [#104](https://github.com/codegram/hyperclient/pull/104): fix #to_h and #to_hash on Hyperclient::Resource - [@jufemaiz](https://github.com/jufemaiz) ### 0.8.1 (March 15, 2016) From fc296f8cd48acb6e207547ff2d733ed113c2a50e Mon Sep 17 00:00:00 2001 From: Joel Courtney Date: Thu, 31 Jan 2019 17:25:44 +1100 Subject: [PATCH 7/7] Update .travis.yml --- .travis.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a283a1..369fbb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,25 @@ sudo: false matrix: include: + - rvm: 2.6.1 + - rvm: 2.6.0 + - rvm: 2.5.3 + - rvm: 2.5.2 + - rvm: 2.5.1 + - rvm: 2.5.0 + - rvm: 2.4.4 + - rvm: 2.4.3 + - rvm: 2.4.2 - rvm: 2.4.1 - rvm: 2.4.1 script: - bundle exec danger + - rvm: 2.3.6 + - rvm: 2.3.5 + - rvm: 2.3.4 + - rvm: 2.2.7 - rvm: jruby-9.1.12.0 - rvm: jruby-head - - rvm: 2.2.7 - - rvm: 2.3.4 - rvm: rbx-2 - rvm: ruby-head allow_failures: