Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support #to_h and #to_hash on the Hyperclient::Resource #104

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
15 changes: 13 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### 0.9.1 (Next)

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).
* [#104](https://github.com/codegram/hyperclient/pull/104): fix #to_h and #to_hash on Hyperclient::Resource - [@jufemaiz](https://github.com/jufemaiz)
* Your contribution here.

### 0.9.0 (January 10, 2018)
Expand Down
6 changes: 6 additions & 0 deletions test/hyperclient/collection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ module Hyperclient
end
end

describe '#to_h' do
it 'returns the wrapped collection as a hash' do
collection.to_h.must_be_kind_of Hash
end
end

describe 'include?' do
it 'returns true for keys that exist' do
collection.include?('_links').must_equal true
Expand Down
12 changes: 12 additions & 0 deletions test/hyperclient/resource_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ module Hyperclient
resource['foo'].must_equal 'bar'
end

describe '#to_h' do
it 'returns the resource attributes as a hash' do
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_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')
Expand Down