Sha256: 18a41a98069c80e0e5db63fb7dbe8ddad038bc2a45f6612d22c31b67ff3c477d
Contents?: true
Size: 1.43 KB
Versions: 2
Compression:
Stored size: 1.43 KB
Contents
require 'spec_helper' # see http://stackoverflow.com/q/5061179/314318 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.to_json.should == '{"type":"type","text":"message","html":"message","username":null,"channel":"channel","growl":"message"}' 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.1 | spec/message_spec.rb |
mad_chatter-0.3.0 | spec/message_spec.rb |