flamethrower 0.3.0 → 0.3.2

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,36 +1,36 @@
1
1
  require File.join(File.dirname(__FILE__), "../spec_helper")
2
2
 
3
- describe Flamethrower::Server do
3
+ describe Flamethrower::Connection do
4
4
  before do
5
- @server = Flamethrower::MockServer.new
6
- @server.stub!(:send_data)
5
+ @connection = Flamethrower::MockConnection.new
6
+ @connection.stub!(:send_data)
7
7
  @user = Flamethrower::Irc::User.new :username => 'user', :nickname => 'nick', :hostname => 'host', :realname => 'realname'
8
- @server.current_user = @user
8
+ @connection.current_user = @user
9
9
  end
10
10
 
11
11
  describe "#send_message" do
12
12
  it "sends the message to the client" do
13
13
  message = "message"
14
- @server.should_receive(:send_message).with("message")
15
- @server.send_message(message)
14
+ @connection.should_receive(:send_message).with("message")
15
+ @connection.send_message(message)
16
16
  end
17
17
 
18
18
  it "should send the data across the wire" do
19
19
  message = "message"
20
- @server.should_receive(:send_data).with("message\r\n")
21
- @server.send_message(message)
20
+ @connection.should_receive(:send_data).with("message\r\n")
21
+ @connection.send_message(message)
22
22
  end
23
23
  end
24
24
 
25
25
  describe "#send_messages" do
26
26
  it "sends a list of messages to the client" do
27
- @server.should_receive(:send_message).exactly(2).times
28
- @server.send_messages("one", "two")
27
+ @connection.should_receive(:send_message).exactly(2).times
28
+ @connection.send_messages("one", "two")
29
29
  end
30
30
 
31
31
  it "yields to the block to allow more messages" do
32
- @server.should_receive(:send_message).exactly(3).times
33
- @server.send_messages("one", "two") do |messages|
32
+ @connection.should_receive(:send_message).exactly(3).times
33
+ @connection.send_messages("one", "two") do |messages|
34
34
  messages << "three"
35
35
  end
36
36
  end
@@ -41,8 +41,8 @@ describe Flamethrower::Server do
41
41
  incoming = "COMMAND params"
42
42
  msg = Flamethrower::Irc::Message.new(incoming)
43
43
  Flamethrower::Irc::Message.should_receive(:new).with(incoming).and_return(msg)
44
- @server.dispatcher.should_receive(:handle_message).with(msg)
45
- @server.receive_data(incoming)
44
+ @connection.dispatcher.should_receive(:handle_message).with(msg)
45
+ @connection.receive_data("#{incoming}\r\n")
46
46
  end
47
47
  end
48
48
 
@@ -53,64 +53,74 @@ describe Flamethrower::Server do
53
53
  to_return(:status => 200, :body => json_fixture("rooms"))
54
54
  end
55
55
 
56
+ it "sends welcome" do
57
+ @connection.stub(:populate_irc_channels)
58
+ @connection.stub(:populate_my_user)
59
+ @connection.should_receive(:send_welcome)
60
+ @connection.after_connect
61
+ end
62
+
56
63
  it "sends motd" do
57
- @server.stub(:populate_irc_channels)
58
- @server.stub(:populate_my_user)
59
- @server.should_receive(:send_motd)
60
- @server.after_connect
64
+ @connection.stub(:populate_irc_channels)
65
+ @connection.stub(:populate_my_user)
66
+ @connection.should_receive(:send_motd)
67
+ @connection.after_connect
61
68
  end
62
69
 
63
70
  it "populates the channel list" do
64
- @server.stub(:populate_my_user)
65
- @server.should_receive(:populate_irc_channels)
66
- @server.after_connect
71
+ @connection.stub(:populate_my_user)
72
+ @connection.should_receive(:populate_irc_channels)
73
+ @connection.after_connect
67
74
  end
68
75
 
69
76
  it "populates the currently logged in user" do
70
- @server.stub(:populate_irc_channels)
71
- @server.should_receive(:populate_my_user)
72
- @server.after_connect
77
+ @connection.stub(:populate_irc_channels)
78
+ @connection.should_receive(:populate_my_user)
79
+ @connection.after_connect
73
80
  end
74
81
  end
75
82
 
76
83
  describe "irc_channels" do
77
- it "stores the list of irc_channels on the server" do
84
+ it "stores the list of irc_channels on the connection" do
78
85
  channel = Flamethrower::Irc::Channel.new("#flamethrower")
79
- @server.irc_channels << channel
80
- @server.irc_channels.should include(channel)
86
+ @connection.irc_channels << channel
87
+ @connection.irc_channels.should include(channel)
81
88
  end
82
89
  end
83
90
 
84
91
  describe "IRCcommands" do
92
+ it "should have a first message" do
93
+ @connection.send_welcome.should == ":host 001 nick :Welcome to Flamethrower"
94
+ end
95
+
85
96
  it "should have the correct MOTD format" do
86
- @server.send_motd.should == [
97
+ @connection.send_motd.should == [
87
98
  ":host 375 nick :MOTD",
88
- ":host 372 nick :Welcome to Flamethrower",
89
99
  ":host 372 nick :Fetching channel list from campfire..."
90
100
  ]
91
101
  end
92
102
 
93
103
  it "should send the channel mode" do
94
104
  channel = Flamethrower::Irc::Channel.new("#flamethrower")
95
- @server.send_channel_mode(channel).should == ":host 324 nick #flamethrower +t"
105
+ @connection.send_channel_mode(channel).should == ":host 324 nick #flamethrower +t"
96
106
  end
97
107
 
98
108
  it "should send the current user mode" do
99
- @server.send_user_mode.should == ":host 221 nick +i"
109
+ @connection.send_user_mode.should == ":host 221 nick +i"
100
110
  end
101
111
 
102
112
  it "should have the correct TOPIC format" do
103
113
  room = Flamethrower::Campfire::Room.new("mydomain", "mytoken", "id" => 347348, "name" => "room 1")
104
114
  channel = Flamethrower::Irc::Channel.new("#flamethrower", room)
105
115
  channel.topic = "A topic"
106
- @server.send_topic(channel).should == ":host 332 nick #flamethrower :A topic"
116
+ @connection.send_topic(channel).should == ":host 332 nick #flamethrower :A topic"
107
117
  end
108
118
 
109
119
  it "should have the correct USERLIST format" do
110
120
  room = Flamethrower::Campfire::Room.new('mydomain', 'mytoken')
111
121
  channel = Flamethrower::Irc::Channel.new("#flamethrower", room)
112
122
  channel.users << Flamethrower::Irc::User.new(:nickname => 'bob', :username => 'bob')
113
- @server.send_userlist(channel).should == [
123
+ @connection.send_userlist(channel).should == [
114
124
  ":host 353 nick = #flamethrower :@nick bob",
115
125
  ":host 366 nick #flamethrower :/End of /NAMES list"
116
126
  ]
@@ -123,7 +133,7 @@ describe Flamethrower::Server do
123
133
  user1 = Flamethrower::Campfire::User.new('id' => 1234, 'name' => 'Bob Jones')
124
134
  user2 = Flamethrower::Campfire::User.new('id' => 4321, 'name' => 'Bill Myer')
125
135
  room.users = [user1, user2]
126
- @server.send_who(channel).should == [
136
+ @connection.send_who(channel).should == [
127
137
  ":host 352 nick #flamethrower Bob_Jones campfirenow.com localhost Bob_Jones H :0 Bob_Jones",
128
138
  ":host 352 nick #flamethrower Bill_Myer campfirenow.com localhost Bill_Myer H :0 Bill_Myer",
129
139
  ":host 315 nick #flamethrower :/End of /WHO list"
@@ -139,8 +149,8 @@ describe Flamethrower::Server do
139
149
  channel.topic = "Flamethrower topic"
140
150
  channel2 = Flamethrower::Irc::Channel.new("#room_1", room2)
141
151
  channel2.topic = "Room 1 topic"
142
- @server.irc_channels = [channel, channel2]
143
- @server.send_channel_list.should == [
152
+ @connection.irc_channels = [channel, channel2]
153
+ @connection.send_channel_list.should == [
144
154
  ":host 372 nick :Active channels:",
145
155
  ":host 372 nick :#flamethrower - Flamethrower topic",
146
156
  ":host 372 nick :#room_1 - Room 1 topic",
@@ -154,8 +164,8 @@ describe Flamethrower::Server do
154
164
  channel = Flamethrower::Irc::Channel.new("#flamethrower", room)
155
165
  channel2 = Flamethrower::Irc::Channel.new("#room_1", room2)
156
166
  channel.topic = channel2.topic = ""
157
- @server.irc_channels = [channel, channel2]
158
- @server.send_channel_list.should == [
167
+ @connection.irc_channels = [channel, channel2]
168
+ @connection.send_channel_list.should == [
159
169
  ":host 372 nick :Active channels:",
160
170
  ":host 372 nick :#flamethrower - No topic",
161
171
  ":host 372 nick :#room_1 - No topic",
@@ -170,9 +180,9 @@ describe Flamethrower::Server do
170
180
  with(:headers => {'Authorization'=>['mytoken', 'x']}).
171
181
  to_return(:status => 200, :body => json_fixture("rooms"))
172
182
 
173
- EM.run_block { @server.populate_irc_channels }
174
- @server.irc_channels.count.should == 1
175
- @server.irc_channels.first.name.should == "#room_1"
183
+ EM.run_block { @connection.populate_irc_channels }
184
+ @connection.irc_channels.count.should == 1
185
+ @connection.irc_channels.first.name.should == "#room_1"
176
186
  end
177
187
  end
178
188
  end
@@ -2,13 +2,13 @@ require File.join(File.dirname(__FILE__), "../spec_helper")
2
2
 
3
3
  describe Flamethrower::Dispatcher do
4
4
  before do
5
- @server = Flamethrower::MockServer.new(:log => Logger.new("/dev/null"))
5
+ @connection = Flamethrower::MockConnection.new(:log => Logger.new("/dev/null"))
6
6
  @room = Flamethrower::Campfire::Room.new('mydomain', 'mytoken', {'name' => 'a room', 'id' => 347348})
7
7
  @room.instance_variable_set("@stream", mock(:twitter_stream, :stop => nil))
8
8
  @channel = Flamethrower::Irc::Channel.new("#flamethrower", @room)
9
9
  @user = Flamethrower::Irc::User.new :username => "user", :nickname => "nick", :hostname => "host", :realname => "realname", :servername => "servername"
10
- @server.irc_channels << @channel
11
- @dispatcher = Flamethrower::Dispatcher.new(@server)
10
+ @connection.irc_channels << @channel
11
+ @dispatcher = Flamethrower::Dispatcher.new(@connection)
12
12
  end
13
13
 
14
14
  describe "#handle_message" do
@@ -29,10 +29,10 @@ describe Flamethrower::Dispatcher do
29
29
  it "sets the current session's user to the specified user" do
30
30
  message = Flamethrower::Irc::Message.new("USER guest tolmoon tolsun :Ronnie Reagan\r\n")
31
31
  @dispatcher.handle_message(message)
32
- @dispatcher.server.current_user.username.should == "guest"
33
- @dispatcher.server.current_user.hostname.should == "tolmoon"
34
- @dispatcher.server.current_user.servername.should == "tolsun"
35
- @dispatcher.server.current_user.realname.should == "Ronnie Reagan"
32
+ @dispatcher.connection.current_user.username.should == "guest"
33
+ @dispatcher.connection.current_user.hostname.should == "tolmoon"
34
+ @dispatcher.connection.current_user.servername.should == "tolsun"
35
+ @dispatcher.connection.current_user.realname.should == "Ronnie Reagan"
36
36
  end
37
37
 
38
38
  it "not set a second user request if a first has already been recieved" do
@@ -40,49 +40,58 @@ describe Flamethrower::Dispatcher do
40
40
  message2 = Flamethrower::Irc::Message.new("USER guest2 tolmoon2 tolsun2 :Ronnie Reagan2\r\n")
41
41
  @dispatcher.handle_message(message)
42
42
  @dispatcher.handle_message(message2)
43
- @dispatcher.server.current_user.username.should == "guest"
44
- @dispatcher.server.current_user.hostname.should == "tolmoon"
45
- @dispatcher.server.current_user.servername.should == "tolsun"
46
- @dispatcher.server.current_user.realname.should == "Ronnie Reagan"
43
+ @dispatcher.connection.current_user.username.should == "guest"
44
+ @dispatcher.connection.current_user.hostname.should == "tolmoon"
45
+ @dispatcher.connection.current_user.servername.should == "tolsun"
46
+ @dispatcher.connection.current_user.realname.should == "Ronnie Reagan"
47
47
  end
48
48
  end
49
49
 
50
50
  describe "#away" do
51
51
  it "respond with RPL_NOWAWAY when the user specifies an away message" do
52
- @server.current_user = @user
52
+ @connection.current_user = @user
53
53
  message = Flamethrower::Irc::Message.new("AWAY :I'm away")
54
- @dispatcher.server.should_receive(:send_message).with(":#{@user.hostname} 306 #{@user.nickname} :You have been marked as being away")
54
+ @dispatcher.connection.should_receive(:send_message).with(":#{@user.hostname} 306 #{@user.nickname} :You have been marked as being away")
55
55
  @dispatcher.handle_message(message)
56
- @server.current_user.away_message.should == "I'm away"
56
+ @connection.current_user.away_message.should == "I'm away"
57
57
  end
58
58
 
59
59
  it "respond with RPL_UNAWAY when the user doesn't specify an away message" do
60
- @server.current_user = @user
61
- @server.current_user.away_message = "Currently away"
60
+ @connection.current_user = @user
61
+ @connection.current_user.away_message = "Currently away"
62
62
  message = Flamethrower::Irc::Message.new("AWAY :")
63
- @dispatcher.server.should_receive(:send_message).with(":#{@user.hostname} 305 #{@user.nickname} :You are no longer marked as being away")
63
+ @dispatcher.connection.should_receive(:send_message).with(":#{@user.hostname} 305 #{@user.nickname} :You are no longer marked as being away")
64
64
  @dispatcher.handle_message(message)
65
- @server.current_user.away_message.should == nil
65
+ @connection.current_user.away_message.should == nil
66
+ end
67
+
68
+ it "response with RPL_UNAWAY when the away message has no colon" do
69
+ @connection.current_user = @user
70
+ @connection.current_user.away_message = "Currently away"
71
+ message = Flamethrower::Irc::Message.new("AWAY")
72
+ @dispatcher.connection.should_receive(:send_message).with(":#{@user.hostname} 305 #{@user.nickname} :You are no longer marked as being away")
73
+ @dispatcher.handle_message(message)
74
+ @connection.current_user.away_message.should == nil
66
75
  end
67
76
  end
68
77
 
69
78
  describe "#topic" do
70
79
  before do
71
80
  @user = Flamethrower::Irc::User.new :username => "user", :nickname => "nick", :hostname => "host", :realname => "realname", :servername => "servername"
72
- @server.current_user = @user
81
+ @connection.current_user = @user
73
82
  end
74
83
 
75
84
  context "retrieving the channel topic" do
76
85
  it "should display the channel topic" do
77
86
  message = Flamethrower::Irc::Message.new("TOPIC #flamethrower")
78
- @dispatcher.server.should_receive(:send_topic).with(@channel)
87
+ @dispatcher.connection.should_receive(:send_topic).with(@channel)
79
88
  @dispatcher.handle_message(message)
80
89
  end
81
90
 
82
91
  it "responds with an error if the channel can't be found" do
83
92
  message = Flamethrower::Irc::Message.new("TOPIC #bogus")
84
- @dispatcher.server.should_not_receive(:send_topic)
85
- @dispatcher.server.should_receive(:send_message).with(":#{@user.hostname} 475")
93
+ @dispatcher.connection.should_not_receive(:send_topic)
94
+ @dispatcher.connection.should_receive(:send_message).with(":#{@user.hostname} 475")
86
95
  @dispatcher.handle_message(message)
87
96
  end
88
97
  end
@@ -93,7 +102,7 @@ describe Flamethrower::Dispatcher do
93
102
  with(:headers => {'Authorization'=>['mytoken', 'x'], 'Content-Type'=>'application/json'}).
94
103
  to_return(:status => 200, :body => json_fixture("room_update"))
95
104
  message = Flamethrower::Irc::Message.new("TOPIC #flamethrower :some awesome topic")
96
- @dispatcher.server.should_receive(:send_topic).with(@channel)
105
+ @dispatcher.connection.should_receive(:send_topic).with(@channel)
97
106
  EM.run_block { @dispatcher.handle_message(message) }
98
107
  @channel.topic.should == "some awesome topic"
99
108
  end
@@ -103,7 +112,7 @@ describe Flamethrower::Dispatcher do
103
112
  describe "#who" do
104
113
  it "responds with a who list" do
105
114
  message = Flamethrower::Irc::Message.new("WHO #flamethrower\r\n")
106
- @dispatcher.server.should_receive(:send_who).with(@channel)
115
+ @dispatcher.connection.should_receive(:send_who).with(@channel)
107
116
  @dispatcher.handle_message(message)
108
117
  end
109
118
  end
@@ -111,25 +120,25 @@ describe Flamethrower::Dispatcher do
111
120
  describe "#mode" do
112
121
  before do
113
122
  @user = Flamethrower::Irc::User.new :username => "user", :nickname => "nick", :hostname => "host", :realname => "realname", :servername => "servername"
114
- @server.current_user = @user
123
+ @connection.current_user = @user
115
124
  end
116
125
 
117
126
  context "channel mode" do
118
127
  it "responds to mode with a static channel mode" do
119
128
  message = Flamethrower::Irc::Message.new("MODE #flamethrower\r\n")
120
- @dispatcher.server.should_receive(:send_channel_mode).with(@channel)
129
+ @dispatcher.connection.should_receive(:send_channel_mode).with(@channel)
121
130
  @dispatcher.handle_message(message)
122
131
  end
123
132
 
124
133
  it "responds with the user mode if the mode isn't for a channel" do
125
134
  message = Flamethrower::Irc::Message.new("MODE #{@user.nickname} +i\r\n")
126
- @dispatcher.server.should_receive(:send_user_mode)
135
+ @dispatcher.connection.should_receive(:send_user_mode)
127
136
  @dispatcher.handle_message(message)
128
137
  end
129
138
 
130
139
  it "responds with unknown command if the mode is neither a server nor the current user" do
131
140
  message = Flamethrower::Irc::Message.new("MODE foo\r\n")
132
- @dispatcher.server.should_receive(:send_message).with(":#{@user.hostname} 421")
141
+ @dispatcher.connection.should_receive(:send_message).with(":#{@user.hostname} 421")
133
142
  @dispatcher.handle_message(message)
134
143
  end
135
144
  end
@@ -139,7 +148,7 @@ describe Flamethrower::Dispatcher do
139
148
  it "sets the current session's user nickname to the specified nick" do
140
149
  message = Flamethrower::Irc::Message.new("NICK WiZ\r\n")
141
150
  @dispatcher.handle_message(message)
142
- @dispatcher.server.current_user.nickname.should == "WiZ"
151
+ @dispatcher.connection.current_user.nickname.should == "WiZ"
143
152
  end
144
153
  end
145
154
 
@@ -149,7 +158,7 @@ describe Flamethrower::Dispatcher do
149
158
  message = Flamethrower::Irc::Message.new("PRIVMSG #test :Hello.\r\n")
150
159
  room = Flamethrower::Campfire::Room.new("mydomain", "mytoken", {'name' => "test"})
151
160
  irc_channel = room.to_irc
152
- @dispatcher.server.irc_channels << irc_channel
161
+ @dispatcher.connection.irc_channels << irc_channel
153
162
  @dispatcher.handle_message(message)
154
163
  room.outbound_messages.size.should == 1
155
164
  end
@@ -158,7 +167,7 @@ describe Flamethrower::Dispatcher do
158
167
  message = Flamethrower::Irc::Message.new("PRIVMSG #test :Hello.\r\n")
159
168
  room = Flamethrower::Campfire::Room.new("mydomain", "mytoken", {'name' => "test"})
160
169
  irc_channel = room.to_irc
161
- @dispatcher.server.irc_channels << irc_channel
170
+ @dispatcher.connection.irc_channels << irc_channel
162
171
  @dispatcher.handle_message(message)
163
172
  campfire_message = room.outbound_messages.pop
164
173
  campfire_message.body.should == "Hello."
@@ -171,7 +180,7 @@ describe Flamethrower::Dispatcher do
171
180
  describe "#ping" do
172
181
  it "responds with pong of the same ping parameters" do
173
182
  message = Flamethrower::Irc::Message.new("PING :something\r\n")
174
- @server.should_receive(:send_message).with("PONG :something")
183
+ @connection.should_receive(:send_message).with("PONG :something")
175
184
  @dispatcher.handle_message(message)
176
185
  end
177
186
  end
@@ -189,17 +198,17 @@ describe Flamethrower::Dispatcher do
189
198
  it "sends a part message with your current user's name" do
190
199
  EventMachine.stub(:cancel_timer)
191
200
  user = Flamethrower::Irc::User.new :username => "user", :nickname => "nick", :hostname => "host", :realname => "realname", :servername => "servername"
192
- @server.current_user = user
201
+ @connection.current_user = user
193
202
  message = Flamethrower::Irc::Message.new("PART #flamethrower")
194
- @server.should_receive(:send_message).with(":#{user.to_s} PART #flamethrower")
203
+ @connection.should_receive(:send_message).with(":#{user.to_s} PART #flamethrower")
195
204
  @dispatcher.handle_message(message)
196
205
  end
197
206
 
198
207
  it "responds with ERR_BADCHANNELKEY a channel that doesn't exist" do
199
208
  user = Flamethrower::Irc::User.new :username => "user", :nickname => "nick", :hostname => "host", :realname => "realname", :servername => "servername"
200
- @server.current_user = user
209
+ @connection.current_user = user
201
210
  message = Flamethrower::Irc::Message.new("PART #foobar")
202
- @server.should_receive(:send_message).with(":#{user.hostname} 475")
211
+ @connection.should_receive(:send_message).with(":#{user.hostname} 475")
203
212
  @dispatcher.handle_message(message)
204
213
  end
205
214
  end
@@ -229,7 +238,7 @@ describe Flamethrower::Dispatcher do
229
238
 
230
239
  it "adds the current user to the channel" do
231
240
  user = Flamethrower::Irc::User.new :username => "user", :nickname => "nick", :hostname => "host", :realname => "realname", :servername => "servername"
232
- @server.current_user = user
241
+ @connection.current_user = user
233
242
  message = Flamethrower::Irc::Message.new("JOIN #flamethrower\r\n")
234
243
  @dispatcher.handle_message(message)
235
244
  @channel.users.should include(user)
@@ -237,11 +246,20 @@ describe Flamethrower::Dispatcher do
237
246
 
238
247
  it "responds with ERR_BADCHANNELKEY a channel that doesn't exist" do
239
248
  user = Flamethrower::Irc::User.new :username => "user", :nickname => "nick", :hostname => "host", :realname => "realname", :servername => "servername"
240
- @server.current_user = user
249
+ @connection.current_user = user
241
250
  message = Flamethrower::Irc::Message.new("JOIN #foobar\r\n")
242
- @server.should_receive(:send_message).with(":#{user.hostname} 475")
243
- @server.should_not_receive(:send_topic)
244
- @server.should_not_receive(:send_userlist)
251
+ @connection.should_receive(:send_message).with(":#{user.hostname} 475")
252
+ @connection.should_not_receive(:send_topic)
253
+ @connection.should_not_receive(:send_userlist)
254
+ @dispatcher.handle_message(message)
255
+ end
256
+
257
+ it "sends a join message with your current user's name" do
258
+ EventMachine.stub(:cancel_timer)
259
+ user = Flamethrower::Irc::User.new :username => "user", :nickname => "nick", :hostname => "host", :realname => "realname", :servername => "servername"
260
+ @connection.current_user = user
261
+ message = Flamethrower::Irc::Message.new("JOIN #flamethrower")
262
+ @connection.should_receive(:send_message).with(":#{user.to_s} JOIN #flamethrower")
245
263
  @dispatcher.handle_message(message)
246
264
  end
247
265
 
@@ -260,13 +278,13 @@ describe Flamethrower::Dispatcher do
260
278
 
261
279
  describe "nick sent first" do
262
280
  it "sends the motd, join" do
263
- @dispatcher.server.should_receive(:after_connect)
281
+ @dispatcher.connection.should_receive(:after_connect)
264
282
  @dispatcher.handle_message(@nick_message)
265
283
  @dispatcher.handle_message(@user_message)
266
284
  end
267
285
 
268
286
  it "doesn't send after_connect if only the nick has been sent" do
269
- @dispatcher.server.should_not_receive(:after_connect)
287
+ @dispatcher.connection.should_not_receive(:after_connect)
270
288
  @dispatcher.handle_message(@nick_message)
271
289
  end
272
290
 
@@ -274,13 +292,13 @@ describe Flamethrower::Dispatcher do
274
292
 
275
293
  describe "user sent first" do
276
294
  it "sends the motd" do
277
- @dispatcher.server.should_receive(:after_connect)
295
+ @dispatcher.connection.should_receive(:after_connect)
278
296
  @dispatcher.handle_message(@user_message)
279
297
  @dispatcher.handle_message(@nick_message)
280
298
  end
281
299
 
282
300
  it "doesn't send after_connect if only the nick has been sent" do
283
- @dispatcher.server.should_not_receive(:after_connect)
301
+ @dispatcher.connection.should_not_receive(:after_connect)
284
302
  @dispatcher.handle_message(@user_message)
285
303
  end
286
304