WpApiClient::Collection: Added accessor to get total pages for a cust…#11
WpApiClient::Collection: Added accessor to get total pages for a cust…#11gadikotamohan wants to merge 3 commits intoduncanjbrown:masterfrom
Conversation
…om post_type posts
|
@duncanjbrown Could review ? |
|
Thank you! Would you mind adding a spec? |
|
@duncanjbrown added spec please review.. |
|
|
@duncanjbrown Please find rspec result in https://travis-ci.org/gadikotamohan/wp-api-client |
duncanjbrown
left a comment
There was a problem hiding this comment.
Thank you so much — Travis too! 🙌
Couple of minor comments.
| 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 |
There was a problem hiding this comment.
This spec has the same name as the below one and I think it's redundant?
| 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 |
There was a problem hiding this comment.
The right hand side is quite magical here. These values are hardcoded in the VCR cassettes: I believe X-WP-TOTAL is 100 and X-WP-TOTALPAGES is 10.
My whole testing approach here was flawed, but I think the least worst thing would be to put literals on the right hand side here, like this?
expect(@collection.total_pages).to eq(10)
expect(@collection.total_available).to eq(100)
|
@duncanjbrown made suggested changes to code and please find rpsec status in https://travis-ci.org/gadikotamohan/wp-api-client/builds/556100532 (all specs are green) |
|
Hi @duncanjbrown got a chance to look into this ? |
|
hi @duncanjbrown, have you got a chance to look into this PR ? |
WpApiClient::Collection: Added accessor to get total pages for a custom post_type posts