posterous 0.2.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.
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/README.md +65 -0
- data/Rakefile +12 -0
- data/autotest/discovery.rb +1 -0
- data/bin/posterous +80 -0
- data/lib/posterous/association_proxy.rb +39 -0
- data/lib/posterous/connection.rb +52 -0
- data/lib/posterous/inheritable.rb +70 -0
- data/lib/posterous/model.rb +115 -0
- data/lib/posterous/models/comment.rb +6 -0
- data/lib/posterous/models/external_site.rb +6 -0
- data/lib/posterous/models/like.rb +6 -0
- data/lib/posterous/models/link.rb +6 -0
- data/lib/posterous/models/link_category.rb +8 -0
- data/lib/posterous/models/page.rb +6 -0
- data/lib/posterous/models/post.rb +9 -0
- data/lib/posterous/models/profile.rb +20 -0
- data/lib/posterous/models/site.rb +22 -0
- data/lib/posterous/models/subscriber.rb +6 -0
- data/lib/posterous/models/subscription.rb +10 -0
- data/lib/posterous/models/tag.rb +6 -0
- data/lib/posterous/models/user.rb +19 -0
- data/lib/posterous/version.rb +3 -0
- data/lib/posterous.rb +39 -0
- data/posterous.gemspec +28 -0
- data/spec/fixtures/metal.png +0 -0
- data/spec/helper.rb +11 -0
- data/spec/posterous.yml.sample +3 -0
- data/spec/unit/lib/posterous/association_proxy_spec.rb +40 -0
- data/spec/unit/lib/posterous/connection_spec.rb +41 -0
- data/spec/unit/lib/posterous/models/comment_spec.rb +53 -0
- data/spec/unit/lib/posterous/models/external_site_spec.rb +55 -0
- data/spec/unit/lib/posterous/models/like_spec.rb +45 -0
- data/spec/unit/lib/posterous/models/link_category_spec.rb +52 -0
- data/spec/unit/lib/posterous/models/link_spec.rb +53 -0
- data/spec/unit/lib/posterous/models/page_spec.rb +52 -0
- data/spec/unit/lib/posterous/models/post_spec.rb +52 -0
- data/spec/unit/lib/posterous/models/profile_spec.rb +32 -0
- data/spec/unit/lib/posterous/models/site_spec.rb +53 -0
- data/spec/unit/lib/posterous/models/subscriber_spec.rb +44 -0
- data/spec/unit/lib/posterous/models/user.rb +10 -0
- data/spec/unit/lib/posterous/models/user_spec.rb +20 -0
- data/spec/unit/lib/posterous_spec.rb +22 -0
- metadata +204 -0
Binary file
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
|
3
|
+
require 'posterous'
|
4
|
+
|
5
|
+
SAMPLE_CONFIG = File.open(File.dirname(__FILE__) + '/posterous.yml')
|
6
|
+
SAMPLE_IMAGE = File.open(File.dirname(__FILE__) + '/fixtures/metal.png')
|
7
|
+
Posterous.config = SAMPLE_CONFIG
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
end
|
11
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::AssociationProxy do
|
4
|
+
include Posterous
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@site = Site.find('primary')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#posts" do
|
11
|
+
it "without params should be a Posterous::Post" do
|
12
|
+
@site.posts.should == Posterous::Post
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should load posts with params" do
|
16
|
+
@site.posts(:page => 1).length.should be > 0
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
#describe "#parsed_resource_url" do
|
21
|
+
#it "builds the resource url" do
|
22
|
+
#@posts.first.parsed_resource_url.should == "/sites/#{@primary.id}/posts"
|
23
|
+
#end
|
24
|
+
#end
|
25
|
+
|
26
|
+
#describe "when chained" do
|
27
|
+
#it "should forward the finder opts" do
|
28
|
+
#@primary.posts.all.first.comments.all.should be_an Array
|
29
|
+
#end
|
30
|
+
#end
|
31
|
+
|
32
|
+
#describe "#posts.create" do
|
33
|
+
#it "creates a post for the site" do
|
34
|
+
##post = @primary.posts.create(:title => 'from proxy')
|
35
|
+
##post.title.should == 'from proxy'
|
36
|
+
##post.destroy
|
37
|
+
#end
|
38
|
+
#end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::Connection do
|
4
|
+
include Posterous::Connection
|
5
|
+
|
6
|
+
it "should handle GET requests" do
|
7
|
+
pending
|
8
|
+
get('/sites/primary').should be_an OpenStruct
|
9
|
+
get('/sites/primary/posts').should be_an Array
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should handle POST requests" do
|
13
|
+
pending
|
14
|
+
new_post = post('/sites/primary/posts', {
|
15
|
+
:post => {
|
16
|
+
:title => "from posterous",
|
17
|
+
:body => 'OMGWTFBBQ'
|
18
|
+
},
|
19
|
+
:media => { '0' => SAMPLE_IMAGE }
|
20
|
+
})
|
21
|
+
new_post.title.should == 'from posterous'
|
22
|
+
new_post.body_full.should =~ /OMGWTFBBQ/
|
23
|
+
new_post.media[2]['images'].length.should == 1
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should handle PUT requests" do
|
27
|
+
pending
|
28
|
+
new_post = put('/sites/primary/posts/27561123', {
|
29
|
+
:post => {
|
30
|
+
:title => "from posterous",
|
31
|
+
:body => 'OMGWTFBBQ'
|
32
|
+
},
|
33
|
+
:media => { '0' => SAMPLE_IMAGE }
|
34
|
+
})
|
35
|
+
new_post.title.should == 'from posterous'
|
36
|
+
new_post.body_full.should =~ /OMGWTFBBQ/
|
37
|
+
new_post.media[2]['images'].length.should == 1
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::Comment do
|
4
|
+
include Posterous
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@primary = Site.find('primary')
|
8
|
+
@post = @primary.posts.all.first
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#all" do
|
12
|
+
before(:all) do
|
13
|
+
@comments = @post.comments.all
|
14
|
+
end
|
15
|
+
|
16
|
+
it "finds the comments" do
|
17
|
+
@comments.should be_an Array
|
18
|
+
@comments.each{|p| p.id.should_not be_nil }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "CRUD" do
|
23
|
+
before(:all) do
|
24
|
+
@comment = @post.comments.create({:body => 'kittens are rad!'})
|
25
|
+
@comment_id = @comment.id
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#create" do
|
29
|
+
it "creates a comment" do
|
30
|
+
@comment.body.should == 'kittens are rad!'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#save" do
|
35
|
+
it "updates a comment" do
|
36
|
+
@comment.body = 'updated via commently'
|
37
|
+
@comment.save
|
38
|
+
@comment.reload.body.should == 'updated via commently'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#destroy" do
|
43
|
+
it "deletes a comment and raises a Connection error when not found" do
|
44
|
+
@comment.destroy
|
45
|
+
lambda {
|
46
|
+
@post.comments.find(@comment.id)
|
47
|
+
}.should raise_error Posterous::Connection::ConnectionError
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::ExternalSite do
|
4
|
+
include Posterous
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@primary = Site.find('primary')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#all" do
|
11
|
+
before(:all) do
|
12
|
+
@external_sites = @primary.external_sites.all
|
13
|
+
end
|
14
|
+
|
15
|
+
it "finds the external_sites" do
|
16
|
+
@external_sites.should be_an Array
|
17
|
+
@external_sites.each{|p| p.id.should_not be_nil }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "CRUD" do
|
22
|
+
before(:all) do
|
23
|
+
@external_site = @primary.external_sites.create({
|
24
|
+
:site_url => 'http://chrisburnett.tumblr.com',
|
25
|
+
:service_type => 'ExtTumblr',
|
26
|
+
:username => 'foo'
|
27
|
+
})
|
28
|
+
@external_site_id = @external_site.id
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#create" do
|
32
|
+
it "creates a external_site" do
|
33
|
+
@external_site.site_url.should == 'http://chrisburnett.tumblr.com'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
#describe "#save" do
|
38
|
+
#it "updates a external_site" do
|
39
|
+
#@external_site.site_url = 'http://chrisburnett.tumblr.com'
|
40
|
+
#@external_site.save
|
41
|
+
#@external_site.reload.blogid.should == 'bar'
|
42
|
+
#end
|
43
|
+
#end
|
44
|
+
|
45
|
+
describe "#destroy" do
|
46
|
+
it "deletes a external_site and raises a Connection error when not found" do
|
47
|
+
@external_site.destroy
|
48
|
+
lambda {
|
49
|
+
@primary.external_sites.find(@external_site.id)
|
50
|
+
}.should raise_error Posterous::Connection::ConnectionError
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::Like do
|
4
|
+
include Posterous
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@primary = Site.find('primary')
|
8
|
+
@post = @primary.posts.all.first
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#all" do
|
12
|
+
before(:all) do
|
13
|
+
@likes = @post.likes.all
|
14
|
+
end
|
15
|
+
|
16
|
+
it "finds the likes" do
|
17
|
+
@likes.should be_an Array
|
18
|
+
@likes.each{|p| p.id.should_not be_nil }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "CRUD" do
|
23
|
+
before(:all) do
|
24
|
+
@like = @post.likes.create
|
25
|
+
@like_id = @like.id
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#create" do
|
29
|
+
it "creates a like" do
|
30
|
+
@like.id.should_not be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#destroy" do
|
35
|
+
it "deletes a like and raises a Connection error when not found" do
|
36
|
+
@like.destroy
|
37
|
+
lambda {
|
38
|
+
@post.likes.find(@like.id)
|
39
|
+
}.should raise_error Posterous::Connection::ConnectionError
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::LinkCategory do
|
4
|
+
include Posterous
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@primary = Site.find('primary')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#all" do
|
11
|
+
before(:all) do
|
12
|
+
@link_categories = @primary.link_categories.all
|
13
|
+
end
|
14
|
+
|
15
|
+
it "finds the link_categories" do
|
16
|
+
@link_categories.should be_an Array
|
17
|
+
@link_categories.each{|p| p.id.should_not be_nil }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "CRUD" do
|
22
|
+
before(:all) do
|
23
|
+
@link_category = @primary.link_categories.create({:title => 'from posterous', :display_order => 1 })
|
24
|
+
@link_category_id = @link_category.id
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#create" do
|
28
|
+
it "creates a post" do
|
29
|
+
@link_category.title.should == 'from posterous'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#save" do
|
34
|
+
it "updates a link_category" do
|
35
|
+
@link_category.title = 'updated via posterous'
|
36
|
+
@link_category.save
|
37
|
+
@link_category.reload.title.should == 'updated via posterous'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#destroy" do
|
42
|
+
it "deletes a link_category and raises a Connection error when not found" do
|
43
|
+
@count = @primary.link_categories.all.count
|
44
|
+
@link_category.destroy
|
45
|
+
lambda {
|
46
|
+
@primary.link_categories.find(@link_category.id)
|
47
|
+
}.should raise_error Posterous::Connection::ConnectionError
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::Link do
|
4
|
+
include Posterous
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@primary = Site.find('primary')
|
8
|
+
@link_category = @primary.link_categories.all.first
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#all" do
|
12
|
+
before(:all) do
|
13
|
+
@links = @link_category.links.all
|
14
|
+
end
|
15
|
+
|
16
|
+
it "finds the links" do
|
17
|
+
@links.should be_an Array
|
18
|
+
@links.each{|p| p.id.should_not be_nil }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "CRUD" do
|
23
|
+
before(:all) do
|
24
|
+
@link = @link_category.links.create({:title => 'kittens are rad!', :url => 'http://google.com'})
|
25
|
+
@link_id = @link.id
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#create" do
|
29
|
+
it "creates a link" do
|
30
|
+
@link.title.should == 'kittens are rad!'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#save" do
|
35
|
+
it "updates a link" do
|
36
|
+
@link.title = 'updated via posterous'
|
37
|
+
@link.save
|
38
|
+
@link.reload.title.should == 'updated via posterous'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#destroy" do
|
43
|
+
it "deletes a link and raises a Connection error when not found" do
|
44
|
+
@link.destroy
|
45
|
+
lambda {
|
46
|
+
@link_category.links.find(@link.id)
|
47
|
+
}.should raise_error Posterous::Connection::ConnectionError
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::Page do
|
4
|
+
include Posterous
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@primary = Site.find('primary')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#all" do
|
11
|
+
before(:all) do
|
12
|
+
@pages = @primary.pages.all
|
13
|
+
end
|
14
|
+
|
15
|
+
it "finds the pages" do
|
16
|
+
@pages.should be_an Array
|
17
|
+
@pages.each{|p| p.id.should_not be_nil }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "CRUD" do
|
22
|
+
before(:all) do
|
23
|
+
@page = @primary.pages.create({:title => 'from posterous', :body => 'kittens are rad!'})
|
24
|
+
@page_id = @page.id
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#create" do
|
28
|
+
it "creates a post" do
|
29
|
+
@page.title.should == 'from posterous'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#save" do
|
34
|
+
it "updates a page" do
|
35
|
+
@page.title = 'updated via posterous'
|
36
|
+
@page.save
|
37
|
+
@page.reload.title.should == 'updated via posterous'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#destroy" do
|
42
|
+
it "deletes a page and raises a Connection error when not found" do
|
43
|
+
@count = @primary.pages.all.count
|
44
|
+
@page.destroy
|
45
|
+
lambda {
|
46
|
+
@primary.pages.find(@page.id)
|
47
|
+
}.should raise_error Posterous::Connection::ConnectionError
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::Post do
|
4
|
+
include Posterous
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@primary = Site.find('primary')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#all" do
|
11
|
+
before(:all) do
|
12
|
+
@posts = @primary.posts.all
|
13
|
+
end
|
14
|
+
|
15
|
+
it "finds the posts" do
|
16
|
+
@posts.should be_an Array
|
17
|
+
@posts.each{|p| p.id.should_not be_nil }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "CRUD" do
|
22
|
+
before(:all) do
|
23
|
+
@post = @primary.posts.create({:title => 'from posterous', :body => 'kittens are rad!'})
|
24
|
+
@post_id = @post.id
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#create" do
|
28
|
+
it "creates a post" do
|
29
|
+
@post.title.should == 'from posterous'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#save" do
|
34
|
+
it "updates a post" do
|
35
|
+
@post.title = 'updated via posterous'
|
36
|
+
@post.save
|
37
|
+
@post.reload.title.should == 'updated via posterous'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#destroy" do
|
42
|
+
it "deletes a post and raises a Connection error when not found" do
|
43
|
+
@count = @primary.posts.all.count
|
44
|
+
@post.destroy
|
45
|
+
lambda {
|
46
|
+
@primary.posts.find(@post.id)
|
47
|
+
}.should raise_error Posterous::Connection::ConnectionError
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::Profile do
|
4
|
+
include Posterous
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@site = Site.find('primary')
|
8
|
+
@site.profile.destroy rescue nil
|
9
|
+
@profile = @site.profile.create(:group_profile_name => 'some profile name')
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#load" do
|
13
|
+
it "should get the profile" do
|
14
|
+
@profile.group_profile_name.should == 'some profile name'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#save" do
|
19
|
+
it "should update the profile" do
|
20
|
+
@profile.body = 'updated'
|
21
|
+
@profile.save
|
22
|
+
@profile.body.should == 'updated'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#destroy" do
|
27
|
+
it "destroys the profile" do
|
28
|
+
@profile.destroy
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::Site do
|
4
|
+
include Posterous
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@primary = Site.find('primary')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should find the primary site" do
|
11
|
+
@primary.name.should =~ /postertester/
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#all" do
|
15
|
+
it "finds all the users sites" do
|
16
|
+
@sites = Site.all(:page => 1)
|
17
|
+
@sites.should be_an Array
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "CRUD" do
|
22
|
+
|
23
|
+
before(:all) do
|
24
|
+
@site = Site.create(:hostname => "newposterous#{Time.now.to_i}")
|
25
|
+
@site_id = @site.id
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#create" do
|
29
|
+
it "creates the site" do
|
30
|
+
@site.name.should =~ /posterous/
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#save" do
|
35
|
+
it "updates a site" do
|
36
|
+
@site.is_private = true
|
37
|
+
@site.save
|
38
|
+
@site.reload.is_private.should be_true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#destroy" do
|
43
|
+
it "deletes the site" do
|
44
|
+
@site.destroy.should be_nil
|
45
|
+
lambda {
|
46
|
+
Site.find(@site_id)
|
47
|
+
}.should raise_error Posterous::Connection::ConnectionError
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
FAKE_USER_ID = 637118
|
4
|
+
|
5
|
+
describe Posterous::Subscriber do
|
6
|
+
include Posterous
|
7
|
+
|
8
|
+
before(:all) do
|
9
|
+
@primary = Site.find('primary')
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#all" do
|
13
|
+
before(:all) do
|
14
|
+
@subscribers = @primary.subscribers.all
|
15
|
+
end
|
16
|
+
|
17
|
+
it "finds the subscribers" do
|
18
|
+
@subscribers.should be_an Array
|
19
|
+
@subscribers.each{|p| p.id.should_not be_nil }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "CRUD" do
|
24
|
+
before(:all) do
|
25
|
+
@subscriber = @primary.subscribers.create({:user_id => FAKE_USER_ID})
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#create" do
|
29
|
+
it "creates a subscriber" do
|
30
|
+
@primary.subscribers.all.first.id.should == FAKE_USER_ID
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#destroy" do
|
35
|
+
it "deletes a subscriber and raises a Connection error when not found" do
|
36
|
+
@primary.subscribers.first.destroy
|
37
|
+
lambda {
|
38
|
+
@primary.subscribers.find(FAKE_USER_ID)
|
39
|
+
}.should raise_error Posterous::Connection::ConnectionError
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous::Site do
|
4
|
+
include Posterous
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@user = User.me
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should find me" do
|
11
|
+
@user.nickname.should =~ /postertester/
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#favorites" do
|
15
|
+
it "finds all the users favorites" do
|
16
|
+
@user.favorites.should be_an Array
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Posterous do
|
4
|
+
describe "#config=" do
|
5
|
+
describe "with hash" do
|
6
|
+
before do
|
7
|
+
Posterous.config = {'user' => 'me@foo.com','passsword' => 'foobar'}
|
8
|
+
end
|
9
|
+
it "should set the config" do
|
10
|
+
Posterous.config.should be_a Hash
|
11
|
+
end
|
12
|
+
end
|
13
|
+
describe "with file" do
|
14
|
+
before do
|
15
|
+
Posterous.config = SAMPLE_CONFIG
|
16
|
+
end
|
17
|
+
it "should set the config" do
|
18
|
+
Posterous.config.should be_a Hash
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|