Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.87 KB | None | 0 0
  1. require "../lib/gort/message"
  2.  
  3. describe GORT::Message, "#new" do
  4.   def parse(message, event, args = {})
  5.     defaults = { :nick => "pauldaniels", :user => "~debbie", :host => "mcg.ee",
  6.                  :channel => "#heis",    :message => "that's magic"
  7.     }
  8.     args = defaults.merge args
  9.     msg = GORT::Message.new message
  10.     msg.nick.should    == args[:nick]
  11.     msg.user.should    == args[:user]
  12.     msg.host.should    == args[:host]
  13.     msg.event.should   == event
  14.     msg.channel.should == args[:channel]
  15.     msg.message.should == args[:message]
  16.     msg.target.should  == args[:target]
  17.   end
  18.  
  19.   it "should parse PRIVMSGs" do
  20.     parse ":pauldaniels!~debbie@mcg.ee PRIVMSG #heis :that's magic", :channel
  21.     parse ":pauldaniels!~debbie@mcg.ee PRIVMSG GORT :that's magic", :private, :channel => nil
  22.   end
  23.   it "should parse CTCPs" do
  24.     parse ":pauldaniels!~debbie@mcg.ee PRIVMSG #heis :\x01that's magic\x01", :ctcp
  25.     parse ":pauldaniels!~debbie@mcg.ee PRIVMSG GORT :\x01that's magic\x01", :ctcp, :channel => nil
  26.   end
  27.   it "should parse ACTIONs" do
  28.     parse ":pauldaniels!~debbie@mcg.ee PRIVMSG #heis :\x01ACTION that's magic\x01", :action
  29.     parse ":pauldaniels!~debbie@mcg.ee PRIVMSG GORT :\x01ACTION that's magic\x01", :action, :channel => nil
  30.   end
  31.   it "should parse CTCP replies" do
  32.     parse ":pauldaniels!~debbie@mcg.ee NOTICE GORT :\x01that's magic\x01", :ctcpreply, :channel => nil
  33.   end
  34.   it "should parse NOTICEs" do
  35.     parse ":pauldaniels!~debbie@mcg.ee NOTICE #heis :that's magic", :notice
  36.     parse ":pauldaniels!~debbie@mcg.ee NOTICE GORT :that's magic", :notice, :channel => nil
  37.   end
  38.   it "should parse JOINs" do
  39.     parse ":pauldaniels!~debbie@mcg.ee JOIN :#heis", :join, :message => nil
  40.   end
  41.   it "should parse PARTs" do
  42.     parse ":pauldaniels!~debbie@mcg.ee PART #heis :that's magic", :part
  43.   end
  44.   it "should parse QUITs" do
  45.     parse ":pauldaniels!~debbie@mcg.ee QUIT :that's magic", :quit, :channel => nil
  46.   end
  47.   it "should parse NICK changes" do
  48.     parse ":pauldaniels!~debbie@mcg.ee NICK :davidblaine", :nick, :channel => nil, :message => nil, :target => "davidblaine"
  49.   end
  50.   it "should parse TOPIC changes" do
  51.     parse ":pauldaniels!~debbie@mcg.ee TOPIC #heis :that's magic", :topic
  52.   end
  53.   it "should parse MODEs" do
  54.     parse ":pauldaniels!~debbie@mcg.ee MODE #heis +o GORT pauldaniels debbiemcgee", :mode, :message => "+o", :target => ["GORT", "pauldaniels", "debbiemcgee"]
  55.   end
  56.   it "should parse PINGs" do
  57.     parse "PING :irc.daemon.org", :ping, :message => "irc.daemon.org", :channel => nil, :user => nil, :host => nil, :nick => nil
  58.   end
  59.   ## ++ add some parsing for significant numerics
  60.   it "should parse raw numerics" do
  61.     parse ":irc.daemon.org 366 GORT #heis :End of NAMES list", :_366, :nick => nil, :user => nil, :host => nil, :channel => nil, :target => "GORT", :message => "#heis End of NAMES list"
  62.   end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement