typekit-client 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -3
- data/.travis.yml +4 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +12 -0
- data/Guardfile +21 -3
- data/README.md +253 -248
- data/bin/typekit-client +16 -16
- data/bin/typekit-publisher +6 -5
- data/lib/typekit.rb +6 -2
- data/lib/typekit/client.rb +66 -24
- data/lib/typekit/collection.rb +6 -11
- data/lib/typekit/collection/base.rb +40 -0
- data/lib/typekit/collection/serialization.rb +17 -0
- data/lib/typekit/converter.rb +26 -0
- data/lib/typekit/converter/boolean.rb +12 -0
- data/lib/typekit/converter/collection.rb +13 -0
- data/lib/typekit/converter/datetime.rb +12 -0
- data/lib/typekit/converter/element.rb +13 -0
- data/lib/typekit/converter/errors.rb +12 -0
- data/lib/typekit/converter/unknown.rb +13 -0
- data/lib/typekit/core.rb +8 -10
- data/lib/typekit/element.rb +27 -0
- data/lib/typekit/element/association.rb +63 -0
- data/lib/typekit/element/base.rb +61 -0
- data/lib/typekit/element/persistence.rb +61 -0
- data/lib/typekit/element/query.rb +25 -0
- data/lib/typekit/element/serialization.rb +17 -0
- data/lib/typekit/error.rb +23 -0
- data/lib/typekit/helper.rb +59 -10
- data/lib/typekit/record.rb +18 -22
- data/lib/typekit/record/family.rb +24 -1
- data/lib/typekit/record/kit.rb +29 -1
- data/lib/typekit/record/library.rb +4 -1
- data/lib/typekit/record/variation.rb +13 -1
- data/lib/typekit/version.rb +1 -1
- data/spec/feature/create_kit_spec.rb +52 -0
- data/spec/feature/delete_kit_spec.rb +33 -0
- data/spec/feature/index_kits_spec.rb +55 -0
- data/spec/feature/publish_kit_spec.rb +15 -0
- data/spec/feature/show_family_spec.rb +75 -0
- data/spec/feature/show_kit_spec.rb +56 -0
- data/spec/feature/show_library_spec.rb +29 -0
- data/spec/feature/show_variation_spec.rb +18 -0
- data/spec/feature/update_kit_spec.rb +88 -0
- data/spec/fixture/cassette/create_kits_bad.yml +16 -0
- data/spec/fixture/cassette/create_kits_ok.yml +16 -0
- data/spec/fixture/cassette/delete_kits_xxx_not_found.yml +13 -0
- data/spec/{cassettes → fixture/cassette}/delete_kits_xxx_ok.yml +0 -3
- data/spec/fixture/cassette/index_kits_show_kit_xxx_ok.yml +25 -0
- data/spec/{cassettes → fixture/cassette}/index_kits_unauthorized.yml +0 -3
- data/spec/{cassettes → fixture/cassette}/show_families_xxx_found.yml +0 -3
- data/spec/{cassettes → fixture/cassette}/show_families_xxx_ok.yml +0 -3
- data/spec/{cassettes → fixture/cassette}/show_families_xxx_yyy_ok.yml +0 -3
- data/spec/fixture/cassette/show_families_yyy_update_kits_xxx_families_ok.yml +35 -0
- data/spec/fixture/cassette/show_kits_xxx_families_yyy_show_family_yyy_ok.yml +45 -0
- data/spec/fixture/cassette/show_kits_xxx_not_found.yml +13 -0
- data/spec/fixture/cassette/show_kits_xxx_show_family_yyy_ok.yml +46 -0
- data/spec/{cassettes → fixture/cassette}/show_libraries_xxx_ok.yml +0 -3
- data/spec/fixture/cassette/update_kits_xxx_empty_families_ok.yml +16 -0
- data/spec/fixture/cassette/update_kits_xxx_families_ok.yml +18 -0
- data/spec/fixture/cassette/update_kits_xxx_families_variations_ok.yml +18 -0
- data/spec/fixture/cassette/update_kits_xxx_name_ok.yml +17 -0
- data/spec/fixture/cassette/update_kits_xxx_publish_ok.yml +16 -0
- data/spec/fixture/record/article.rb +11 -0
- data/spec/fixture/record/section.rb +10 -0
- data/spec/lib/typekit/collection_spec.rb +22 -0
- data/spec/{typekit/processing → lib/typekit}/converter_spec.rb +13 -13
- data/spec/lib/typekit/element/association_spec.rb +96 -0
- data/spec/lib/typekit/element/base_spec.rb +70 -0
- data/spec/lib/typekit/element/persistence_spec.rb +97 -0
- data/spec/lib/typekit/element/serialization_spec.rb +28 -0
- data/spec/lib/typekit/element_spec.rb +58 -0
- data/spec/{typekit → lib/typekit}/helper_spec.rb +6 -8
- data/spec/lib/typekit/record_spec.rb +57 -0
- data/spec/spec_helper.rb +10 -3
- data/spec/support/common_helper.rb +5 -0
- data/spec/support/record_helper.rb +38 -0
- data/typekit-client.gemspec +11 -4
- metadata +164 -58
- data/lib/typekit/processing.rb +0 -8
- data/lib/typekit/processing/converter.rb +0 -28
- data/lib/typekit/processing/converter/boolean.rb +0 -14
- data/lib/typekit/processing/converter/collection.rb +0 -18
- data/lib/typekit/processing/converter/datetime.rb +0 -14
- data/lib/typekit/processing/converter/errors.rb +0 -24
- data/lib/typekit/processing/converter/record.rb +0 -16
- data/lib/typekit/processing/converter/unknown.rb +0 -15
- data/lib/typekit/processing/translator.rb +0 -13
- data/lib/typekit/record/base.rb +0 -52
- data/spec/cassettes/index_kits_ok.yml +0 -16
- data/spec/cassettes/show_kits_xxx_families_yyy_ok.yml +0 -16
- data/spec/cassettes/show_kits_xxx_ok.yml +0 -17
- data/spec/features/client/delete_kit_spec.rb +0 -13
- data/spec/features/client/index_kits_spec.rb +0 -25
- data/spec/features/client/show_family_spec.rb +0 -47
- data/spec/features/client/show_kit_spec.rb +0 -18
- data/spec/features/client/show_library_spec.rb +0 -18
- data/spec/features/client/show_variation_spec.rb +0 -22
- data/spec/support/resource_helper.rb +0 -34
- data/spec/typekit/record/base_spec.rb +0 -85
- data/spec/typekit/record_spec.rb +0 -80
data/lib/typekit/record/kit.rb
CHANGED
@@ -1,7 +1,35 @@
|
|
1
1
|
module Typekit
|
2
2
|
module Record
|
3
|
-
class Kit < Base
|
3
|
+
class Kit < Element::Base
|
4
|
+
include Element::Association
|
5
|
+
include Element::Persistence
|
6
|
+
include Element::Query
|
7
|
+
include Element::Serialization
|
8
|
+
|
4
9
|
has_many :families
|
10
|
+
|
11
|
+
def complete?
|
12
|
+
!persistent? || attribute?(:families)
|
13
|
+
end
|
14
|
+
|
15
|
+
def load!
|
16
|
+
become(process(:show, id))
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def publish!
|
21
|
+
process(:update, id, :publish)
|
22
|
+
end
|
23
|
+
|
24
|
+
[:load, :publish].each do |method|
|
25
|
+
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
26
|
+
def #{method}(*arguments)
|
27
|
+
#{method}!(*arguments)
|
28
|
+
rescue ServerError
|
29
|
+
false
|
30
|
+
end
|
31
|
+
CODE
|
32
|
+
end
|
5
33
|
end
|
6
34
|
end
|
7
35
|
end
|
@@ -1,8 +1,20 @@
|
|
1
1
|
module Typekit
|
2
2
|
module Record
|
3
|
-
class Variation < Base
|
3
|
+
class Variation < Element::Base
|
4
|
+
include Element::Association
|
5
|
+
include Element::Serialization
|
6
|
+
|
4
7
|
has_many :libraries
|
5
8
|
belongs_to :family
|
9
|
+
|
10
|
+
def initialize(*arguments)
|
11
|
+
arguments[-1] = { id: arguments[-1] } if arguments[-1].is_a?(String)
|
12
|
+
super(*arguments)
|
13
|
+
end
|
14
|
+
|
15
|
+
def serialize
|
16
|
+
id.to_s.split(':').last
|
17
|
+
end
|
6
18
|
end
|
7
19
|
end
|
8
20
|
end
|
data/lib/typekit/version.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/bdd'
|
3
|
+
|
4
|
+
RSpec.feature 'Creating a new kit' do
|
5
|
+
given(:client) { Typekit::Client.new(token: token) }
|
6
|
+
|
7
|
+
context 'Successful' do
|
8
|
+
options = { vcr: { cassette_name: 'create_kits_ok' } }
|
9
|
+
|
10
|
+
scenario 'Using #save', options do
|
11
|
+
kit = client::Kit.new(name: 'Megakit', domains: 'localhost')
|
12
|
+
kit.save
|
13
|
+
|
14
|
+
expect(kit).to be_persistent
|
15
|
+
expect(kit.name).to eq('Megakit')
|
16
|
+
end
|
17
|
+
|
18
|
+
scenario 'Using #create', options do
|
19
|
+
kit = client::Kit.create(name: 'Megakit', domains: 'localhost')
|
20
|
+
|
21
|
+
expect(kit).to be_persistent
|
22
|
+
expect(kit.name).to eq('Megakit')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'Failure' do
|
27
|
+
options = { vcr: { cassette_name: 'create_kits_bad' } }
|
28
|
+
|
29
|
+
scenario 'Using #save', options do
|
30
|
+
kit = client::Kit.new(name: 'Megakit')
|
31
|
+
|
32
|
+
expect(kit.save).to be false
|
33
|
+
expect(kit).not_to be_persistent
|
34
|
+
end
|
35
|
+
|
36
|
+
scenario 'Using #save!', options do
|
37
|
+
kit = client::Kit.new(name: 'Megakit')
|
38
|
+
|
39
|
+
expect { kit.save! }.to raise_error(Typekit::ServerError)
|
40
|
+
|
41
|
+
expect(kit).to be_new
|
42
|
+
expect(kit).not_to be_persistent
|
43
|
+
end
|
44
|
+
|
45
|
+
scenario 'Using #create', options do
|
46
|
+
kit = client::Kit.create(name: 'Megakit')
|
47
|
+
|
48
|
+
expect(kit).to be_new
|
49
|
+
expect(kit).not_to be_persistent
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/bdd'
|
3
|
+
|
4
|
+
RSpec.feature 'Deleting a kit' do
|
5
|
+
given(:client) { Typekit::Client.new(token: token) }
|
6
|
+
|
7
|
+
shared_scenarios 'Adequate behavior' do
|
8
|
+
options = { vcr: { cassette_name: 'delete_kits_xxx_ok' } }
|
9
|
+
|
10
|
+
scenario 'Success', options do
|
11
|
+
expect(result).to be true
|
12
|
+
end
|
13
|
+
|
14
|
+
options = { vcr: { cassette_name: 'delete_kits_xxx_not_found' } }
|
15
|
+
|
16
|
+
scenario 'Failure', options do
|
17
|
+
expect { result }.to raise_error(Typekit::ServerError, /Not found/i)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'Using Client' do
|
22
|
+
given(:result) { client.delete(:kits, 'xxx') }
|
23
|
+
|
24
|
+
include_scenarios 'Adequate behavior'
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'Using Record' do
|
28
|
+
given(:kit) { client::Kit.new(id: 'xxx') }
|
29
|
+
given(:result) { kit.delete! }
|
30
|
+
|
31
|
+
include_scenarios 'Adequate behavior'
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/bdd'
|
3
|
+
|
4
|
+
RSpec.feature 'Listing kits' do
|
5
|
+
given(:client) { Typekit::Client.new(token: token) }
|
6
|
+
|
7
|
+
shared_scenarios 'Adequate behavior' do
|
8
|
+
options = { vcr: { cassette_name: 'index_kits_show_kit_xxx_ok' } }
|
9
|
+
|
10
|
+
scenario 'Success', options do
|
11
|
+
kits = client::Kit.all
|
12
|
+
|
13
|
+
expect(kits).to be_kind_of(Typekit::Collection::Base)
|
14
|
+
expect(kits).not_to be_empty
|
15
|
+
|
16
|
+
kits.each do |kit|
|
17
|
+
expect(kit).to be_kind_of(Typekit::Record::Kit)
|
18
|
+
|
19
|
+
expect(kit).to be_persistent
|
20
|
+
expect(kit).not_to be_new
|
21
|
+
expect(kit).not_to be_complete
|
22
|
+
|
23
|
+
expect(kit.attributes.keys).to contain_exactly(:id, :link)
|
24
|
+
end
|
25
|
+
|
26
|
+
kit = kits.first
|
27
|
+
|
28
|
+
expect(kit.load!).to be true
|
29
|
+
|
30
|
+
expect(kit).to be_persistent
|
31
|
+
expect(kit).not_to be_new
|
32
|
+
expect(kit).to be_complete
|
33
|
+
|
34
|
+
expect(kit.families).to be_kind_of(Typekit::Collection::Base)
|
35
|
+
end
|
36
|
+
|
37
|
+
options = { vcr: { cassette_name: 'index_kits_unauthorized' } }
|
38
|
+
|
39
|
+
scenario 'Failure', options do
|
40
|
+
expect { kits }.to raise_error(Typekit::ServerError, /Not authorized/i)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'Using Client' do
|
45
|
+
given(:kits) { client.index(:kits) }
|
46
|
+
|
47
|
+
include_scenarios 'Adequate behavior'
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'Using Record' do
|
51
|
+
given(:kits) { client::Kit.all }
|
52
|
+
|
53
|
+
include_scenarios 'Adequate behavior'
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/bdd'
|
3
|
+
|
4
|
+
RSpec.feature 'Publishing a kit' do
|
5
|
+
given(:client) { Typekit::Client.new(token: token) }
|
6
|
+
given(:kit) { client::Kit.new(:kits, id: 'xxx') }
|
7
|
+
|
8
|
+
options = { vcr: { cassette_name: 'update_kits_xxx_publish_ok' } }
|
9
|
+
|
10
|
+
scenario 'Success', options do
|
11
|
+
date = kit.publish!
|
12
|
+
|
13
|
+
expect(date).to be_kind_of(DateTime)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/bdd'
|
3
|
+
|
4
|
+
RSpec.feature 'Reading a family' do
|
5
|
+
given(:client) { Typekit::Client.new(token: token) }
|
6
|
+
|
7
|
+
shared_scenarios 'Adequate behavior' do
|
8
|
+
options = { vcr: { cassette_name: 'show_families_xxx_ok' } }
|
9
|
+
|
10
|
+
scenario 'Success using the id parameter', options do
|
11
|
+
expect(family).to be_kind_of(Typekit::Record::Family)
|
12
|
+
|
13
|
+
variations = family.variations
|
14
|
+
expect(variations).to be_kind_of(Typekit::Collection::Base)
|
15
|
+
|
16
|
+
variations.each do |variation|
|
17
|
+
expect(variation).to be_kind_of(Typekit::Record::Variation)
|
18
|
+
end
|
19
|
+
|
20
|
+
libraries = family.libraries
|
21
|
+
expect(libraries).to be_kind_of(Typekit::Collection::Base)
|
22
|
+
|
23
|
+
libraries.each do |library|
|
24
|
+
expect(library).to be_kind_of(Typekit::Record::Library)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
options = { vcr: { cassette_name: 'show_families_xxx_found' } }
|
29
|
+
|
30
|
+
scenario 'Success using the slug parameter', options do
|
31
|
+
expect(family).to be_kind_of(Typekit::Record::Family)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'Searching directly using Client' do
|
36
|
+
given(:family) { client.show(:families, 'xxx') }
|
37
|
+
|
38
|
+
include_scenarios 'Adequate behavior'
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'Searching directly using Record' do
|
42
|
+
given(:family) { client::Family.find('xxx') }
|
43
|
+
|
44
|
+
include_scenarios 'Adequate behavior'
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'Searching in a Kit using Client' do
|
48
|
+
given(:family) { client.show(:kits, 'xxx', :families, 'yyy') }
|
49
|
+
|
50
|
+
options = { vcr: { cassette_name:
|
51
|
+
'show_kits_xxx_families_yyy_show_family_yyy_ok' } }
|
52
|
+
|
53
|
+
scenario 'Success', options do
|
54
|
+
expect(family).to be_kind_of(Typekit::Record::Family)
|
55
|
+
|
56
|
+
variations = family.variations
|
57
|
+
expect(variations).to be_kind_of(Typekit::Collection::Base)
|
58
|
+
|
59
|
+
variations.each do |variation|
|
60
|
+
expect(variation).to be_kind_of(Typekit::Record::Variation)
|
61
|
+
end
|
62
|
+
|
63
|
+
expect(family).not_to be_complete
|
64
|
+
|
65
|
+
libraries = family.libraries
|
66
|
+
expect(variations).to be_kind_of(Typekit::Collection::Base)
|
67
|
+
|
68
|
+
expect(family).to be_complete
|
69
|
+
|
70
|
+
libraries.each do |library|
|
71
|
+
expect(library).to be_kind_of(Typekit::Record::Library)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/bdd'
|
3
|
+
|
4
|
+
RSpec.feature 'Reading a kit' do
|
5
|
+
given(:client) { Typekit::Client.new(token: token) }
|
6
|
+
|
7
|
+
shared_scenarios 'Adequate behavior' do
|
8
|
+
options = { vcr: { cassette_name: 'show_kits_xxx_show_family_yyy_ok' } }
|
9
|
+
|
10
|
+
scenario 'Success', options do
|
11
|
+
expect(kit).to be_kind_of(Typekit::Record::Kit)
|
12
|
+
expect(kit).to be_complete
|
13
|
+
|
14
|
+
families = kit.families
|
15
|
+
|
16
|
+
expect(families).to be_kind_of(Typekit::Collection::Base)
|
17
|
+
expect(families).not_to be_empty
|
18
|
+
|
19
|
+
families.each do |family|
|
20
|
+
expect(family).to be_kind_of(Typekit::Record::Family)
|
21
|
+
expect(family).not_to be_complete
|
22
|
+
end
|
23
|
+
|
24
|
+
family = families.first
|
25
|
+
expect(family.load!).to be true
|
26
|
+
expect(family).to be_complete
|
27
|
+
|
28
|
+
variations = family.variations
|
29
|
+
|
30
|
+
expect(variations).to be_kind_of(Typekit::Collection::Base)
|
31
|
+
expect(variations).not_to be_empty
|
32
|
+
|
33
|
+
variations.each do |variation|
|
34
|
+
expect(variation).to be_kind_of(Typekit::Record::Variation)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
options = { vcr: { cassette_name: 'show_kits_xxx_not_found' } }
|
39
|
+
|
40
|
+
scenario 'Failure', options do
|
41
|
+
expect { kit }.to raise_error(Typekit::ServerError, /Not found/i)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'Using Client' do
|
46
|
+
given(:kit) { client.show(:kits, 'xxx') }
|
47
|
+
|
48
|
+
include_scenarios 'Adequate behavior'
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'Using Record' do
|
52
|
+
given(:kit) { client::Kit.find!('xxx') }
|
53
|
+
|
54
|
+
include_scenarios 'Adequate behavior'
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/bdd'
|
3
|
+
|
4
|
+
RSpec.feature 'Reading a library' do
|
5
|
+
given(:client) { Typekit::Client.new(token: token) }
|
6
|
+
|
7
|
+
shared_scenarios 'Adequate behavior' do
|
8
|
+
options = { vcr: { cassette_name: 'show_libraries_xxx_ok' } }
|
9
|
+
|
10
|
+
scenario 'Success', options do
|
11
|
+
expect(library).to be_kind_of(Typekit::Record::Library)
|
12
|
+
|
13
|
+
expect(library.families.map(&:class).uniq).to \
|
14
|
+
contain_exactly(Typekit::Record::Family)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'Using Client' do
|
19
|
+
given(:library) { client.show(:libraries, 'xxx') }
|
20
|
+
|
21
|
+
include_scenarios 'Adequate behavior'
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'Using Record' do
|
25
|
+
given(:library) { client::Library.find('xxx') }
|
26
|
+
|
27
|
+
include_scenarios 'Adequate behavior'
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/bdd'
|
3
|
+
|
4
|
+
RSpec.feature 'Reading a variation' do
|
5
|
+
given(:client) { Typekit::Client.new(token: token) }
|
6
|
+
given(:variation) { client.show(:families, 'xxx', 'yyy') }
|
7
|
+
|
8
|
+
options = { vcr: { cassette_name: 'show_families_xxx_yyy_ok' } }
|
9
|
+
|
10
|
+
scenario 'Success', options do
|
11
|
+
expect(variation).to be_kind_of(Typekit::Record::Variation)
|
12
|
+
|
13
|
+
expect(variation.libraries.map(&:class).uniq).to \
|
14
|
+
contain_exactly(Typekit::Record::Library)
|
15
|
+
|
16
|
+
expect(variation.family).to be_kind_of(Typekit::Record::Family)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/bdd'
|
3
|
+
|
4
|
+
RSpec.feature 'Updating a kit' do
|
5
|
+
given(:client) { Typekit::Client.new(token: token) }
|
6
|
+
|
7
|
+
given(:kit) do
|
8
|
+
client::Kit.new(:kits, id: 'xxx', name: 'Megakit',
|
9
|
+
analytics: false, badge: true, domains: ['localhost'],
|
10
|
+
families: [{ id: 'vqgt', subset: 'all', variations: ['n4'] }])
|
11
|
+
end
|
12
|
+
|
13
|
+
options = { vcr: { cassette_name: 'update_kits_xxx_name_ok' } }
|
14
|
+
|
15
|
+
scenario 'Changing the name attribute via #save', options do
|
16
|
+
kit.name = 'Ultrakit'
|
17
|
+
kit.save!
|
18
|
+
|
19
|
+
expect(kit.name).to eq('Ultrakit')
|
20
|
+
end
|
21
|
+
|
22
|
+
scenario 'Changing the name attribute via #update', options do
|
23
|
+
kit.update!(name: 'Ultrakit')
|
24
|
+
|
25
|
+
expect(kit.name).to eq('Ultrakit')
|
26
|
+
end
|
27
|
+
|
28
|
+
options = { vcr: { cassette_name: 'update_kits_xxx_families_ok' } }
|
29
|
+
|
30
|
+
scenario 'Adding a new family', options do
|
31
|
+
kit.families << Typekit::Record::Family.new(id: 'gkmg')
|
32
|
+
kit.save!
|
33
|
+
|
34
|
+
expect(kit.families.length).to be 2
|
35
|
+
expect(kit.families.map(&:id)).to contain_exactly('gkmg', 'vqgt')
|
36
|
+
end
|
37
|
+
|
38
|
+
options = { vcr: {
|
39
|
+
cassette_name: 'show_families_yyy_update_kits_xxx_families_ok' } }
|
40
|
+
|
41
|
+
scenario 'Adding a family fetched earlier', options do
|
42
|
+
family = client::Family.find('gkmg')
|
43
|
+
|
44
|
+
expect(family).to be_complete
|
45
|
+
expect(family.libraries).not_to be_empty
|
46
|
+
expect(family.variations).not_to be_empty
|
47
|
+
|
48
|
+
kit.families << family
|
49
|
+
kit.save!
|
50
|
+
|
51
|
+
expect(kit.families.length).to be 2
|
52
|
+
expect(kit.families.map(&:id)).to contain_exactly('gkmg', 'vqgt')
|
53
|
+
end
|
54
|
+
|
55
|
+
options = { vcr: {
|
56
|
+
cassette_name: 'update_kits_xxx_families_variations_ok' } }
|
57
|
+
|
58
|
+
scenario 'Adding a new family with variations', options do
|
59
|
+
family = Typekit::Record::Family.new(id: 'gkmg')
|
60
|
+
|
61
|
+
expect { family.variations }.to raise_error(/Client is not specified/i)
|
62
|
+
family.variations = [Typekit::Record::Variation.new(id: 'n4')]
|
63
|
+
|
64
|
+
expect(kit.families).not_to be nil
|
65
|
+
|
66
|
+
kit.families << family
|
67
|
+
kit.save!
|
68
|
+
|
69
|
+
expect(kit.families.length).to be 2
|
70
|
+
expect(kit.families.map(&:id)).to contain_exactly('gkmg', 'vqgt')
|
71
|
+
|
72
|
+
i = kit.families[0].id == 'gkmg' ? 0 : 1
|
73
|
+
expect(kit.families[i].variations.map(&:id)).to eq(['n4'])
|
74
|
+
end
|
75
|
+
|
76
|
+
options = { vcr: {
|
77
|
+
cassette_name: 'update_kits_xxx_empty_families_ok' } }
|
78
|
+
|
79
|
+
scenario 'Deleting all families', options do
|
80
|
+
expect(kit.families.length).to be 1
|
81
|
+
|
82
|
+
family = kit.families.first
|
83
|
+
kit.families.delete(family)
|
84
|
+
kit.save!
|
85
|
+
|
86
|
+
expect(kit.families).to be_empty
|
87
|
+
end
|
88
|
+
end
|