Skip to content

Instantly share code, notes, and snippets.

@plexus
Created April 24, 2015 13:12
Show Gist options
  • Save plexus/f3db5b609cf02663fd06 to your computer and use it in GitHub Desktop.
Save plexus/f3db5b609cf02663fd06 to your computer and use it in GitHub Desktop.
describe Ticketsolve::API::Mappers::ShowMapper do
include_context 'with a single show and event'
include_context 'yaks context'
let(:mapper) { described_class.new(yaks_context) }
subject(:resource) { mapper.call(show) }
context 'show with no events' do
it 'should map attributes' do
expect(resource).to match_attributes(
id: 7,
name: 'A Show',
price_description: '',
dates: [],
description: 'The best ever',
sales_disabled: true,
sales_disabled_message: nil
)
end
it 'should serialize the the show - links' do
expect(resource).to match_links(
[
{rel: :self, uri: "/api/shows/7"},
{rel: :profile, uri: 'http://api.ticketsolve.com/profile/show'},
{rel: 'http://api.ticketsolve.com/rel/events', uri: "/api/shows/7/events"}
]
)
end
it 'should serialize forms' do
expect(resource).to match_forms(
promotion_code: {
action: "/api/cart/promotion_code",
method: 'POST',
title: 'promotion_code.title',
media_type: 'application/x-www-form-urlencoded',
fields: [{name: :code, type: :text, label: 'promotion_code.label', value: ''}]
}
)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment