Skip to content

Commit

Permalink
RSpec
Browse files Browse the repository at this point in the history
WpApiClient::Collection: Added accessor to get total pages for a custom post_type posts
  • Loading branch information
Mohan Raja Gadikota authored and Mohan Gadikota committed Jul 8, 2019
1 parent e2e61e9 commit 3ecc7fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
language: ruby
rvm:
- 2.3.0
- 2.5.3
before_install: gem install bundler -v 1.11.2
script:
- WP_VERSION=4.4 bundle exec rspec
- WP_VERSION=4.5 bundle exec rspec
- WP_VERSION=4.5.3 bundle exec rspec
- WP_VERSION=4.5.3_b13 bundle exec rspec
- WP_VERSION=4.7 bundle exec rspec
- WP_VERSION=4.7.2 bundle exec rspec
cache: bundler
10 changes: 10 additions & 0 deletions spec/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
expect(@collection.count).to eq 9
end

it "should respond to total_pages and total_available" do
expect(@collection).to respond_to(:total_pages)
expect(@collection).to respond_to(:total_available)
end

it "should respond to total_pages and total_available" do
expect(@collection.total_pages).to eq(@api.instance_variable_get("@headers")["X-Wp-Totalpages"].to_i)
expect(@collection.total_available).to eq(@api.instance_variable_get("@headers")["X-Wp-Total"].to_i)
end

it "throws an error when it tries to parse an error response" do
expect {
WpApiClient::Collection.new([{"code"=>"rest_forbidden", "message"=>"You don't have permission to do this.", "data"=>{"status"=>403}}])
Expand Down

0 comments on commit 3ecc7fe

Please sign in to comment.