Skip to content

Instantly share code, notes, and snippets.

@rking
Created December 22, 2012 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rking/4357513 to your computer and use it in GitHub Desktop.
Save rking/4357513 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rspec'
def chop_at_crlf! data
data.sub! /(\r\n)(.*)/, '\1'
$2
end
describe 'thing' do
it 'should parse' do
input = "PRIVMSG #notroll :this is a pretty standard message plus or minus the colon... i forget.\r\ntrash"
trash = chop_at_crlf! input
"PRIVMSG #notroll :this is a pretty standard message plus or minus the colon... i forget.\r\n".should == input
'trash'.should == trash
end
end
#!/usr/bin/env ruby
require 'minitest/autorun'
def chop_at_crlf! data
data.sub! /(\r\n)(.*)/, '\1'
$2
end
class IrcTest < MiniTest::Unit::TestCase
def test_parse
input = "PRIVMSG #notroll :this is a pretty standard message plus or minus the colon... i forget.\r\ntrash"
trash = chop_at_crlf! input
assert_equal "PRIVMSG #notroll :this is a pretty standard message plus or minus the colon... i forget.\r\n", input
assert_equal 'trash', trash
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment