test/takosan_test.rb in takosan-1.2.0 vs test/takosan_test.rb in takosan-1.3.0
- old
+ new
@@ -22,13 +22,29 @@
Net::HTTP::Post.expects(:new).with('/privmsg').returns(req)
Takosan.privmsg('foo bar buzz')
end
+ def test_privmsg_with_message_attachments
+ http = mock('http')
+ http.stub_everything
+ http.expects(:request)
+ Net::HTTP.expects(:new).with('irc.example.com', 4649).returns(http)
+
+ req = mock('req')
+ req.stub_everything
+ req.expects(:form_data=).with do |params|
+ (params['channel'] == '#example') && (params['message'] == 'foo bar buzz')
+ end
+ Net::HTTP::Post.expects(:new).with('/privmsg').returns(req)
+
+ Takosan.privmsg('foo bar buzz', title: 'black', color: '#000')
+ end
+
def test_rescue_timeout_error
http = stub('http')
http.stub_everything
- http.stubs(:request).raises(TimeoutError, 'timeout error!')
+ http.stubs(:request).raises(Timeout::Error, 'timeout error!')
Net::HTTP.expects(:new).with('irc.example.com', 4649).returns(http)
req = stub('req')
req.stub_everything
Net::HTTP::Post.expects(:new).with('/privmsg').returns(req)