Sha256: 5386acaf367d104bf66af5c2438b3e558547031cbf33dbb166a8588eac925086

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe Berkshelf::API::SrvCtl do
  describe "ClassMethods" do
    describe "::parse_options" do
      let(:args) { Array.new }
      let(:filename) { "berks-api" }

      subject { described_class.parse_options(args, filename) }

      it "returns a hash" do
        expect(subject).to be_a(Hash)
      end

      context "given -p" do
        let(:args) { ["-p", "1234"] }

        it "sets :pid_file to the given value" do
          expect(subject[:port]).to eql(1234)
        end
      end

      context "given -v" do
        let(:args) { ["-v"] }

        it "sets :log_level to INFO" do
          expect(subject[:log_level]).to eql("INFO")
        end
      end

      context "given -d" do
        let(:args) { ["-d"] }

        it "sets :log_level to DEBUG" do
          expect(subject[:log_level]).to eql("DEBUG")
        end
      end

      context "given -q" do
        let(:args) { ["-q"] }

        it "sets :log_location to /dev/null" do
          expect(subject[:log_location]).to eql("/dev/null")
        end
      end

      context "given -v and -d" do
        let(:args) { ["-v", "-d"] }

        it "sets :log_level to DEBUG" do
          expect(subject[:log_level]).to eql("DEBUG")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
berkshelf-api-0.1.0 spec/unit/berkshelf/api/srv_ctl_spec.rb