forked from sferik/twitter-ruby
/
twitter_spec.rb
103 lines (86 loc) · 2.53 KB
/
twitter_spec.rb
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
require 'helper'
describe Twitter do
after do
Twitter.reset
end
context "when delegating to a client" do
before do
stub_get("statuses/user_timeline.json").
with(:query => {:screen_name => "sferik"}).
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should get the correct resource" do
Twitter.user_timeline('sferik')
a_get("statuses/user_timeline.json").
with(:query => {:screen_name => "sferik"}).
should have_been_made
end
it "should return the same results as a client" do
Twitter.user_timeline('sferik').should == Twitter::Client.new.user_timeline('sferik')
end
end
describe '.respond_to?' do
it "should take an optional argument" do
Twitter.respond_to?(:new, true).should be_true
end
end
describe ".new" do
it "should return a Twitter::Client" do
Twitter.new.should be_a Twitter::Client
end
end
describe ".adapter" do
it "should return the default adapter" do
Twitter.adapter.should == Twitter::Configuration::DEFAULT_ADAPTER
end
end
describe ".adapter=" do
it "should set the adapter" do
Twitter.adapter = :typhoeus
Twitter.adapter.should == :typhoeus
end
end
describe ".endpoint" do
it "should return the default endpoint" do
Twitter.endpoint.should == Twitter::Configuration::DEFAULT_ENDPOINT
end
end
describe ".endpoint=" do
it "should set the endpoint" do
Twitter.endpoint = 'http://tumblr.com/'
Twitter.endpoint.should == 'http://tumblr.com/'
end
end
describe ".format" do
it "should return the default format" do
Twitter.format.should == Twitter::Configuration::DEFAULT_FORMAT
end
end
describe ".format=" do
it "should set the format" do
Twitter.format = 'xml'
Twitter.format.should == 'xml'
end
end
describe ".user_agent" do
it "should return the default user agent" do
Twitter.user_agent.should == Twitter::Configuration::DEFAULT_USER_AGENT
end
end
describe ".user_agent=" do
it "should set the user_agent" do
Twitter.user_agent = 'Custom User Agent'
Twitter.user_agent.should == 'Custom User Agent'
end
end
describe ".configure" do
Twitter::Configuration::VALID_OPTIONS_KEYS.each do |key|
it "should set the #{key}" do
Twitter.configure do |config|
config.send("#{key}=", key)
Twitter.send(key).should == key
end
end
end
end
end