dribbble 0.0.4 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -1
- data/Guardfile +0 -5
- data/dribbble.gemspec +0 -3
- data/lib/dribbble/attachment.rb +7 -0
- data/lib/dribbble/base.rb +64 -5
- data/lib/dribbble/bucket.rb +31 -0
- data/lib/dribbble/client.rb +0 -7
- data/lib/dribbble/comment.rb +4 -0
- data/lib/dribbble/like.rb +7 -0
- data/lib/dribbble/project.rb +11 -0
- data/lib/dribbble/shot.rb +62 -0
- data/lib/dribbble/team.rb +4 -0
- data/lib/dribbble/user.rb +47 -6
- data/lib/dribbble/utils/creatable.rb +33 -0
- data/lib/dribbble/utils/deletable.rb +21 -0
- data/lib/dribbble/utils/findable.rb +17 -0
- data/lib/dribbble/utils/has_children.rb +33 -0
- data/lib/dribbble/utils/updatable.rb +24 -0
- data/lib/dribbble/utils.rb +38 -7
- data/lib/dribbble/version.rb +1 -1
- data/spec/lib/dribbble/base_spec.rb +161 -4
- data/spec/lib/dribbble/bucket_spec.rb +136 -0
- data/spec/lib/dribbble/client_spec.rb +2 -23
- data/spec/lib/dribbble/project_spec.rb +45 -0
- data/spec/lib/dribbble/shot_spec.rb +254 -0
- data/spec/lib/dribbble/user_spec.rb +173 -23
- data/spec/spec_helper.rb +14 -17
- data/spec/support/dribbble.rb +159 -20
- data/spec/support/fixtures/attachment_success.json +9 -0
- data/spec/support/fixtures/attachments_success.json +11 -0
- data/spec/support/fixtures/bucket_created.json +8 -0
- data/spec/support/fixtures/bucket_success.json +8 -0
- data/spec/support/fixtures/bucket_updated.json +8 -0
- data/spec/support/fixtures/comments_success.json +37 -0
- data/spec/support/fixtures/current_user_success.json +25 -0
- data/spec/support/fixtures/followers_success.json +33 -0
- data/spec/support/fixtures/following_success.json +33 -0
- data/spec/support/fixtures/project_success.json +8 -0
- data/spec/support/fixtures/projects_success.json +10 -0
- data/spec/support/fixtures/shot_likes_success.json +33 -0
- data/spec/support/fixtures/shot_success.json +85 -0
- data/spec/support/fixtures/shot_updated.json +85 -0
- data/spec/support/fixtures/teams_success.json +28 -0
- data/spec/support/fixtures/user_likes_success.json +91 -0
- metadata +52 -48
- data/spec/factories.rb +0 -2
@@ -5,9 +5,9 @@ describe Dribbble::Client do
|
|
5
5
|
@base = Dribbble::Base.new 'valid_token', {}
|
6
6
|
end
|
7
7
|
|
8
|
-
describe 'on #
|
8
|
+
describe 'on #full_url_with_default_params' do
|
9
9
|
describe 'without params' do
|
10
|
-
subject { @base.
|
10
|
+
subject { @base.full_url_with_default_params '/shots' }
|
11
11
|
|
12
12
|
it 'return a valid url' do
|
13
13
|
expect(subject).to eq('https://api.dribbble.com/v1/shots?page=1&per_page=100')
|
@@ -15,7 +15,7 @@ describe Dribbble::Client do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe 'with default params overrided' do
|
18
|
-
subject { @base.
|
18
|
+
subject { @base.full_url_with_default_params '/shots', page: 2, per_page: 10 }
|
19
19
|
|
20
20
|
it 'return a valid url' do
|
21
21
|
expect(subject).to eq('https://api.dribbble.com/v1/shots?page=2&per_page=10')
|
@@ -23,11 +23,168 @@ describe Dribbble::Client do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe 'with extra params' do
|
26
|
-
subject { @base.
|
26
|
+
subject { @base.full_url_with_default_params '/shots', params1: 'custom' }
|
27
27
|
|
28
28
|
it 'return a valid url' do
|
29
29
|
expect(subject).to eq('https://api.dribbble.com/v1/shots?page=1&per_page=100¶ms1=custom')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
describe 'on #full_url' do
|
35
|
+
describe 'without params' do
|
36
|
+
subject { @base.full_url '/shots' }
|
37
|
+
|
38
|
+
it 'return a valid url' do
|
39
|
+
expect(subject).to eq('https://api.dribbble.com/v1/shots?')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'with params' do
|
44
|
+
subject { @base.full_url '/shots', custom: 1 }
|
45
|
+
|
46
|
+
it 'return a valid url' do
|
47
|
+
expect(subject).to eq('https://api.dribbble.com/v1/shots?custom=1')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'on #get_bucket' do
|
53
|
+
subject do
|
54
|
+
stub_dribbble :get, '/buckets/2754', DribbbleAPI::BucketSuccess
|
55
|
+
@base.get_bucket 2754
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'return a bucket' do
|
59
|
+
expect(subject).to be_a Dribbble::Bucket
|
60
|
+
expect(subject.id).to eq(2754)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'on #get_buckets' do
|
65
|
+
subject do
|
66
|
+
stub_dribbble :get, '/user/buckets', DribbbleAPI::BucketsSuccess
|
67
|
+
@base.get_buckets
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'return buckets' do
|
71
|
+
expect(subject.first).to be_a Dribbble::Bucket
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'on #get_followers' do
|
76
|
+
subject do
|
77
|
+
stub_dribbble :get, '/user/followers', DribbbleAPI::FollowersSuccess
|
78
|
+
@base.get_followers
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'return users' do
|
82
|
+
expect(subject.first).to be_a Dribbble::User
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe 'on #get_likes' do
|
87
|
+
subject do
|
88
|
+
stub_dribbble :get, '/user/likes', DribbbleAPI::UserLikesSuccess
|
89
|
+
@base.get_likes
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'return shots' do
|
93
|
+
expect(subject.first).to be_a Dribbble::Shot
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'on #get_project' do
|
98
|
+
subject do
|
99
|
+
stub_dribbble :get, '/projects/3', DribbbleAPI::ProjectSuccess
|
100
|
+
@base.get_project 3
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'return a project' do
|
104
|
+
expect(subject).to be_a Dribbble::Project
|
105
|
+
expect(subject.id).to eq(3)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'on #get_projects' do
|
110
|
+
subject do
|
111
|
+
stub_dribbble :get, '/user/projects', DribbbleAPI::ProjectsSuccess
|
112
|
+
@base.get_projects
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'return projects' do
|
116
|
+
expect(subject.first).to be_a Dribbble::Project
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe 'on #get_shot' do
|
121
|
+
subject do
|
122
|
+
stub_dribbble :get, '/shots/471756', DribbbleAPI::ShotSuccess
|
123
|
+
@base.get_shot 471_756
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'return a shot' do
|
127
|
+
expect(subject).to be_a Dribbble::Shot
|
128
|
+
expect(subject.id).to eq(471_756)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe 'on #get_shots' do
|
133
|
+
subject do
|
134
|
+
stub_dribbble :get, '/user/shots', DribbbleAPI::ShotsSuccess
|
135
|
+
@base.get_shots
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'return shots' do
|
139
|
+
expect(subject.first).to be_a Dribbble::Shot
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe 'on #get_following_shots' do
|
144
|
+
subject do
|
145
|
+
stub_dribbble :get, '/user/following/shots', DribbbleAPI::ShotsSuccess
|
146
|
+
@base.get_following_shots
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'return shots' do
|
150
|
+
expect(subject.first).to be_a Dribbble::Shot
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe 'on #get_teams' do
|
155
|
+
subject do
|
156
|
+
stub_dribbble :get, '/user/teams', DribbbleAPI::TeamsSuccess
|
157
|
+
@base.get_teams
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'return teams' do
|
161
|
+
expect(subject.first).to be_a Dribbble::Team
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe 'on #get_user' do
|
166
|
+
describe 'without id' do
|
167
|
+
subject do
|
168
|
+
stub_dribbble :get, '/user', DribbbleAPI::CurrentUserSuccess
|
169
|
+
@base.get_user
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'return current user' do
|
173
|
+
expect(subject).to be_a Dribbble::User
|
174
|
+
expect(subject.id).to eq(8_008_135)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe 'with id' do
|
179
|
+
subject do
|
180
|
+
stub_dribbble :get, '/users/483195', DribbbleAPI::UserSuccess
|
181
|
+
@base.get_user 483_195
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'return current user' do
|
185
|
+
expect(subject).to be_a Dribbble::User
|
186
|
+
expect(subject.id).to eq(483_195)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
33
190
|
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RAW_BUCKET = data_from_json 'bucket_success.json'
|
4
|
+
|
5
|
+
describe Dribbble::Bucket do
|
6
|
+
describe 'on instance' do
|
7
|
+
before :all do
|
8
|
+
@bucket = Dribbble::Bucket.new 'valid_token', RAW_BUCKET
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'after initialization' do
|
12
|
+
RAW_BUCKET.each do |field, value|
|
13
|
+
it "respond to #{field}" do
|
14
|
+
expect(@bucket.send field).to eq(value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'on #update' do
|
20
|
+
subject do
|
21
|
+
stub_dribbble :put, '/buckets/2754', DribbbleAPI::BucketUpdated
|
22
|
+
new_bucket = {
|
23
|
+
name: 'Bucket title',
|
24
|
+
description: 'Bucket description'
|
25
|
+
}
|
26
|
+
@bucket.update new_bucket
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'update bucket' do
|
30
|
+
expect(subject.name).to eq('Bucket title')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'on #delete' do
|
35
|
+
subject do
|
36
|
+
stub_dribbble :delete, '/buckets/2754', DribbbleAPI::BucketDeleted
|
37
|
+
@bucket.delete
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'return true' do
|
41
|
+
expect(subject).to eq(true)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'on #shots' do
|
46
|
+
subject do
|
47
|
+
stub_dribbble :get, '/bucket/2754/shots', DribbbleAPI::ShotsSuccess
|
48
|
+
@bucket.shots
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'responds with shots' do
|
52
|
+
expect(subject.size).to eq 2
|
53
|
+
expect(subject.first).to be_a Dribbble::Shot
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'on #add_shot' do
|
58
|
+
subject do
|
59
|
+
stub_dribbble :put, '/buckets/2754/shots', DribbbleAPI::NoContent
|
60
|
+
@bucket.add_shot '471756'
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'add shot' do
|
64
|
+
expect(subject).to eq(true)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'on #remove_shot' do
|
69
|
+
subject do
|
70
|
+
stub_dribbble :delete, '/buckets/2754/shots?shot_id=471756', DribbbleAPI::NoContent
|
71
|
+
@bucket.remove_shot '471756'
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'remove shot' do
|
75
|
+
expect(subject).to eq(true)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'on class' do
|
81
|
+
describe 'on #create' do
|
82
|
+
subject do
|
83
|
+
stub_dribbble :post, '/buckets', DribbbleAPI::BucketCreated
|
84
|
+
bucket = {
|
85
|
+
name: 'Bucket title',
|
86
|
+
description: 'Bucket description'
|
87
|
+
}
|
88
|
+
Dribbble::Bucket.create 'valid_token', bucket
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'create the shot' do
|
92
|
+
expect(subject).to be_a Dribbble::Bucket
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe 'on #update' do
|
97
|
+
subject do
|
98
|
+
stub_dribbble :get, '/buckets/2754', DribbbleAPI::BucketSuccess
|
99
|
+
stub_dribbble :put, '/buckets/2754', DribbbleAPI::BucketUpdated
|
100
|
+
bucket = {
|
101
|
+
name: 'Bucket title',
|
102
|
+
description: 'Bucket description'
|
103
|
+
}
|
104
|
+
Dribbble::Bucket.update 'valid_token', 2754, bucket
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'update bucket' do
|
108
|
+
expect(subject.name).to eq('Bucket title')
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe 'on #delete' do
|
113
|
+
subject do
|
114
|
+
stub_dribbble :get, '/buckets/2754', DribbbleAPI::BucketSuccess
|
115
|
+
stub_dribbble :delete, '/buckets/2754', DribbbleAPI::BucketDeleted
|
116
|
+
Dribbble::Bucket.delete 'valid_token', 2754
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'return true' do
|
120
|
+
expect(subject).to eq(true)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe 'on #find' do
|
125
|
+
subject do
|
126
|
+
stub_dribbble :get, '/buckets/2754', DribbbleAPI::BucketSuccess
|
127
|
+
Dribbble::Bucket.find 'valid_token', 2754
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'return a bucket' do
|
131
|
+
expect(subject).to be_a Dribbble::Bucket
|
132
|
+
expect(subject.id).to eq(2754)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -12,7 +12,7 @@ describe Dribbble::Client do
|
|
12
12
|
describe 'on #user' do
|
13
13
|
describe 'with an invalid token' do
|
14
14
|
subject do
|
15
|
-
|
15
|
+
stub_dribbble :get, '/user', DribbbleAPI::Unauthorized
|
16
16
|
Dribbble::Client.new(token: 'fake_invalid_token')
|
17
17
|
end
|
18
18
|
|
@@ -25,7 +25,7 @@ describe Dribbble::Client do
|
|
25
25
|
|
26
26
|
describe 'with a valid token' do
|
27
27
|
subject do
|
28
|
-
|
28
|
+
stub_dribbble :get, '/user', DribbbleAPI::UserSuccess
|
29
29
|
Dribbble::Client.new(token: 'valid_token')
|
30
30
|
end
|
31
31
|
|
@@ -35,25 +35,4 @@ describe Dribbble::Client do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
39
|
-
describe 'on #create_shot' do
|
40
|
-
before :all do
|
41
|
-
stub_dribbble_with DribbbleAPI::Created
|
42
|
-
@shot = {
|
43
|
-
title: 'Shot title',
|
44
|
-
desciption: 'Shot description',
|
45
|
-
image: File.new("#{Dir.pwd}/spec/support/fixtures/image.jpg", 'rb'),
|
46
|
-
tags: %w(tag1 tag2)
|
47
|
-
}
|
48
|
-
@client = Dribbble::Client.new(token: 'valid_token')
|
49
|
-
end
|
50
|
-
|
51
|
-
subject do
|
52
|
-
@client.create_shot(@shot)
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'create the shot' do
|
56
|
-
expect(subject.code).to eq(202)
|
57
|
-
end
|
58
|
-
end
|
59
38
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RAW_PROJECT = data_from_json 'project_success.json'
|
4
|
+
|
5
|
+
describe Dribbble::Project do
|
6
|
+
describe 'on instance' do
|
7
|
+
before :all do
|
8
|
+
@project = Dribbble::Project.new 'valid_token', RAW_PROJECT
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'after initialization' do
|
12
|
+
RAW_PROJECT.each do |field, value|
|
13
|
+
it "respond to #{field}" do
|
14
|
+
expect(@project.send field).to eq(value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'on #shots' do
|
20
|
+
subject do
|
21
|
+
stub_dribbble :get, '/projects/3/shots', DribbbleAPI::ShotsSuccess
|
22
|
+
@project.shots
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'responds with shots' do
|
26
|
+
expect(subject.size).to eq 2
|
27
|
+
expect(subject.first).to be_a Dribbble::Shot
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'on class' do
|
33
|
+
describe 'on #find' do
|
34
|
+
subject do
|
35
|
+
stub_dribbble :get, '/projects/3', DribbbleAPI::ProjectSuccess
|
36
|
+
Dribbble::Project.find 'valid_token', 3
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'return a project' do
|
40
|
+
expect(subject).to be_a Dribbble::Project
|
41
|
+
expect(subject.id).to eq(3)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,254 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RAW_SHOT = data_from_json 'shot_success.json'
|
4
|
+
|
5
|
+
describe Dribbble::Shot do
|
6
|
+
describe 'on instance' do
|
7
|
+
before :all do
|
8
|
+
@shot = Dribbble::Shot.new 'valid_token', RAW_SHOT
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'after initialization' do
|
12
|
+
RAW_SHOT.each do |field, value|
|
13
|
+
it "respond to #{field}" do
|
14
|
+
expect(@shot.send field).to eq(value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'on #update' do
|
20
|
+
subject do
|
21
|
+
stub_dribbble :put, '/shots/471756', DribbbleAPI::ShotUpdated
|
22
|
+
new_shot = {
|
23
|
+
title: 'Shot title',
|
24
|
+
description: 'Shot description'
|
25
|
+
}
|
26
|
+
@shot.update new_shot
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'update shot' do
|
30
|
+
expect(subject.title).to eq('Shot title')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'on #delete' do
|
35
|
+
subject do
|
36
|
+
stub_dribbble :delete, '/shots/471756', DribbbleAPI::ShotDeleted
|
37
|
+
@shot.delete
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'return true' do
|
41
|
+
expect(subject).to eq(true)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'on #attachments' do
|
46
|
+
describe 'all' do
|
47
|
+
subject do
|
48
|
+
stub_dribbble :get, '/shots/471756/attachments', DribbbleAPI::AttachmentsSuccess
|
49
|
+
@shot.attachments
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'return a shot' do
|
53
|
+
expect(subject.first).to be_a Dribbble::Attachment
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'create' do
|
58
|
+
subject do
|
59
|
+
stub_dribbble :post, '/shots/471756/attachments', DribbbleAPI::Accepted
|
60
|
+
@shot.create_attachment
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'works' do
|
64
|
+
expect(subject).to be_truthy
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'find' do
|
69
|
+
subject do
|
70
|
+
stub_dribbble :get, '/shots/471756/attachments/206165', DribbbleAPI::AttachmentSuccess
|
71
|
+
@shot.find_attachment 206_165
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'return an attachment' do
|
75
|
+
expect(subject).to be_a Dribbble::Attachment
|
76
|
+
expect(subject.id).to eq(206_165)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'on #buckets' do
|
82
|
+
subject do
|
83
|
+
stub_dribbble :get, '/shots/471756/buckets', DribbbleAPI::BucketsSuccess
|
84
|
+
@shot.buckets
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'return a shot' do
|
88
|
+
expect(subject.first).to be_a Dribbble::Bucket
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe 'on #comments' do
|
93
|
+
subject do
|
94
|
+
stub_dribbble :get, '/shots/471756/comments', DribbbleAPI::CommentsSuccess
|
95
|
+
@shot.comments
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'return a shot' do
|
99
|
+
expect(subject.first).to be_a Dribbble::Comment
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe 'on #likes' do
|
104
|
+
subject do
|
105
|
+
stub_dribbble :get, '/shots/471756/likes', DribbbleAPI::ShotLikesSuccess
|
106
|
+
@shot.likes
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'return a user' do
|
110
|
+
expect(subject.first).to be_a Dribbble::Like
|
111
|
+
expect(subject.first.user).to be_a Dribbble::User
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe 'on #like?' do
|
116
|
+
describe 'on a not liked shot' do
|
117
|
+
subject do
|
118
|
+
stub_dribbble :get, '/shots/471756/like', DribbbleAPI::ShotLikeNotFound
|
119
|
+
@shot.like?
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'return a user' do
|
123
|
+
expect(subject).to be_falsy
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe 'on a liked shot' do
|
128
|
+
subject do
|
129
|
+
stub_dribbble :get, '/shots/471756/like', DribbbleAPI::ShotLikeSuccess
|
130
|
+
@shot.like?
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'return a user' do
|
134
|
+
expect(subject).to be_truthy
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe 'on #like!' do
|
140
|
+
subject do
|
141
|
+
stub_dribbble :post, '/shots/471756/like', DribbbleAPI::ShotLikeCreated
|
142
|
+
@shot.like!
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'return true' do
|
146
|
+
expect(subject).to be_truthy
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe 'on #unlike!' do
|
151
|
+
subject do
|
152
|
+
stub_dribbble :delete, '/shots/471756/like', DribbbleAPI::ShotLikeDeleted
|
153
|
+
@shot.unlike!
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'return true' do
|
157
|
+
expect(subject).to be_truthy
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe 'on #projects' do
|
162
|
+
subject do
|
163
|
+
stub_dribbble :get, '/shots/471756/projects', DribbbleAPI::ProjectsSuccess
|
164
|
+
@shot.projects
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'return a list of project' do
|
168
|
+
expect(subject.first).to be_a Dribbble::Project
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe 'on #rebounds' do
|
173
|
+
subject do
|
174
|
+
stub_dribbble :get, '/shots/471756/rebounds', DribbbleAPI::ShotsSuccess
|
175
|
+
@shot.rebounds
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'return a list of shots' do
|
179
|
+
expect(subject.first).to be_a Dribbble::Shot
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe 'on class' do
|
185
|
+
describe 'on #create' do
|
186
|
+
subject do
|
187
|
+
stub_dribbble :post, '/shots', DribbbleAPI::ShotAccepted
|
188
|
+
shot = {
|
189
|
+
title: 'Shot title',
|
190
|
+
desciption: 'Shot description',
|
191
|
+
image: File.new("#{Dir.pwd}/spec/support/fixtures/image.jpg", 'rb'),
|
192
|
+
tags: %w(tag1 tag2)
|
193
|
+
}
|
194
|
+
Dribbble::Shot.create 'valid_token', shot
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'create the shot' do
|
198
|
+
expect(subject).to be_truthy
|
199
|
+
expect(subject).to eq('471756')
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe 'on #update' do
|
204
|
+
subject do
|
205
|
+
stub_dribbble :get, '/shots/471756', DribbbleAPI::ShotSuccess
|
206
|
+
stub_dribbble :put, '/shots/471756', DribbbleAPI::ShotUpdated
|
207
|
+
bucket = {
|
208
|
+
name: 'Shot title',
|
209
|
+
description: 'Shot description'
|
210
|
+
}
|
211
|
+
Dribbble::Shot.update 'valid_token', 471_756, bucket
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'update bucket' do
|
215
|
+
expect(subject.title).to eq('Shot title')
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe 'on #delete' do
|
220
|
+
subject do
|
221
|
+
stub_dribbble :get, '/shots/471756', DribbbleAPI::ShotSuccess
|
222
|
+
stub_dribbble :delete, '/shots/471756', DribbbleAPI::ShotDeleted
|
223
|
+
Dribbble::Shot.delete 'valid_token', 471_756
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'return true' do
|
227
|
+
expect(subject).to eq(true)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe 'on #find' do
|
232
|
+
subject do
|
233
|
+
stub_dribbble :get, '/shots/471756', DribbbleAPI::ShotSuccess
|
234
|
+
Dribbble::Shot.find 'valid_token', 471_756
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'return a shot' do
|
238
|
+
expect(subject).to be_a Dribbble::Shot
|
239
|
+
expect(subject.id).to eq(471_756)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
describe 'on #all' do
|
244
|
+
subject do
|
245
|
+
stub_dribbble :get, '/shots', DribbbleAPI::ShotsSuccess
|
246
|
+
Dribbble::Shot.all 'valid_token'
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'return a shot' do
|
250
|
+
expect(subject.first).to be_a Dribbble::Shot
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|