public
Description: Ruby library for the del.icio.us API
Clone URL: git://github.com/technicalpickles/deliciousr.git
deliciousr / test / deliciousr / v1 / posts_test.rb
100644 74 lines (58 sloc) 2.274 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require File.dirname(__FILE__) + "/../../test_helper.rb"
 
module Deliciousr
  module V1
    class PostsTest < Test::Unit::TestCase
      context 'LastUpdated' do
        setup do
          @api_call = Deliciousr::V1::Posts::LastUpdated.new(stub)
          @expected_date = example_last_updated_posts_date
        end
        
        method_should_be :posts
        action_should_be :update
        should_have_required_parameters :none
        should_have_optional_parameters :none
        should_build_request_path '/v1/posts/update'
        
        should 'parse response as a date' do
          root = build_root_for(example_last_updated_posts_response)
          actual_date = @api_call.parse(root)
          
          assert {@expected_date == actual_date}
        end
        
 
      end
      
      context 'Recent' do
        setup do
          @api_call = Deliciousr::V1::Posts::Recent.new(stub)
          @root = build_root_for(example_recent_posts_response)
        end
        
        method_should_be :posts
        action_should_be :recent
        should_have_required_parameters :none
        should_have_optional_parameters :tag, :count
        
        context 'without any optional parameters' do
          should 'parse 2 posts' do
            posts = @api_call.parse(@root)
          
            assert {posts.size == 2}
          end
        
          context 'first parsed post' do
            setup do
              @post = @api_call.parse(@root).first
            end
          
            should 'have href be http://www.weather.com' do
              assert {@post.href == 'http://www.weather.com/'}
            end
          
            should 'have description be weather.com' do
              assert {@post.description == 'weather.com'}
            end
          
            should 'have weather and reference tags' do
              assert {@post.tags.size == 2}
              assert {@post.tags.first.name == 'weather'}
              assert {@post.tags.last.name == 'reference'}
            end
          
            should_eventually 'have date be 2005-11-29T20:30:47Z' do
              assert {@post.date == DateTime.parse('2005-11-29T20:30:47Z')}
            end
          end
        end
      end
    end
  end
end