Sha256: 5aae6634be9beaef8995f0145ef4a3fa0ba1a5a9d24cba0cc2ccd87f5e5c13b1
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require 'pry' describe WP::API do context "raw HTTP request" do let(:response) { HTTParty.get('http://wp.example.com/wp-json/posts').body } let(:file) { support_file('posts.json') } subject { parse_json(response) } it { should eq parse_json(file) } end context "/wp-json/posts" do let(:client) { WP::API['wp.example.com'] } subject { client.posts } it "should have size of 2" do expect(subject.size).to eq 2 end it "should have correct IDs" do expect(subject.collect(&:id)).to match_array [1, 2] end it "should have authors" do expect(subject.collect(&:author).size).to eq 2 end context "first post" do subject do client.posts.find {|p| p.id == 1 } end it "should have boolean methods" do expect(subject.sticky).to eq true expect(subject.sticky?).to eq true end it("should have a title") { expect(subject.title).to eq "First post" } context "author" do let(:author) { subject.author } it "should be converted to author class" do expect(author).to be_a WP::API::Author end end context "meta" do let(:meta) { subject.meta } it "should not be converted to a class" do expect(meta).to be_a Hash end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wp-api-0.0.2 | spec/endpoints/posts_spec.rb |