Sha256: 69aec36dcd405a5947d47ebd6d69079bd99ebc4b035c665d2a353d08e2deb625

Contents?: true

Size: 1.01 KB

Versions: 18

Compression:

Stored size: 1.01 KB

Contents

require "spec_helper"

describe Ruboty::Env::Validatable do
  let(:validatable_class) do
    Class.new do
      include Ruboty::Env::Validatable

      env :A, "description of A"
      env :B, "description of B", optional: true
    end
  end

  let(:instance) do
    validatable_class.new
  end

  describe "#validate" do
    context "without required ENV" do
      it "raises Ruboty::Env::ValidationError" do
        expect { instance.validate }.to raise_error(Ruboty::Env::ValidationError)
      end
    end

    context "without optional ENV" do
      before do
        ENV["A"] = "dummy"
      end

      after do
        ENV["A"] = nil
      end

      it "does nothing" do
        expect { instance.validate }.not_to raise_error
      end
    end
  end

  describe "#validate!" do
    context "without required ENV" do
      it "dies with usage as erorr message" do
        Ruboty.logger.should_receive(:error).with(/description of A/)
        Ruboty.should_receive(:exit)
        instance.validate!
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ruboty-1.2.2 spec/ruboty/env/validatable_spec.rb
ruboty-1.2.1 spec/ruboty/env/validatable_spec.rb
ruboty-1.2.0 spec/ruboty/env/validatable_spec.rb
ruboty-1.1.9 spec/ruboty/env/validatable_spec.rb
ruboty-1.1.8 spec/ruboty/env/validatable_spec.rb
ruboty-1.1.7 spec/ruboty/env/validatable_spec.rb
ruboty-1.1.6 spec/ruboty/env/validatable_spec.rb
ruboty-1.1.5 spec/ruboty/env/validatable_spec.rb
ruboty-1.1.4 spec/ruboty/env/validatable_spec.rb
ruboty-1.1.3 spec/ruboty/env/validatable_spec.rb
ruboty-1.1.2 spec/ruboty/env/validatable_spec.rb
ruboty-1.1.1 spec/ruboty/env/validatable_spec.rb
ruboty-1.1.0 spec/ruboty/env/validatable_spec.rb
ruboty-1.0.4 spec/ruboty/env/validatable_spec.rb
ruboty-1.0.3 spec/ruboty/env/validatable_spec.rb
ruboty-1.0.2 spec/ruboty/env/validatable_spec.rb
ruboty-1.0.1 spec/ruboty/env/validatable_spec.rb
ruboty-1.0.0 spec/ruboty/env/validatable_spec.rb