tumblr_client 0.6.11 → 0.7.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.
@@ -0,0 +1,186 @@
1
+ require 'spec_helper'
2
+
3
+ describe Tumblr::Post do
4
+
5
+ let(:client) { Tumblr::Client.new }
6
+ let(:blog_name) { 'blogname' }
7
+ let(:file_path) { '/path/to/the/file' }
8
+ let(:file_data) { 'lol cats' }
9
+ let(:source) { 'the source' }
10
+ let(:post_id) { 42 }
11
+
12
+ describe :delete do
13
+
14
+ context 'when deleting a post' do
15
+
16
+ before do
17
+ client.should_receive(:post).once.with("v2/blog/#{blog_name}/post/delete", {
18
+ :id => post_id
19
+ })
20
+ end
21
+
22
+ it 'should setup a delete properly' do
23
+ client.delete blog_name, post_id
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+ describe :edit do
31
+
32
+ it 'should make the correct call' do
33
+ client.should_receive(:post).once.with("v2/blog/#{blog_name}/post/edit", {
34
+ :id => 123
35
+ }).and_return('response')
36
+ r = client.edit blog_name, :id => 123
37
+ r.should == 'response'
38
+ end
39
+
40
+ end
41
+
42
+ describe :reblog do
43
+
44
+ it 'should make the correct call' do
45
+ client.should_receive(:post).once.with("v2/blog/#{blog_name}/post/reblog", {
46
+ :id => 123
47
+ }).and_return('response')
48
+ r = client.reblog blog_name, :id => 123
49
+ r.should == 'response'
50
+ end
51
+
52
+ end
53
+
54
+ # Simple post types
55
+ [:quote, :text, :link, :chat].each do |type|
56
+
57
+ field = type == :quote ? 'quote' : 'title' # uglay
58
+
59
+ describe type do
60
+
61
+ context 'when passing an option which is not allowed' do
62
+
63
+ it 'should raise an error' do
64
+ lambda {
65
+ client.send type, blog_name, :not => 'an option'
66
+ }.should raise_error ArgumentError
67
+ end
68
+
69
+ end
70
+
71
+ context 'when passing valid data' do
72
+
73
+ before do
74
+ @val = 'hello world'
75
+ client.should_receive(:post).once.with("v2/blog/#{blog_name}/post", {
76
+ field.to_sym => @val,
77
+ :type => type.to_s
78
+ }).and_return('response')
79
+ end
80
+
81
+ it 'should set up the call properly' do
82
+ r = client.send type, blog_name, field.to_sym => @val
83
+ r.should == 'response'
84
+ end
85
+
86
+ end
87
+
88
+ end
89
+
90
+ end
91
+
92
+ # Complex post types
93
+ [:photo, :audio, :video].each do |type|
94
+
95
+ describe type do
96
+
97
+ context 'when passing an option which is not allowed' do
98
+
99
+ it 'should raise an error' do
100
+ lambda {
101
+ client.send type, blog_name, :not => 'an option'
102
+ }.should raise_error ArgumentError
103
+ end
104
+
105
+ end
106
+
107
+ context 'when passing data different ways' do
108
+
109
+ before do
110
+ fakefile = OpenStruct.new :read => file_data
111
+ File.stub(:open).with(file_path, 'rb').and_return(fakefile)
112
+ client.should_receive(:post).once.with("v2/blog/#{blog_name}/post", {
113
+ 'data[0]' => file_data,
114
+ :type => type.to_s
115
+ }).and_return('post')
116
+ end
117
+
118
+ it 'should be able to pass data as an array of filepaths' do
119
+ r = client.send type, blog_name, :data => [file_path]
120
+ r.should == 'post'
121
+ end
122
+
123
+ it 'should be able to pass data as a single filepath' do
124
+ r = client.send type, blog_name, :data => file_path
125
+ r.should == 'post'
126
+ end
127
+
128
+ it 'should be able to pass an array of raw data' do
129
+ r = client.send type, blog_name, :data_raw => [file_data]
130
+ r.should == 'post'
131
+ end
132
+
133
+ it 'should be able to pass raw data' do
134
+ r = client.send type, blog_name, :data_raw => file_data
135
+ r.should == 'post'
136
+ end
137
+
138
+ end
139
+
140
+ # Only photos have source
141
+ if type == :photo
142
+
143
+ context 'when passing source different ways' do
144
+
145
+ it 'should be able to be passed as a string' do
146
+ client.should_receive(:post).once.with("v2/blog/#{blog_name}/post", {
147
+ :source => source,
148
+ :type => type.to_s
149
+ })
150
+ client.send type, blog_name, :source => source
151
+ end
152
+
153
+ it 'should be able to be passed as an array' do
154
+ client.should_receive(:post).once.with("v2/blog/#{blog_name}/post", {
155
+ 'source[0]' => source,
156
+ 'source[1]' => source,
157
+ :type => type.to_s
158
+ })
159
+ client.send type, blog_name, :source => [source, source]
160
+ end
161
+
162
+ end
163
+
164
+ end
165
+
166
+ context 'when passing colliding options' do
167
+
168
+ it 'should get an error when passing data & source' do
169
+ lambda {
170
+ client.send type, blog_name, :data => 'hi', :source => 'bye'
171
+ }.should raise_error ArgumentError
172
+ end
173
+
174
+ it 'should get an error when passing data & raw_data' do
175
+ lambda {
176
+ client.send type, blog_name, :raw_data => 'hi', :data => 'bye'
177
+ }.should raise_error ArgumentError
178
+ end
179
+
180
+ end
181
+
182
+ end
183
+
184
+ end
185
+
186
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Tumblr::Tagged do
4
+
5
+ let(:client) { Tumblr::Client.new }
6
+ let(:consumer_key) { 'consumer' }
7
+ let(:tag) { 'helloworld' }
8
+
9
+ before do
10
+ Tumblr.configure do |c|
11
+ c.consumer_key = consumer_key
12
+ end
13
+ end
14
+
15
+ describe :tagged do
16
+
17
+ before do
18
+ client.should_receive(:get).once.with('v2/tagged', {
19
+ :tag => tag,
20
+ :api_key => consumer_key
21
+ }).and_return('response')
22
+ end
23
+
24
+ it 'should setup the request properly' do
25
+ r = client.tagged tag
26
+ r.should == 'response'
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,114 @@
1
+ require 'spec_helper'
2
+
3
+ describe Tumblr::User do
4
+
5
+ let(:client) { Tumblr::Client.new }
6
+
7
+ describe :info do
8
+
9
+ it 'should make the request properly' do
10
+ client.should_receive(:get).with('v2/user/info').and_return('response')
11
+ r = client.info
12
+ r.should == 'response'
13
+ end
14
+
15
+ end
16
+
17
+ describe :dashboard do
18
+
19
+ context 'when using options that are not allowed' do
20
+
21
+ it 'should raise an error' do
22
+ lambda {
23
+ client.dashboard :not => 'an option'
24
+ }.should raise_error ArgumentError
25
+ end
26
+
27
+ end
28
+
29
+ context 'when using valid options' do
30
+
31
+ it 'should make the correct call' do
32
+ client.should_receive(:get).with('v2/user/dashboard', {
33
+ :limit => 25
34
+ }).and_return('response')
35
+ r = client.dashboard :limit => 25
36
+ r.should == 'response'
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+
43
+ # These two are very similar
44
+ [:following, :likes].each do |type|
45
+
46
+ describe type do
47
+
48
+ context 'with defaults' do
49
+
50
+ it 'should make the reqest properly' do
51
+ client.should_receive(:get).with("v2/user/#{type}", {}).
52
+ and_return('response')
53
+ r = client.send type
54
+ r.should == 'response'
55
+ end
56
+
57
+ end
58
+
59
+ context 'with custom limit & offset' do
60
+
61
+ it 'should make the reqest properly' do
62
+ client.should_receive(:get).with("v2/user/#{type}", {
63
+ :limit => 10,
64
+ :offset => 5
65
+ }).and_return('response')
66
+ r = client.send type, :offset => 5, :limit => 10
67
+ r.should == 'response'
68
+ end
69
+
70
+ end
71
+
72
+ end
73
+
74
+ end
75
+
76
+ # Like and unlike are similar
77
+ [:like, :unlike].each do |type|
78
+
79
+ describe type do
80
+
81
+ it 'should make the request properly' do
82
+ id = 123
83
+ reblog_key = 'hello'
84
+ client.should_receive(:post).with("v2/user/#{type}", {
85
+ :id => id,
86
+ :reblog_key => reblog_key
87
+ }).and_return('response')
88
+ r = client.send type, id, reblog_key
89
+ r.should == 'response'
90
+ end
91
+
92
+ end
93
+
94
+ end
95
+
96
+ # Follow and unfollow are similar
97
+ [:follow, :unfollow].each do |type|
98
+
99
+ describe type do
100
+
101
+ it 'should make the request properly' do
102
+ url = 'some url'
103
+ client.should_receive(:post).with("v2/user/#{type}", {
104
+ :url => url
105
+ }).and_return('response')
106
+ r = client.send type, url
107
+ r.should == 'response'
108
+ end
109
+
110
+ end
111
+
112
+ end
113
+
114
+ end
@@ -0,0 +1,7 @@
1
+ if ENV['COV'] == '1'
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+ end
5
+
6
+ require 'ostruct'
7
+ require_relative '../lib/tumblr_client'
@@ -1,13 +1,15 @@
1
1
  # encoding: utf-8
2
+ require File.join(File.dirname(__FILE__), 'lib/tumblr/version')
2
3
 
3
4
  Gem::Specification.new do |gem|
4
5
  gem.add_dependency 'faraday', '>= 0.8'
5
- gem.add_dependency 'faraday_middleware'
6
+ gem.add_dependency 'faraday_middleware', '>= 0.8'
6
7
  gem.add_dependency 'json'
7
8
  gem.add_dependency 'oauth'
8
9
  gem.add_development_dependency 'rake'
9
10
  gem.add_development_dependency 'rspec'
10
11
  gem.add_development_dependency 'webmock'
12
+ gem.add_development_dependency 'simplecov'
11
13
  gem.authors = ["John Bunting"]
12
14
  gem.description = %q{A Ruby wrapper for the Tumblr v2 API}
13
15
  gem.email = ['codingjester@gmail.com']
@@ -19,5 +21,5 @@ Gem::Specification.new do |gem|
19
21
  gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
20
22
  gem.summary = %q{Tumblr API wrapper}
21
23
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
- gem.version = "0.6.11"
24
+ gem.version = Tumblr::VERSION
23
25
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 6
8
- - 11
9
- version: 0.6.11
7
+ - 7
8
+ - 0
9
+ version: 0.7.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Bunting
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2013-02-02 00:00:00 -05:00
17
+ date: 2013-02-05 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -39,7 +39,8 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  segments:
41
41
  - 0
42
- version: "0"
42
+ - 8
43
+ version: "0.8"
43
44
  type: :runtime
44
45
  version_requirements: *id002
45
46
  - !ruby/object:Gem::Dependency
@@ -102,6 +103,18 @@ dependencies:
102
103
  version: "0"
103
104
  type: :development
104
105
  version_requirements: *id007
106
+ - !ruby/object:Gem::Dependency
107
+ name: simplecov
108
+ prerelease: false
109
+ requirement: &id008 !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ type: :development
117
+ version_requirements: *id008
105
118
  description: A Ruby wrapper for the Tumblr v2 API
106
119
  email:
107
120
  - codingjester@gmail.com
@@ -113,9 +126,8 @@ extra_rdoc_files: []
113
126
 
114
127
  files:
115
128
  - .gitignore
116
- - .path
129
+ - .travis.yml
117
130
  - Gemfile
118
- - Gemfile.lock
119
131
  - LICENSE.md
120
132
  - README.md
121
133
  - Rakefile
@@ -130,8 +142,15 @@ files:
130
142
  - lib/tumblr/request/oauth.rb
131
143
  - lib/tumblr/tagged.rb
132
144
  - lib/tumblr/user.rb
145
+ - lib/tumblr/version.rb
133
146
  - lib/tumblr_client.rb
134
- - tumblr.gemspec
147
+ - spec/examples/blog_spec.rb
148
+ - spec/examples/client_spec.rb
149
+ - spec/examples/post_spec.rb
150
+ - spec/examples/tagged_spec.rb
151
+ - spec/examples/user_spec.rb
152
+ - spec/spec_helper.rb
153
+ - tumblr_client.gemspec
135
154
  has_rdoc: true
136
155
  homepage: http://github.com/codingjester/tumblr_client
137
156
  licenses: []
@@ -164,5 +183,10 @@ rubygems_version: 1.3.6
164
183
  signing_key:
165
184
  specification_version: 3
166
185
  summary: Tumblr API wrapper
167
- test_files: []
168
-
186
+ test_files:
187
+ - spec/examples/blog_spec.rb
188
+ - spec/examples/client_spec.rb
189
+ - spec/examples/post_spec.rb
190
+ - spec/examples/tagged_spec.rb
191
+ - spec/examples/user_spec.rb
192
+ - spec/spec_helper.rb