Sha256: 24b85f9be76ca5bfb6f4a94089e4f4440f2969310333e9f0c9aeedc76f9e328a

Contents?: true

Size: 1.9 KB

Versions: 6

Compression:

Stored size: 1.9 KB

Contents

require 'spec_helper'

describe Fantasy::IRC do
    before :each do
        @bot = Fantasy::IRC.new

        # stub the send ethod
        @bot.stub(:send) { }
    end

    describe "#new" do
        it "takes no parameter and returns a Fantasy::IRC object" do
            @bot.should be_an_instance_of Fantasy::IRC
        end
    end

    describe "login" do
        it "takes no arguments and raises an error" do
            expect { @bot.login }.to raise_error
        end

        it "takes a nickname as argument and proceeds to log in" do
            @bot.should_receive(:send).with(/^USER rspec_nick /)
            @bot.should_receive(:send).with(/^NICK rspec_nick$/)
            @bot.login(:nickname => 'rspec_nick')
        end

        it "takes a username as argument and proceeds to log in" do
            @bot.should_receive(:send).with(/^USER rspec_uname /)
            @bot.should_receive(:send).with(/^NICK rspec_uname$/)
            @bot.login(:username => 'rspec_uname')
        end

        it "takes a username and a nickname as argument and proceeds to log in with both" do
            @bot.should_receive(:send).with(/^USER rspec_uname /)
            @bot.should_receive(:send).with(/^NICK rspec_nick$/)
            @bot.login(:username => 'rspec_uname', :nickname => 'rspec_nick')
        end

        it "takes a (username and a) realname and sets the realname too" do
            @bot.should_receive(:send).with(/^USER rspec_uname [^:]+:rspec realname$/)
            @bot.login(:username => 'rspec_uname', :realname => "rspec realname")
        end
    end

    describe "connect" do
        it "takes no arguments and raises an error" do
            expect { @bot.connect }.to raise_error
        end
    end

    describe "parse" do
        it "parses at least the PING message" do
            @bot.should_receive(:send).with(/^PONG :rspec_test$/)
            @bot.parse("PING :rspec_test")
        end
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fantasy-irc-0.3.0 spec/lib/fantasy-irc_spec.rb
fantasy-irc-0.2.3 spec/lib/fantasy-irc_spec.rb
fantasy-irc-0.2.2 spec/lib/fantasy-irc_spec.rb
fantasy-irc-0.2.1 spec/lib/fantasy-irc_spec.rb
fantasy-irc-0.2.0 spec/lib/fantasy-irc_spec.rb
fantasy-irc-0.1.2 spec/lib/fantasy-irc_spec.rb