Sha256: 7107fc9cdd4b3f202dea067a417284c10512645847122aeafa7f97d69782d3d6

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

require 'spec_helper'
require 'feroxbuster/command'

describe Feroxbuster::Command do
  describe described_class::StatusCode do
    describe "#initialize" do
      it "must set #range to 100..599 by default" do
        expect(subject.range).to eq(100..599)
      end
    end
  end

  describe described_class::TimeSpec do
    describe "#validate" do
      context "when given nil" do
        let(:value) { nil }

        it "must return [false, \"cannot be nil\"]" do
          expect(subject.validate(value)).to eq(
            [false, "cannot be nil"]
          )
        end
      end

      context "when given a String" do
        context "when given an empty String" do
          let(:value) { "" }

          it "must return [false, \"does not allow an empty value\"]" do
            expect(subject.validate(value)).to eq(
              [false, "does not allow an empty value"]
            )
          end
        end

        context "when given a number" do
          let(:value) { "10" }

          it "must return [false, \"must be a number and end with 'm', 's', 'ms', or 'ns'\"]" do
            expect(subject.validate(value)).to eq(
              [false, "must be a number and end with 'm', 's', 'ms', or 'ns'"]
            )
          end
        end

        context "when given a number that ends with a unit" do
          let(:value) { "10s" }

          it "must return true" do
            expect(subject.validate(value)).to be(true)
          end

          context "but the unit isn't recognized" do
            let(:value) { "10x" }

            it "must return [false, \"must be a number and end with 'm', 's', 'ms', or 'ns'\"]" do
              expect(subject.validate(value)).to eq(
                [false, "must be a number and end with 'm', 's', 'ms', or 'ns'"]
              )
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-feroxbuster-0.1.0 spec/command_spec.rb