contentful 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. data/.README.md.swp +0 -0
  2. data/.gitignore +2 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +10 -0
  5. data/ChangeLog.md +3 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +193 -0
  9. data/Rakefile +30 -0
  10. data/contentful.gemspec +31 -0
  11. data/do_request.sh +5 -0
  12. data/doc/Contentful.html +131 -0
  13. data/doc/Contentful/AccessDenied.html +158 -0
  14. data/doc/Contentful/Array.html +346 -0
  15. data/doc/Contentful/Asset.html +315 -0
  16. data/doc/Contentful/BadRequest.html +158 -0
  17. data/doc/Contentful/Client.html +1407 -0
  18. data/doc/Contentful/ContentType.html +183 -0
  19. data/doc/Contentful/DynamicEntry.html +333 -0
  20. data/doc/Contentful/Entry.html +198 -0
  21. data/doc/Contentful/Error.html +413 -0
  22. data/doc/Contentful/Field.html +161 -0
  23. data/doc/Contentful/File.html +160 -0
  24. data/doc/Contentful/Link.html +275 -0
  25. data/doc/Contentful/Locale.html +161 -0
  26. data/doc/Contentful/NotFound.html +158 -0
  27. data/doc/Contentful/Request.html +669 -0
  28. data/doc/Contentful/Resource.html +606 -0
  29. data/doc/Contentful/Resource/AssetFields.html +413 -0
  30. data/doc/Contentful/Resource/AssetFields/ClassMethods.html +174 -0
  31. data/doc/Contentful/Resource/ClassMethods.html +271 -0
  32. data/doc/Contentful/Resource/Fields.html +398 -0
  33. data/doc/Contentful/Resource/Fields/ClassMethods.html +187 -0
  34. data/doc/Contentful/Resource/SystemProperties.html +444 -0
  35. data/doc/Contentful/Resource/SystemProperties/ClassMethods.html +174 -0
  36. data/doc/Contentful/ResourceBuilder.html +1400 -0
  37. data/doc/Contentful/Response.html +546 -0
  38. data/doc/Contentful/ServerError.html +158 -0
  39. data/doc/Contentful/Space.html +183 -0
  40. data/doc/Contentful/Support.html +198 -0
  41. data/doc/Contentful/Unauthorized.html +158 -0
  42. data/doc/Contentful/UnparsableJson.html +158 -0
  43. data/doc/Contentful/UnparsableResource.html +158 -0
  44. data/doc/_index.html +410 -0
  45. data/doc/class_list.html +54 -0
  46. data/doc/css/common.css +1 -0
  47. data/doc/css/full_list.css +57 -0
  48. data/doc/css/style.css +338 -0
  49. data/doc/file.README.html +214 -0
  50. data/doc/file_list.html +56 -0
  51. data/doc/frames.html +26 -0
  52. data/doc/index.html +214 -0
  53. data/doc/js/app.js +219 -0
  54. data/doc/js/full_list.js +178 -0
  55. data/doc/js/jquery.js +4 -0
  56. data/doc/method_list.html +533 -0
  57. data/doc/top-level-namespace.html +112 -0
  58. data/examples/custom_classes.rb +43 -0
  59. data/examples/dynamic_entries.rb +126 -0
  60. data/examples/example_queries.rb +27 -0
  61. data/examples/raise_errors.rb +22 -0
  62. data/examples/raw_mode.rb +15 -0
  63. data/examples/resource_mapping.rb +33 -0
  64. data/lib/contentful.rb +3 -0
  65. data/lib/contentful/array.rb +47 -0
  66. data/lib/contentful/asset.rb +34 -0
  67. data/lib/contentful/client.rb +193 -0
  68. data/lib/contentful/content_type.rb +16 -0
  69. data/lib/contentful/dynamic_entry.rb +54 -0
  70. data/lib/contentful/entry.rb +12 -0
  71. data/lib/contentful/error.rb +52 -0
  72. data/lib/contentful/field.rb +16 -0
  73. data/lib/contentful/file.rb +13 -0
  74. data/lib/contentful/link.rb +20 -0
  75. data/lib/contentful/locale.rb +12 -0
  76. data/lib/contentful/location.rb +12 -0
  77. data/lib/contentful/request.rb +37 -0
  78. data/lib/contentful/resource.rb +146 -0
  79. data/lib/contentful/resource/asset_fields.rb +50 -0
  80. data/lib/contentful/resource/fields.rb +39 -0
  81. data/lib/contentful/resource/system_properties.rb +48 -0
  82. data/lib/contentful/resource_builder.rb +197 -0
  83. data/lib/contentful/response.rb +64 -0
  84. data/lib/contentful/space.rb +14 -0
  85. data/lib/contentful/support.rb +18 -0
  86. data/lib/contentful/version.rb +3 -0
  87. data/spec/array_spec.rb +69 -0
  88. data/spec/asset_spec.rb +62 -0
  89. data/spec/auto_includes_spec.rb +12 -0
  90. data/spec/client_class_spec.rb +59 -0
  91. data/spec/client_configuration_spec.rb +197 -0
  92. data/spec/coercions_spec.rb +10 -0
  93. data/spec/content_type_spec.rb +44 -0
  94. data/spec/dynamic_entry_spec.rb +34 -0
  95. data/spec/entry_spec.rb +53 -0
  96. data/spec/error_class_spec.rb +60 -0
  97. data/spec/error_requests_spec.rb +32 -0
  98. data/spec/field_spec.rb +36 -0
  99. data/spec/file_spec.rb +28 -0
  100. data/spec/fixtures/json_responses/content_type.json +83 -0
  101. data/spec/fixtures/json_responses/not_found.json +13 -0
  102. data/spec/fixtures/json_responses/nyancat.json +48 -0
  103. data/spec/fixtures/json_responses/unparsable.json +13 -0
  104. data/spec/fixtures/vcr_cassettes/array.yml +288 -0
  105. data/spec/fixtures/vcr_cassettes/array_page_1.yml +106 -0
  106. data/spec/fixtures/vcr_cassettes/array_page_2.yml +73 -0
  107. data/spec/fixtures/vcr_cassettes/asset.yml +96 -0
  108. data/spec/fixtures/vcr_cassettes/bad_request.yml +76 -0
  109. data/spec/fixtures/vcr_cassettes/content_type.yml +147 -0
  110. data/spec/fixtures/vcr_cassettes/entries.yml +561 -0
  111. data/spec/fixtures/vcr_cassettes/entry.yml +112 -0
  112. data/spec/fixtures/vcr_cassettes/entry_cache.yml +288 -0
  113. data/spec/fixtures/vcr_cassettes/field.yml +147 -0
  114. data/spec/fixtures/vcr_cassettes/locale.yml +81 -0
  115. data/spec/fixtures/vcr_cassettes/location.yml +305 -0
  116. data/spec/fixtures/vcr_cassettes/not_found.yml +71 -0
  117. data/spec/fixtures/vcr_cassettes/nyancat.yml +112 -0
  118. data/spec/fixtures/vcr_cassettes/nyancat_include.yml +112 -0
  119. data/spec/fixtures/vcr_cassettes/reloaded_entry.yml +112 -0
  120. data/spec/fixtures/vcr_cassettes/space.yml +81 -0
  121. data/spec/fixtures/vcr_cassettes/unauthorized.yml +64 -0
  122. data/spec/link_spec.rb +40 -0
  123. data/spec/locale_spec.rb +20 -0
  124. data/spec/location_spec.rb +30 -0
  125. data/spec/request_spec.rb +48 -0
  126. data/spec/resource_spec.rb +52 -0
  127. data/spec/response_spec.rb +50 -0
  128. data/spec/space_spec.rb +36 -0
  129. data/spec/spec_helper.rb +6 -0
  130. data/spec/support/client.rb +6 -0
  131. data/spec/support/json_responses.rb +11 -0
  132. data/spec/support/vcr.rb +16 -0
  133. metadata +374 -0
@@ -0,0 +1,64 @@
1
+ require_relative 'error'
2
+ require 'multi_json'
3
+
4
+ module Contentful
5
+ # An object representing an answer by the contentful service. It is later used
6
+ # to build a Resource, which is done by the ResourceBuilder.
7
+ #
8
+ # The Response parses the http response (as returned by the underlying http library) to
9
+ # a JSON object. Responses can be asked the following methods:
10
+ # - #raw (raw HTTP response by the HTTP library)
11
+ # - #object (the parsed JSON object)
12
+ # - #request (the request the response is refering to)
13
+ #
14
+ # It also sets a #status which can be one of:
15
+ # - :ok (seems to be a valid resource object)
16
+ # - :contentful_error (valid error object)
17
+ # - :not_contentful (valid json, but missing the contentful's sys property)
18
+ # - :unparsable_json (invalid json)
19
+ #
20
+ # Error Repsonses also contain a:
21
+ # - :error_message
22
+ class Response
23
+ attr_reader :raw, :object, :status, :error_message, :request
24
+
25
+ def initialize(raw, request = nil)
26
+ @raw = raw
27
+ @request = request
28
+ @status = :ok
29
+
30
+ if parse_json!
31
+ parse_contentful_error!
32
+ end
33
+ end
34
+
35
+
36
+ private
37
+
38
+ def parse_json!
39
+ @object = MultiJson.load(raw.to_s)
40
+ true
41
+ rescue MultiJson::LoadError => e
42
+ @status = :unparsable_json
43
+ @error_message = e.message
44
+ @object = e
45
+ false
46
+ end
47
+
48
+ def parse_contentful_error!
49
+ if @object && @object["sys"]
50
+ if @object["sys"]["type"] == 'Error'
51
+ @status = :contentful_error
52
+ @error_message = object['message']
53
+ true
54
+ else
55
+ false
56
+ end
57
+ else
58
+ @status = :not_contentful
59
+ @error_message = "No contentful system properties found in object"
60
+ end
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'resource'
2
+ require_relative 'locale'
3
+
4
+ module Contentful
5
+ # Resource class for Space.
6
+ # https://www.contentful.com/developers/documentation/content-delivery-api/#spaces
7
+ class Space
8
+ include Contentful::Resource
9
+ include Contentful::Resource::SystemProperties
10
+
11
+ property :name, :string
12
+ property :locales, Locale
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ module Contentful
2
+ # Utility methods used by the contentful gem
3
+ module Support
4
+ class << self
5
+ # Transforms CamelCase into snake_case (taken from zucker)
6
+ def snakify(object)
7
+ object.to_s.gsub(/(?<!^)[A-Z]/) do "_#$&" end.downcase
8
+ end
9
+
10
+ # Transforms each hash key into a symbol (like in AS)
11
+ def symbolize_keys(h)
12
+ result = {}
13
+ h.each_key{ |key| result[(key.to_sym rescue key)] = h[key] }
14
+ result
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module Contentful
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ describe Contentful::Array do
4
+ let(:array){ vcr('array'){ create_client.content_types } }
5
+
6
+ describe 'SystemProperties' do
7
+ it 'has a #sys getter returning a hash with symbol keys' do
8
+ expect( array.sys ).to be_a Hash
9
+ expect( array.sys.keys.sample ).to be_a Symbol
10
+ end
11
+
12
+ it 'has #type' do
13
+ expect( array.type ).to eq "Array"
14
+ end
15
+ end
16
+
17
+ describe 'Properties' do
18
+ it 'has a #properties getter returning a hash with symbol keys' do
19
+ expect( array.properties ).to be_a Hash
20
+ expect( array.properties.keys.sample ).to be_a Symbol
21
+ end
22
+
23
+ it 'has #total' do
24
+ expect( array.total ).to eq 4
25
+ end
26
+
27
+ it 'has #skip' do
28
+ expect( array.skip ).to eq 0
29
+ end
30
+
31
+ it 'has #limit' do
32
+ expect( array.limit ).to eq 100
33
+ end
34
+
35
+ it 'has #items which contain resources' do
36
+ expect( array.items ).to be_a Array
37
+ expect( array.items.sample ).to be_a Contentful::Resource
38
+ end
39
+ end
40
+
41
+ describe '#each' do
42
+ it 'is an Enumerator' do
43
+ expect( array.each ).to be_a Enumerator
44
+ end
45
+
46
+ it 'iterates over items' do
47
+ expect( array.each.to_a ).to eq array.items
48
+ end
49
+
50
+ it 'includes Enumerable' do
51
+ expect( array.map{ |r| r.type } ).to eq array.items.map{ |r| r.type }
52
+ end
53
+ end
54
+
55
+ describe '#next_page' do
56
+ it 'requests more of the same content from the server, using its limit and skip values' do
57
+ array_page_1 = vcr('array_page_1'){ create_client.content_types(skip: 3, limit: 2) }
58
+ array_page_2 = vcr('array_page_2'){ array_page_1.next_page }
59
+
60
+ expect( array_page_2 ).to be_a Contentful::Array
61
+ expect( array_page_2.limit ).to eq 2
62
+ expect( array_page_2.skip ).to eq 5
63
+ end
64
+
65
+ it 'will return false if #request not available' do
66
+ expect( Contentful::Array.new({}).reload ).to be_false
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe Contentful::Asset do
4
+ let(:asset){ vcr('asset'){ create_client.asset('nyancat') } }
5
+
6
+ describe 'SystemProperties' do
7
+ it 'has a #sys getter returning a hash with symbol keys' do
8
+ expect( asset.sys ).to be_a Hash
9
+ expect( asset.sys.keys.sample ).to be_a Symbol
10
+ end
11
+
12
+ it 'has #id' do
13
+ expect( asset.id ).to eq "nyancat"
14
+ end
15
+
16
+ it 'has #type' do
17
+ expect( asset.type ).to eq "Asset"
18
+ end
19
+
20
+ it 'has #space' do
21
+ expect( asset.space ).to be_a Contentful::Link
22
+ end
23
+
24
+ it 'has #created_at' do
25
+ expect( asset.created_at ).to be_a DateTime
26
+ end
27
+
28
+ it 'has #updated_at' do
29
+ expect( asset.updated_at ).to be_a DateTime
30
+ end
31
+
32
+ it 'has #revision' do
33
+ expect( asset.revision ).to eq 1
34
+ end
35
+ end
36
+
37
+ describe 'Fields' do
38
+ it 'has #title' do
39
+ expect( asset.title ).to eq "Nyan Cat"
40
+ end
41
+
42
+ it 'could have #description' do
43
+ expect( asset ).to respond_to :description
44
+ end
45
+
46
+ it 'has #file' do
47
+ expect( asset.file ).to be_a Contentful::File
48
+ end
49
+ end
50
+
51
+ describe '#image_url' do
52
+ it 'returns #url of #file without parameter' do
53
+ expect( asset.image_url ).to eq asset.file.url
54
+ end
55
+
56
+ it 'adds image options if given' do
57
+ url = asset.image_url(width: 100, format: 'jpg', quality: 50)
58
+ expect(url).to include asset.file.url
59
+ expect(url).to include "?w=100&fm=jpg&q=50"
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Auto-include resources' do
4
+ let(:entries){ vcr('entries'){ create_client.entries } } # entries come with asset includes
5
+
6
+ it 'replaces Contentful::Links which are actually included with the resource' do
7
+ asset = entries.items[1].fields[:image]
8
+
9
+ expect( asset ).not_to be_a Contentful::Link
10
+ expect( asset ).to be_a Contentful::Asset
11
+ end
12
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe Contentful::Client do
5
+ describe '#get' do
6
+ let(:client){ create_client }
7
+ let(:request){
8
+ Contentful::Request.new(nil, '/content_types', nil, 'cat')
9
+ }
10
+
11
+
12
+ it 'uses #base_url' do
13
+ stub(client).base_url{ "https://cdn.contentful.com/spaces/cfexampleapi" }
14
+ vcr('content_type'){ client.get(request) }
15
+ expect( client ).to have_received.base_url
16
+ end
17
+
18
+ it 'uses #request_headers' do
19
+ stub(client).request_headers{{
20
+ 'User-Agent' => 'RubyContentfulGem/0.1.0',
21
+ 'Authorization' => 'Bearer b4c0n73n7fu1',
22
+ 'Content-Type' => 'application/vnd.contentful.delivery.v1+json',
23
+ }}
24
+ vcr('content_type'){ client.get(request) }
25
+ expect( client ).to have_received.request_headers
26
+ end
27
+
28
+ it 'uses Request#url' do
29
+ stub(request).url{ "/content_types/cat" }
30
+ vcr('content_type'){ client.get(request) }
31
+ expect( request ).to have_received.url
32
+ end
33
+
34
+ it 'uses Request#query' do
35
+ stub(request).query
36
+ vcr('content_type'){ client.get(request) }
37
+ expect( request ).to have_received.query
38
+ end
39
+
40
+ it 'calls #get_http' do
41
+ stub(client.class).get_http{ raw_fixture('content_type') }
42
+ client.get(request)
43
+ expect( client.class ).to have_received.get_http(client.base_url + request.url, request.query, client.request_headers)
44
+ end
45
+
46
+ describe 'build_resources parameter' do
47
+ it 'returns Contentful::Resource object if second parameter is true [default]' do
48
+ res = vcr('content_type'){ client.get(request) }
49
+ expect( res ).to be_a Contentful::Resource
50
+ end
51
+
52
+ it 'returns a Contentful::Response object if second parameter is not true' do
53
+ res = vcr('content_type'){ client.get(request, false) }
54
+ expect( res ).to be_a Contentful::Response
55
+ end
56
+ end
57
+
58
+ end
59
+ end
@@ -0,0 +1,197 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe 'Client Configuration Options' do
5
+ describe ':space' do
6
+ it 'is required' do
7
+ expect{
8
+ Contentful::Client.new(access_token: 'b4c0n73n7fu1')
9
+ }.to raise_error(ArgumentError)
10
+ end
11
+ end
12
+
13
+ describe ':access_token' do
14
+ it 'is required' do
15
+ expect{
16
+ Contentful::Client.new(space: 'cfexampleapi')
17
+ }.to raise_error(ArgumentError)
18
+ end
19
+ end
20
+
21
+ describe ':secure' do
22
+ it 'will use https [default]' do
23
+ expect(
24
+ create_client.base_url
25
+ ).to start_with 'https://'
26
+ end
27
+
28
+ it 'will use http when secure set to false' do
29
+ expect(
30
+ create_client(secure: false).base_url
31
+ ).to start_with 'http://'
32
+ end
33
+ end
34
+
35
+ describe ':raise_errors' do
36
+ it 'will raise response errors if set to true [default]' do
37
+ expect_vcr('not found'){
38
+ create_client.entry "not found"
39
+ }.to raise_error Contentful::NotFound
40
+ end
41
+
42
+ it 'will not raise response errors if set to false' do
43
+ res = nil
44
+
45
+ expect_vcr('not found'){
46
+ res = create_client(raise_errors: false).entry "not found"
47
+ }.not_to raise_error
48
+ expect( res ).to be_instance_of Contentful::NotFound
49
+ end
50
+ end
51
+
52
+ describe ':dynamic_entries' do
53
+ it 'will create static if dynamic_entry_cache is empty' do
54
+ entry = vcr('nyancat'){ create_client(dynamic_entries: :manual).entry('nyancat') }
55
+ expect( entry ).not_to be_a Contentful::DynamicEntry
56
+ end
57
+
58
+ it 'will create dynamic entries if dynamic_entry_cache is not empty' do
59
+ client = create_client(dynamic_entries: :manual)
60
+ vcr('entry_cache'){ client.update_dynamic_entry_cache! }
61
+ entry = vcr('nyancat'){ client.entry('nyancat') }
62
+
63
+ expect( entry ).to be_a Contentful::DynamicEntry
64
+ end
65
+
66
+ context ':auto' do
67
+ it 'will call update dynamic_entry_cache on start-up' do
68
+ client = vcr('entry_cache'){
69
+ create_client(dynamic_entries: :auto)
70
+ }
71
+ expect( client.dynamic_entry_cache ).not_to be_empty
72
+ expect( client.dynamic_entry_cache.values.first.ancestors ).to \
73
+ include Contentful::DynamicEntry
74
+ end
75
+ end
76
+
77
+ context ':manual' do
78
+ it 'will not call #update_dynamic_entry_cache! on start-up' do
79
+ client = create_client(dynamic_entries: :manual)
80
+ expect( client.dynamic_entry_cache ).to be_empty
81
+ end
82
+ end
83
+
84
+ describe '#update_dynamic_entry_cache!' do
85
+ let(:client){ create_client(dynamic_entries: :manual) }
86
+
87
+ it 'will fetch all content_types' do
88
+ stub(client).content_types{{}}
89
+ client.update_dynamic_entry_cache!
90
+ expect( client ).to have_received.content_types(limit: 0)
91
+ end
92
+
93
+ it 'will save dynamic entries in @dynamic_entry_cache' do
94
+ vcr('entry_cache'){
95
+ client.update_dynamic_entry_cache!
96
+ }
97
+ expect( client.dynamic_entry_cache ).not_to be_empty
98
+ expect( client.dynamic_entry_cache.values.first.ancestors ).to \
99
+ include Contentful::DynamicEntry
100
+ end
101
+ end
102
+
103
+ describe '#register_dynamic_entry' do
104
+ let(:client){ create_client(dynamic_entries: :manual) }
105
+
106
+ it 'can be used to register a dynamic entry manually' do
107
+ cat = vcr('content_type'){ client.content_type 'cat' }
108
+ CatEntry = Contentful::DynamicEntry.create(cat)
109
+ client.register_dynamic_entry 'cat', CatEntry
110
+
111
+ entry = vcr('nyancat'){ client.entry('nyancat') }
112
+ expect( entry ).to be_a Contentful::DynamicEntry
113
+ expect( entry ).to be_a CatEntry
114
+ end
115
+ end
116
+ end
117
+
118
+ describe ':api_url' do
119
+ it 'is "cdn.contentful.com" [default]' do
120
+ expect(
121
+ create_client.configuration[:api_url]
122
+ ).to eq "cdn.contentful.com"
123
+ end
124
+
125
+ it 'will be used as base url' do
126
+ expect(
127
+ create_client(api_url: "cdn2.contentful.com").base_url
128
+ ).to start_with "https://cdn2.contentful.com"
129
+ end
130
+ end
131
+
132
+ describe ':api_version' do
133
+ it 'is 1 [default]' do
134
+ expect(
135
+ create_client.configuration[:api_version]
136
+ ).to eq 1
137
+ end
138
+
139
+ it 'will used for the http content type request header' do
140
+ expect(
141
+ create_client(api_version: 2).request_headers['Content-Type']
142
+ ).to eq "application/vnd.contentful.delivery.v2+json"
143
+ end
144
+ end
145
+
146
+ describe ':authentication_mechanism' do
147
+ describe ':header [default]' do
148
+ it 'will add the :access_token as authorization bearer token request header' do
149
+ expect(
150
+ create_client.request_headers['Authorization']
151
+ ).to eq "Bearer b4c0n73n7fu1"
152
+ end
153
+
154
+ it 'will not add :access_token to query' do
155
+ expect(
156
+ create_client.request_query({})['access_token']
157
+ ).to be_nil
158
+ end
159
+ end
160
+
161
+ describe ':query_string' do
162
+ it 'will add the :access_token to query' do
163
+ expect(
164
+ create_client(authentication_mechanism: :query_string).
165
+ request_query({})['access_token']
166
+ ).to eq "b4c0n73n7fu1"
167
+ end
168
+
169
+ it 'will not add the :access_token as authorization bearer token request header' do
170
+ expect(
171
+ create_client(authentication_mechanism: :query_string).
172
+ request_headers['Authorization']
173
+ ).to be_nil
174
+ end
175
+ end
176
+ end
177
+
178
+ describe ':resource_mapping' do
179
+ it 'lets you register your own resource classes for certain response types' do
180
+ class MyBetterAsset < Contentful::Asset
181
+ def https_image_url
182
+ image_url.sub %r<\A//>, 'https://'
183
+ end
184
+ end
185
+
186
+ client = create_client(
187
+ resource_mapping: {
188
+ 'Asset' => MyBetterAsset,
189
+ }
190
+ )
191
+
192
+ nyancat = vcr('asset'){ client.asset 'nyancat' }
193
+ expect( nyancat ).to be_a MyBetterAsset
194
+ expect( nyancat.https_image_url ).to start_with 'https'
195
+ end
196
+ end
197
+ end