Sha256: 8bab49fe8a1a8f8fe9921683b7f462f443418207fbe9a170c2244e1911c4c630

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

require "spec_helper"

module Lumberg
  describe Cpanel::SubDomain do
    before(:each) do
      @login    = { :host => @whm_host, :hash => @whm_hash }
      @server   = Whm::Server.new(@login.dup)

      @api_username = "lumberg"
      @subd = Cpanel::SubDomain.new(
        :server       => @server.dup,
        :api_username => @api_username
      )
    end

    describe "#list" do
      use_vcr_cassette "cpanel/sub_domain/list"

      context "subdomains exist on the account" do
        let(:result) { @subd.list }
        subject { result[:params][:data] }

        it "returns an array with info for each subdomain" do
          subject.should be_an(Array)
          subject.each {|info|
            info.keys.should include(
              :domainkey, :status, :reldir, :dir, :subdomain,
              :rootdomain, :domain, :basedir
            )
          }
        end
      end

      context "subdomains do not exist on the account" do
        before { @subd.api_username = "minimal" }
        after { @subd.api_username = "lumberg" }

        it "returns an empty array" do
          @subd.list[:params][:data].should be_empty
        end

      end
    end

    describe "#remove" do
      use_vcr_cassette "cpanel/sub_domain/remove"

      it "removes a subdomain" do
        # Add the subdomain first
        @subd.add(:domain => "foo", :rootdomain => "lumberg-test.com")

        result = @subd.remove(:domain => "foo.lumberg-test.com")
        result[:params][:data][0][:result].should == 1
      end
    end

    describe "#add" do
      use_vcr_cassette "cpanel/sub_domain/add"

      it "adds a subdomain" do
        # Delete the subdomain first
        @subd.remove(:domain => "sub.lumberg-test.com")

        result = @subd.add(
          :domain     => "sub",
          :rootdomain => "lumberg-test.com"
        )
        result[:params][:data][0][:result].should == 1
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lumberg-2.0.0.pre4 spec/cpanel/sub_domain_spec.rb
lumberg-2.0.0.pre3 spec/cpanel/sub_domain_spec.rb