t 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,251 +0,0 @@
1
- # encoding: utf-8
2
- require 'helper'
3
-
4
- describe T::Delete do
5
-
6
- before do
7
- @t = T::CLI.new
8
- Timecop.freeze(Time.local(2011, 11, 24, 16, 20, 0))
9
- @old_stderr = $stderr
10
- $stderr = StringIO.new
11
- @old_stdout = $stdout
12
- $stdout = StringIO.new
13
- end
14
-
15
- after do
16
- $stderr = @old_stderr
17
- $stdout = @old_stdout
18
- end
19
-
20
- describe "#block" do
21
- before do
22
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
23
- stub_delete("/1/blocks/destroy.json").
24
- with(:query => {:screen_name => "sferik"}).
25
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
26
- end
27
- it "should request the correct resource" do
28
- @t.delete("block", "sferik")
29
- a_delete("/1/blocks/destroy.json").
30
- with(:query => {:screen_name => "sferik"}).
31
- should have_been_made
32
- end
33
- it "should have the correct output" do
34
- @t.delete("block", "sferik")
35
- $stdout.string.should =~ /^@testcli unblocked @sferik$/
36
- end
37
- end
38
-
39
- describe "#dm" do
40
- before do
41
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
42
- end
43
- context "not found" do
44
- before do
45
- stub_get("/1/direct_messages/sent.json").
46
- with(:query => {:count => "1"}).
47
- to_return(:body => "[]", :headers => {:content_type => "application/json; charset=utf-8"})
48
- end
49
- it "should exit" do
50
- lambda do
51
- @t.delete("dm")
52
- end.should raise_error(Thor::Error, "Direct Message not found")
53
- end
54
- end
55
- context "found" do
56
- before do
57
- stub_get("/1/direct_messages/sent.json").
58
- with(:query => {:count => "1"}).
59
- to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
60
- stub_delete("/1/direct_messages/destroy/1773478249.json").
61
- to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
62
- end
63
- context ":force => true" do
64
- before do
65
- @t.options = @t.options.merge(:force => true)
66
- end
67
- it "should request the correct resource" do
68
- @t.delete("dm")
69
- a_get("/1/direct_messages/sent.json").
70
- with(:query => {:count => "1"}).
71
- should have_been_made
72
- a_delete("/1/direct_messages/destroy/1773478249.json").
73
- should have_been_made
74
- end
75
- it "should have the correct output" do
76
- @t.delete("dm")
77
- $stdout.string.chomp.should == "@sferik deleted the direct message sent to @pengwynn: Creating a fixture for the Twitter gem"
78
- end
79
- end
80
- context ":force => false" do
81
- before do
82
- @t.options = @t.options.merge(:force => false)
83
- end
84
- it "should request the correct resource" do
85
- $stdout.should_receive(:print).with("Are you sure you want to permanently delete the direct message to @hurrycane: Sounds good. Meeting Tuesday is fine.? ")
86
- $stdin.should_receive(:gets).and_return("y")
87
- @t.delete("dm")
88
- a_get("/1/direct_messages/sent.json").
89
- with(:query => {:count => "1"}).
90
- should have_been_made
91
- a_delete("/1/direct_messages/destroy/1773478249.json").
92
- should have_been_made
93
- end
94
- it "should have the correct output" do
95
- $stdout.should_receive(:print).with("Are you sure you want to permanently delete the direct message to @hurrycane: Sounds good. Meeting Tuesday is fine.? ")
96
- $stdin.should_receive(:gets).and_return("y")
97
- @t.delete("dm")
98
- $stdout.string.chomp.should == "@sferik deleted the direct message sent to @pengwynn: Creating a fixture for the Twitter gem"
99
- end
100
- it "should exit" do
101
- $stdout.should_receive(:print).with("Are you sure you want to permanently delete the direct message to @hurrycane: Sounds good. Meeting Tuesday is fine.? ")
102
- $stdin.should_receive(:gets).and_return("n")
103
- lambda do
104
- @t.delete("dm")
105
- end.should raise_error(SystemExit)
106
- end
107
- end
108
- end
109
- end
110
-
111
- describe "#favorite" do
112
- before do
113
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
114
- end
115
- context "not found" do
116
- before do
117
- stub_get("/1/favorites.json").
118
- with(:query => {:count => "1"}).
119
- to_return(:body => "[]", :headers => {:content_type => "application/json; charset=utf-8"})
120
- end
121
- it "should exit" do
122
- lambda do
123
- @t.delete("favorite")
124
- end.should raise_error(Thor::Error, "Tweet not found")
125
- end
126
- end
127
- context "found" do
128
- before do
129
- stub_get("/1/favorites.json").
130
- with(:query => {:count => "1"}).
131
- to_return(:body => fixture("favorites.json"), :headers => {:content_type => "application/json; charset=utf-8"})
132
- stub_delete("/1/favorites/destroy/28439861609.json").
133
- to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
134
- end
135
- context ":force => true" do
136
- before do
137
- @t.options = @t.options.merge(:force => true)
138
- end
139
- it "should request the correct resource" do
140
- @t.delete("favorite")
141
- a_get("/1/favorites.json").
142
- with(:query => {:count => "1"}).
143
- should have_been_made
144
- a_delete("/1/favorites/destroy/28439861609.json").
145
- should have_been_made
146
- end
147
- it "should have the correct output" do
148
- @t.delete("favorite")
149
- $stdout.string.should =~ /^@testcli unfavorited @z's latest status: Spilled grilled onions on myself\. I smell delicious!$/
150
- end
151
- end
152
- context ":force => false" do
153
- before do
154
- @t.options = @t.options.merge(:force => false)
155
- end
156
- it "should request the correct resource" do
157
- $stdout.should_receive(:print).with("Are you sure you want to delete the favorite of @z: Spilled grilled onions on myself. I smell delicious!? ")
158
- $stdin.should_receive(:gets).and_return("y")
159
- @t.delete("favorite")
160
- a_get("/1/favorites.json").
161
- with(:query => {:count => "1"}).
162
- should have_been_made
163
- a_delete("/1/favorites/destroy/28439861609.json").
164
- should have_been_made
165
- end
166
- it "should have the correct output" do
167
- $stdout.should_receive(:print).with("Are you sure you want to delete the favorite of @z: Spilled grilled onions on myself. I smell delicious!? ")
168
- $stdin.should_receive(:gets).and_return("y")
169
- @t.delete("favorite")
170
- $stdout.string.should =~ /^@testcli unfavorited @z's latest status: Spilled grilled onions on myself\. I smell delicious!$/
171
- end
172
- it "should exit" do
173
- $stdout.should_receive(:print).with("Are you sure you want to delete the favorite of @z: Spilled grilled onions on myself. I smell delicious!? ")
174
- $stdin.should_receive(:gets).and_return("n")
175
- lambda do
176
- @t.delete("favorite")
177
- end.should raise_error(SystemExit)
178
- end
179
- end
180
- end
181
- end
182
-
183
- describe "#status" do
184
- before do
185
- @t.options = @t.options.merge(:profile => File.expand_path('../fixtures/.trc', __FILE__))
186
- end
187
- context "not found" do
188
- before do
189
- stub_get("/1/account/verify_credentials.json").
190
- to_return(:body => "{}", :headers => {:content_type => "application/json; charset=utf-8"})
191
- end
192
- it "should exit" do
193
- lambda do
194
- @t.delete("status")
195
- end.should raise_error(Thor::Error, "Tweet not found")
196
- end
197
- end
198
- context "found" do
199
- before do
200
- stub_get("/1/account/verify_credentials.json").
201
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
202
- stub_delete("/1/statuses/destroy/26755176471724032.json").
203
- to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
204
- end
205
- context ":force => true" do
206
- before do
207
- @t.options = @t.options.merge(:force => true)
208
- end
209
- it "should request the correct resource" do
210
- @t.delete("status")
211
- a_get("/1/account/verify_credentials.json").
212
- should have_been_made
213
- a_delete("/1/statuses/destroy/26755176471724032.json").
214
- should have_been_made
215
- end
216
- it "should have the correct output" do
217
- @t.delete("status")
218
- $stdout.string.chomp.should == "@testcli deleted the status: @noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
219
- end
220
- end
221
- context ":force => false" do
222
- before do
223
- @t.options = @t.options.merge(:force => false)
224
- end
225
- it "should request the correct resource" do
226
- $stdout.should_receive(:print).with("Are you sure you want to permanently delete the status: RT @tenderlove: [ANN] sqlite3-ruby => sqlite3? ")
227
- $stdin.should_receive(:gets).and_return("y")
228
- @t.delete("status")
229
- a_get("/1/account/verify_credentials.json").
230
- should have_been_made
231
- a_delete("/1/statuses/destroy/26755176471724032.json").
232
- should have_been_made
233
- end
234
- it "should have the correct output" do
235
- $stdout.should_receive(:print).with("Are you sure you want to permanently delete the status: RT @tenderlove: [ANN] sqlite3-ruby => sqlite3? ")
236
- $stdin.should_receive(:gets).and_return("y")
237
- @t.delete("status")
238
- $stdout.string.chomp.should == "@testcli deleted the status: @noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
239
- end
240
- it "should exit" do
241
- $stdout.should_receive(:print).with("Are you sure you want to permanently delete the status: RT @tenderlove: [ANN] sqlite3-ruby => sqlite3? ")
242
- $stdin.should_receive(:gets).and_return("n")
243
- lambda do
244
- @t.delete("status")
245
- end.should raise_error(SystemExit)
246
- end
247
- end
248
- end
249
- end
250
-
251
- end