Sha256: 2b32e963f4bcce21e4f5bee2f642c864d10e0e0dd94f68558a23ef1a49e9a276

Contents?: true

Size: 1.45 KB

Versions: 13

Compression:

Stored size: 1.45 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

      context "given -c" do
        let(:args) { ["-c", "/path/to/config"] }

        it "sets :config_file to the given value" do
          expect(subject[:config_file]).to eql("/path/to/config")
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
berkshelf-api-2.0.0 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-1.4.0 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-1.3.1 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-1.3.0 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-1.2.2 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-1.2.1 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-1.2.0 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-1.2.0.rc2 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-1.2.0.rc1 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-1.1.1 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-1.1.0 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-1.0.0 spec/unit/berkshelf/api/srv_ctl_spec.rb
berkshelf-api-0.2.0 spec/unit/berkshelf/api/srv_ctl_spec.rb