Skip to content

Commit

Permalink
Final cleanup, version bump to 1.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach Feldman committed Jun 5, 2013
1 parent dacb112 commit 61d9fba
Show file tree
Hide file tree
Showing 18 changed files with 266 additions and 344 deletions.
5 changes: 0 additions & 5 deletions .document

This file was deleted.

3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
*.tmp
*.swp
wordpress.yml
*.swp
62 changes: 0 additions & 62 deletions README.rdoc

This file was deleted.

2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task :default => :spec
task :default => :spec
2 changes: 0 additions & 2 deletions lib/rubypress.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# encoding: UTF-8

$LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__))

require 'xmlrpc/client'
Expand Down
4 changes: 2 additions & 2 deletions lib/rubypress/client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'yaml'
require 'erb'
require_relative "post"
require_relative "posts"
require_relative "taxonomies"
require_relative "media"
require_relative "comments"
Expand Down Expand Up @@ -53,7 +53,7 @@ def execute(method, options)
end
end

include Post
include Posts
include Taxonomies
include Media
include Comments
Expand Down
2 changes: 1 addition & 1 deletion lib/rubypress/post.rb → lib/rubypress/posts.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Post
module Posts

def getPost(options = {})
default_options = {
Expand Down
Binary file removed rubypress-0.0.2.gem
Binary file not shown.
12 changes: 6 additions & 6 deletions rubypress.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ $LOAD_PATH.push File.expand_path("../lib", __FILE__)

Gem::Specification.new do |s|
s.name = "rubypress"
s.version = "0.0.2"
s.version = "1.0.0"
s.platform = Gem::Platform::RUBY
s.author = "Daniel Collis-Puro"
s.email = ["djcp@thoughtbot.com"]
s.homepage = "https://github.com/djcp/ruby-wordpress-api"
s.summary = "Easily access WordPress installations."
s.description = "Easily push to WordPress installations through the WordPress XML-RPC API."
s.author = "Zach Feldman"
s.email = ["zachfeldman@gmail.com"]
s.homepage = "https://github.com/zachfeldman/ruby-wordpress-api"
s.summary = "Easily access WordPress installations through the WordPress XML-RPC API."
s.description = "Easily push to WordPress installations through the WordPress XML-RPC API. This gem exactly mirrors the functionality provided by the WordPress XML-RPC API."

s.required_ruby_version = ">= 1.9.2"

Expand Down
17 changes: 17 additions & 0 deletions spec/cassettes/options_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
describe "#options" do

let(:options){ { "blog_tagline" => "This is a great tagline" } }

it "#getOptions" do
VCR.use_cassette("getOptions") do
CLIENT.getOptions.should include("time_zone" => {"desc"=>"Time Zone", "readonly"=>false, "value"=>"0"})
end
end

it "#setOptions" do
VCR.use_cassette("setOptions") do
CLIENT.setOptions({:options => options}).should include("blog_tagline" => {"desc"=>"Site Tagline", "readonly"=>false, "value"=>"This is a great tagline"})
end
end

end
35 changes: 35 additions & 0 deletions spec/cassettes/users_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
describe "#users" do

let(:edited_profile_content){ {:first_name => "Johnson"} }

it "#getUsersBlogs" do
VCR.use_cassette("getUsersBlogs") do
CLIENT.getUsersBlogs[0].should include("blogid")
end
end

it "#getUsers" do
VCR.use_cassette("getUsers") do
CLIENT.getUsers[0].should include("user_id")
end
end

it "#getProfile" do
VCR.use_cassette("getProfile") do
CLIENT.getProfile.should include("user_id")
end
end

it "#editProfile" do
VCR.use_cassette("editProfile") do
CLIENT.editProfile({:content => edited_profile_content}).should eq(true)
end
end

it "#getAuthors" do
VCR.use_cassette("getAuthors") do
CLIENT.getAuthors[0].should include("user_id")
end
end

end
14 changes: 14 additions & 0 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require_relative 'spec_helper'

describe "#client" do

it '#initialize' do
CLIENT.class.should == Rubypress::Client
end

it "#execute" do
Rubypress::Client.any_instance.stub_chain(:connection, :call){ [{"user_id"=>"46917508", "user_login"=>"johnsmith", "display_name"=>"john"}, {"user_id"=>"33333367", "user_login"=>"johnsmith", "display_name"=>"johnsmith"}] }
expect(CLIENT.execute("wp.getAuthors", {})).to eq( [{"user_id"=>"46917508", "user_login"=>"johnsmith", "display_name"=>"john"}, {"user_id"=>"33333367", "user_login"=>"johnsmith", "display_name"=>"johnsmith"}] )
end

end
49 changes: 49 additions & 0 deletions spec/comments_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
describe "#comments" do

let(:post_id){ 134 }
let(:comment_id){ 1 }
let(:comment){ {:comment_parent => "", :content => "This is a test thing here.", :author => "John Adams", :author_url => "http://johnadamsforpresidentnow.com", :author_email => "[email protected]"} }

it "#getCommentCount" do
VCR.use_cassette("getCommentCount") do
CLIENT.getCommentCount({:post_id => post_id}).should include("approved" => "1")
end
end

it "#getComment" do
VCR.use_cassette("getComment") do
CLIENT.getComment({:comment_id => comment_id}).should include("comment_id" => "1")
end
end

it "#getComments" do
VCR.use_cassette("getComments") do
CLIENT.getComments[0].should include("post_id" => post_id.to_s)
end
end

it "#newComment" do
VCR.use_cassette("newComment") do
CLIENT.newComment({:post_id => post_id, :comment => comment}).class.should eq(Fixnum)
end
end

it "#editComment" do
VCR.use_cassette("editComment") do
CLIENT.editComment({:comment_id => comment_id, :comment => comment}).class.should eq(TrueClass)
end
end

it "#deleteComment" do
VCR.use_cassette("deleteComment") do
CLIENT.deleteComment({:comment_id => comment_id}).class.should eq(TrueClass)
end
end

it "#getCommentStatusList" do
VCR.use_cassette("getCommentStatusList") do
CLIENT.getCommentStatusList.should include("hold" => "Unapproved")
end
end

end
24 changes: 24 additions & 0 deletions spec/media_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
describe "#media" do

let(:attachment_id){ 129 }
let(:file){ {:id => "", :name => "test_file.png", :bits => '"\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00\n\x00\x00\x00\n\b\x03\x00\x00\x00\xBA\xEC?\x8F\x00\x00\x00\x19tEXtSoftware\x00Adobe ImageReadyq\xC9e<\x00\x00\x00\fPLTE\xAC\xAC\xAC\x87\x87\x87aaa\xFF\xFF\xFF\xF2\xB3\r\x90\x00\x00\x00\x04tRNS\xFF\xFF\xFF\x00@*\xA9\xF4\x00\x00\x004IDATx\xDAl\x8D1\x12\x00 \f\xC2\x02\xFE\xFF\xCF\x82\x0Eu0\x03\x97r\xD7\x96U\xDC\xE0\x98;\xE1@\xDB$ \xA7\xACJ\x1F\xD5h\xD0]{\x8E\xCD\x8B-\xC0\x00/\x88\x00\xDF$\xC9\x85\\\x00\x00\x00\x00IEND\xAEB`\x82"'}}

it "#getMediaItem" do
VCR.use_cassette("getMediaItem") do
CLIENT.getMediaItem({:attachment_id => attachment_id}).should include("title" => "8yI9E3I")
end
end

it "#getMediaLibrary" do
VCR.use_cassette("getMediaLibrary") do
CLIENT.getMediaLibrary[0].should include("attachment_id"=>"129")
end
end

it "#uploadFile" do
VCR.use_cassette("uploadFile") do
CLIENT.uploadFile({:data => file}).should include("url" => "http://cthisisatest.files.wordpress.com/2013/06/test_file.png")
end
end

end
61 changes: 61 additions & 0 deletions spec/posts_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
describe "#post" do

let(:post_id){ 134 }
let(:post){ {:post_type => "post", :post_status => "draft", :post_title => "5 Ways to Know You're Cool", :post_content => "I don't always write tests, but when I do, I use RSpec."} }
let(:post_id_to_delete){ 137 }

it "#getPost" do
VCR.use_cassette("getPost") do
CLIENT.getPost({:post_id => post_id}).should include("post_id" => "134")
end
end

it "#getPosts" do
VCR.use_cassette("getPosts") do
CLIENT.getPosts[0].should include("post_id")
end
end

it "#newPost" do
VCR.use_cassette("newPost") do
CLIENT.newPost({:content => post}).should =~ STRING_NUMBER_REGEX
end
end

it "#editPost" do
VCR.use_cassette("editPost") do
CLIENT.editPost({:post_id => post_id, :content => post}).should eq(true)
end
end

it "#deletePost" do
VCR.use_cassette("deletePost") do
CLIENT.deletePost({:post_id => post_id_to_delete}).should eq(true)
end
end

it "#getPostType" do
VCR.use_cassette("getPostType") do
CLIENT.getPostType({:post_type_name => "post"}).should include("name"=>"post")
end
end

it "#getPostTypes" do
VCR.use_cassette("getPostTypes") do
CLIENT.getPostTypes.should include("page")
end
end

it "#getPostFormats" do
VCR.use_cassette("getPostFormats") do
CLIENT.getPostFormats.should include("image" => "Image")
end
end

it "#getPostStatusList" do
VCR.use_cassette("getPostStatusList") do
CLIENT.getPostStatusList.should include("standard"=>"Standard")
end
end

end
Loading

0 comments on commit 61d9fba

Please sign in to comment.