firering 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,203 +0,0 @@
1
- require 'spec_helper'
2
- require 'date'
3
-
4
- Firering::Streaming.protocol = "http"
5
- Firering::Streaming.host = "localhost:4567"
6
-
7
- Firering::HTTP.host = "localhost:4567"
8
-
9
- describe "firering" do
10
-
11
- it "authenticates a user" do
12
- EM.run {
13
- Firering.authenticate(nil, "user", "password") do |user|
14
- user.token.should == "token"
15
- EM.stop
16
- end
17
- }
18
- end
19
-
20
- it "gets a user info" do
21
- EM.run {
22
- Firering.user(415731) do |user|
23
- user.type.should == "Member"
24
- user.created_at.should == Date.parse("2009/01/27 19:54:36 +0000")
25
- user.email_address.should == "eoga@mail.com"
26
- user.should_not be_admin
27
- user.id.should == 415731
28
- user.name.should == "Emmanuel"
29
- EM.stop
30
- end
31
- }
32
- end
33
-
34
- it "gets a single room" do
35
- EM.run {
36
- Firering.room(304355) do |room|
37
- room.name.should == "test2"
38
- room.created_at.should == Date.parse("2010/05/29 21:38:02 +0000")
39
- room.updated_at.should == Date.parse("2010/05/29 21:38:02 +0000")
40
- room.topic.should == "this and the test room should be deleted by a campfire admin."
41
- room.should_not be_full
42
- room.id.should == 304355
43
- room.should_not be_open_to_guests
44
- room.membership_limit.should == 12
45
- room.should_not be_locked
46
-
47
- room.users.each do |u|
48
- u.should be_an_instance_of(Firering::User)
49
- end
50
-
51
- EM.stop
52
- end
53
- }
54
- end
55
-
56
- it "gets multiple rooms without performing multiple requests per room" do
57
- EM.run {
58
- Firering.rooms(false) do |rooms|
59
- rooms.each do |room|
60
- room.should be_an_instance_of(Firering::Room)
61
- room.users.should be_an_instance_of(Array)
62
- end
63
- EM.stop
64
- end
65
- }
66
- end
67
-
68
- it "gets multiple rooms performing multiple requests per room" do
69
- EM.run {
70
- Firering.rooms do |rooms|
71
- rooms.each do |room|
72
- room.should be_an_instance_of(Firering::Room)
73
- room.users.should be_an_instance_of(Array)
74
- end
75
-
76
- EM.stop
77
- end
78
- }
79
- end
80
-
81
- it "updates a room and then calls the block" do
82
- EM.run {
83
- Firering.update_room(304355, :topic => "some topic") do
84
- EM.stop
85
- end
86
- }
87
- end
88
-
89
- it "gets a collection of recent messages" do
90
- EM.run {
91
- Firering.room_recent_messages(304355) do |messages|
92
-
93
- messages.each do |m|
94
- m.should be_an_instance_of(Firering::Message)
95
- end
96
-
97
- message = messages.first
98
- message.should be_timestamp
99
- message.room_id.should == 304355
100
- message.created_at.should == Date.parse("2010/05/29 22:05:00 +0000")
101
- message.body.should be_nil
102
- message.id.should == 224587718
103
- message.user_id.should be_nil
104
-
105
- EM.stop
106
- end
107
- }
108
- end
109
-
110
- it "returns a collection of messages matching certain pattern" do
111
- EM.run {
112
- Firering.search_messages("harmless") do |messages|
113
-
114
- messages.length.should == 3
115
-
116
- messages.each do |m|
117
- m.should be_an_instance_of(Firering::Message)
118
- end
119
-
120
- message = messages.last
121
- message.should be_text
122
- message.room_id.should == 177718
123
- message.created_at.should == Date.parse("2009/06/02 21:20:32 +0000")
124
- message.body.should == "q: should i add :case_sensitive =\u003E false to the validation of title name? Looks harmless but who knows..."
125
- message.id.should == 134405854
126
- message.user_id.should == 415731
127
-
128
- EM.stop
129
- end
130
- }
131
- end
132
-
133
- it "returns the messages of today for a given room" do
134
- EM.run {
135
- Firering.today_messages(304355) do |messages|
136
-
137
- messages.length.should == 33
138
-
139
- messages.each do |m|
140
- m.should be_an_instance_of(Firering::Message)
141
- end
142
-
143
- message = messages.last
144
-
145
- message.should be_paste
146
- message.room_id.should == 304355
147
- message.created_at.should == Date.parse("2010/05/29 22:41:34 +0000")
148
- message.body.should == "paste\ntext"
149
- message.id.should == 224590114
150
- message.user_id.should == 415731
151
-
152
- EM.stop
153
- end
154
- }
155
- end
156
-
157
- it "joins a room an call a block" do
158
- EM.run { Firering.room_join(304355) { EM.stop } }
159
- end
160
-
161
- it "leaves a room an call a block" do
162
- EM.run { Firering.room_leave(304355) { EM.stop } }
163
- end
164
-
165
- it "unlocks a room an call a block" do
166
- EM.run { Firering.room_unlock(304355) { EM.stop } }
167
- end
168
-
169
- it "is able to speak a text message" do
170
- EM.run { Firering.text(304355, "some text") { EM.stop } }
171
- end
172
-
173
- it "is able to speak a paste message" do
174
- EM.run { Firering.paste(304355, "some\ntext") { EM.stop } }
175
- end
176
-
177
- it "is able to speak a tweet" do
178
- EM.run { Firering.tweet(304355, "http://twitter.com/message") { EM.stop } }
179
- end
180
-
181
- it "is able to play a rimshot" do
182
- EM.run { Firering.rimshot(304355) { EM.stop } }
183
- end
184
-
185
- it "is able to play crickets" do
186
- EM.run { Firering.crickets(304355) { EM.stop } }
187
- end
188
-
189
- it "is able to play a trombone" do
190
- EM.run { Firering.trombone(304355) { EM.stop } }
191
- end
192
-
193
- it "is able to highlight / de-highlight a message" do
194
- EM.run {
195
- Firering.highlight_message(224590113) {
196
- Firering.highlight_message(224590113, false) {
197
- EM.stop
198
- }
199
- }
200
- }
201
- end
202
-
203
- end
@@ -1,40 +0,0 @@
1
- require 'rack'
2
- require 'thin'
3
- require 'sinatra'
4
-
5
- use Rack::ContentLength
6
-
7
- def setup(method, path)
8
- fixture = ([method.to_s] + path.split("/")).join("_").squeeze("_").gsub("*", "ID")
9
-
10
- send(method, path) do
11
- File.read(File.expand_path(File.join(File.dirname(__FILE__), "json", fixture)))
12
- end
13
- end
14
-
15
- setup :get, "/rooms.json"
16
-
17
- setup :get, "/room/*/recent.json"
18
- setup :get, "/room/*/uploads.json"
19
- setup :get, "/room/*/transcript.json"
20
- setup :get, "/room/*/transcript/2010/05/28.json"
21
- setup :post, "/room/*/speak.json"
22
- setup :post, "/room/*/uploads.json"
23
- setup :post, "/room/*/lock.json"
24
- setup :post, "/room/*/join.json"
25
- setup :post, "/room/*/leave.json"
26
- setup :post, "/room/*/unlock.json"
27
-
28
- setup :delete, "/messages/*/star.json"
29
- setup :post, "/messages/*/star.json"
30
-
31
- setup :get, "/users/me.json"
32
- setup :get, "/users/*.json"
33
-
34
- setup :get, "/search/harmless.json"
35
-
36
- setup :post, "/room/*/join.json"
37
- setup :get, "/room/*/live.json"
38
-
39
- setup :get, "/room/*.json"
40
- setup :put, "/room/*.json"