Sha256: f8fe7c0c41aeb4439ce54db327f08afeae348f6f6a9da2dc2d38b07892e3d0bd

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper.rb"))
describe Heel::Server do
    before(:each) do 
        @stdin = StringIO.new
        @stdout = StringIO.new
        @stderr = StringIO.new
    end
    
    it "should output the version when invoked with --version" do
        server = Heel::Server.new(["--version"])
        server.set_io(@stdin, @stdout)
        begin
            server.run
        rescue SystemExit => se
            se.status.should == 0
            @stdout.string.should =~ /version #{Heel::VERSION}/
        end
    end
    
    it "should output the Usage when invoked with --help" do
        server = Heel::Server.new(["--help"])
        server.set_io(@stdin, @stdout)
        begin
            server.run
        rescue SystemExit => se
            se.status.should == 0
            @stdout.string.should =~ /Usage/m
        end
    end
    
    it "should have an error when invoked with invalid parameters" do
        server = Heel::Server.new(["--junk"])
        server.set_io(@stdin,@stdout)
        begin
            server.run
        rescue SystemExit => se
            se.status.should == 1
            @stdout.string.should =~ /Try .*--help/m
        end
    end
    
    it "should raise print an error if the directory to serve does not exist" do
        server = Heel::Server.new(["--root /not/valid"])
        server.set_io(@stdin,@stdout)
        begin
            server.run
        rescue SystemExit => se
            se.status.should == 1
            @stdout.string.should =~ /Try .*--help/m
        end
    end
        
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heel-0.2.0 spec/server_spec.rb