Sha256: 759f00ae86b818deb9a8d21c3370eafce9cebf11463080ec27c49f5f72d949fc

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'helper'

describe Pinboard::Post do

  describe ".all" do
    let(:posts) { Pinboard::Post.all(auth_params) }

    before do
      stub_get("posts/all").
        to_return(:body => fixture("posts_all.xml"),
                  :headers => { 'content-type' => 'text/xml' })
    end

    it "returns a collection" do
      posts.count.should == 2
    end

    it "loads posts with valid attributes" do
      post = posts.first
      post.href.should == "http://foo.com/"
      post.description.should == "Foo!"
      post.tag.should == ["foo", "bar"]
      post.time.should == Time.parse('Tue Jul 26 17:52:04 UTC 2011')
    end
  end
  
  describe ".new" do
    let(:post) {
      Pinboard::Post.new(
        :href => 'http://foo.com',
        :description => 'Foo!',
        :tag => 'rspec pinboard',
        :time => Time.mktime(2011, 1, 1))
    }

    it "initializes attributes" do
      post.href.should        == 'http://foo.com'
      post.description.should == 'Foo!'
      post.tag.should         == %w{rspec pinboard}
      post.time.should        == Time.mktime(2011, 1, 1)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pinboard-0.0.3 spec/pinboard/post_spec.rb
pinboard-0.0.2 spec/pinboard/post_spec.rb