-
-
Notifications
You must be signed in to change notification settings - Fork 14
Delegate to Roar's represent w/o options argument #18
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,7 @@ rvm: | |
| - 1.9.3 | ||
| - jruby-19mode | ||
| - rbx-2.2.10 | ||
|
|
||
| matrix: | ||
| allow_failures: | ||
| - rvm: rbx-2.2.10 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,15 +15,30 @@ def app | |
| end | ||
|
|
||
| context 'decorator' do | ||
| before do | ||
| subject.get('/user/:id') do | ||
| present User.new(name: 'Lonestar', id: params[:id]), with: UserRepresenter | ||
| context 'with a single resource' do | ||
| before do | ||
| subject.get('/user/:id') do | ||
| present User.new(name: 'Lonestar', id: params[:id]), with: UserRepresenter | ||
| end | ||
| end | ||
|
|
||
| it 'returns a single hypermedia representation' do | ||
| get '/user/666' | ||
| expect(last_response.body).to eq '{"name":"Lonestar","id":"666","links":[{"rel":"self","href":"/user/666"}]}' | ||
| end | ||
| end | ||
|
|
||
| it 'returns a hypermedia representation' do | ||
| get '/user/666' | ||
| expect(last_response.body).to eq '{"name":"Lonestar","id":"666","links":[{"rel":"self","href":"/user/666"}]}' | ||
| context 'with an array of resources' do | ||
| before do | ||
| subject.get('/users') do | ||
| present [User.new(name: 'Texassee', id: 1), User.new(name: 'Lonestar', id: 2)], with: UserRepresenter | ||
| end | ||
| end | ||
|
|
||
| it 'returns an array of hypermedia representations' do | ||
| get 'users' | ||
| expect(last_response.body).to eq '[{"name":"Texassee","id":1,"links":[{"rel":"self","href":"/user/1"}]},{"name":"Lonestar","id":2,"links":[{"rel":"self","href":"/user/2"}]}]' | ||
|
||
| end | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,15 +15,43 @@ def app | |
| end | ||
|
|
||
| context 'using present' do | ||
| before do | ||
| subject.get('/product/:id') do | ||
| present Product.new(title: 'Lonestar', id: params[:id]), with: ProductRepresenter | ||
| context 'with a single resource' do | ||
| before do | ||
| subject.get('/product/:id') do | ||
| present Product.new(title: 'Lonestar', id: params[:id]), with: ProductRepresenter | ||
| end | ||
| end | ||
|
|
||
| it 'returns a hypermedia representation' do | ||
| get '/product/666' | ||
| expect(last_response.body).to eq '{"title":"Lonestar","id":"666","links":[{"rel":"self","href":"/product/666"}]}' | ||
| end | ||
| end | ||
|
|
||
| context 'with an array of resources' do | ||
| before do | ||
| subject.get('/products') do | ||
| present [Product.new(title: 'Texassee', id: 1), Product.new(title: 'Lonestar', id: 2)], with: ProductRepresenter | ||
| end | ||
| end | ||
|
|
||
| it 'returns an array of hypermedia representations' do | ||
| get 'products' | ||
| expect(last_response.body).to eq '[{"title":"Texassee","id":1,"links":[{"rel":"self","href":"/product/1"}]},{"title":"Lonestar","id":2,"links":[{"rel":"self","href":"/product/2"}]}]' | ||
| end | ||
| end | ||
|
|
||
| it 'returns a hypermedia representation' do | ||
| get '/product/666' | ||
| expect(last_response.body).to eq '{"title":"Lonestar","id":"666","links":[{"rel":"self","href":"http://example.org/product/666"}]}' | ||
| context 'with an array of resources as a resource' do | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dblock - failing spec here
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I'll try to spend some time on this. |
||
| before do | ||
| subject.get('/products') do | ||
| present [Product.new(title: 'Texassee', id: 1), Product.new(title: 'Lonestar', id: 2)], with: ProductsRepresenter | ||
| end | ||
| end | ||
|
|
||
| it 'returns an array of hypermedia representations' do | ||
| get 'products' | ||
| expect(last_response.body).to eq '[{"title":"Texassee","id":1,"links":[{"rel":"self","href":"/product/1"}]},{"title":"Lonestar","id":2,"links":[{"rel":"self","href":"/product/2"}]}]' | ||
| end | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| require 'roar/json/hal' | ||
| require 'support/product_representer' | ||
|
|
||
| module ProductsRepresenter | ||
| include Roar::JSON::HAL | ||
| include Roar::Hypermedia | ||
| include Grape::Roar::Representer | ||
|
|
||
| collection :entries, extend: ProductRepresenter, as: :products, embedded: true | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this one to
rbx-2, that means "the latest rbx 2", otherwise we constantly chase our tails.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change both references or just this
allow_failuresreference? Sorry, I'm not very familiar with travis configuration.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both. The first one says that we use
rbx-2and the second that we don't care ;)