Sha256: 774cc9fff442513786babb87f3531a3f7a246cffaa4dee636965ade430557a96
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require 'spec_helper' describe MadChatter::Message do before(:each) do MadChatter.users = [] MadChatter.channels = [] end it 'should have a well-known interface' do message = MadChatter::Message.new('message', 'my chat message') [:text, :to_json, :filter].each do |m| message.should respond_to(m) end end it 'should encode into JSON correctly' do message = MadChatter::Message.new('type', 'message', 'token', 'channel') message.timestamp = 1234567890 message.to_json.should == ' { "type":"type", "text":"message", "html":"message", "username":null, "channel":"channel", "growl":"message", "time":1234567890 } '.gsub(/\s+/, '') # remove the white space end context '#username' do let (:user) { MadChatter::User.new('usertoken', 'myusername') } let (:message) { MadChatter::Message.new('message', 'text', 'usertoken') } it 'should find username correctly' do MadChatter.users << user message.username.should == 'myusername' end end context '#filter' do let (:message) { MadChatter::Message.new('message', 'text') } it 'should escape all html tags' do html = "<strong>bold</strong><script>alert('text')</script>" message.filter(html).should == "<strong>bold</strong><script>alert('text')</script>" end it 'should be able to handle messages made of empty space' do text = " " message.filter(text).should == '' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mad_chatter-0.3.3 | spec/message_spec.rb |
mad_chatter-0.3.2 | spec/message_spec.rb |