Sha256: 930c9a8f4a35cca2fac7200f0356c6336eb1100b677b5b665049f420b1096e20

Contents?: true

Size: 1.63 KB

Versions: 9

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe NightcrawlerSwift::Options do

  subject do
    NightcrawlerSwift::Options.new opts
  end

  let :opts do
    {}
  end

  describe "initialization" do
    context "verify_ssl" do
      it "defauts to false" do
        expect(subject.verify_ssl).to eql false
      end
    end

    context "retries" do
      it "defauts to 5" do
        expect(subject.retries).to eql 5
      end
    end

    context "max_retry_time" do
      it "defauts to 30" do
        expect(subject.max_retry_time).to eql 30
      end
    end

    context "password" do
      before do
        expect(ENV).to receive(:[]).with("NSWIFT_PASSWORD").and_return("123")
      end

      it "can be defined by the ENV variable 'NSWIFT_PASSWORD'" do
        expect(subject.password).to eql "123"
      end

      context "when configured" do
        let :opts do
          {password: "345"}
        end

        it "takes the ENV variable in precedence" do
          expect(subject.password).to eql "123"
        end
      end
    end

    context "and max_age isn't an integer" do
      let(:opts) { {max_age: "a string"} }

      it "raises NightcrawlerSwift::Exceptions::ConfigurationError" do
        expect { subject }.to raise_error(NightcrawlerSwift::Exceptions::ConfigurationError)
      end
    end

    context "when configured" do
      let :opts do
        {
          bucket: "rogue",
          password: "123",
          retries: 2
        }
      end

      it "creates with the given values" do
        expect(subject.bucket).to eql "rogue"
        expect(subject.password).to eql "123"
        expect(subject.retries).to eql 2
      end
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
nightcrawler_swift-1.0.0 spec/lib/nightcrawler_swift/options_spec.rb
nightcrawler_swift-0.11.1 spec/lib/nightcrawler_swift/options_spec.rb
nightcrawler_swift-0.11.0 spec/lib/nightcrawler_swift/options_spec.rb
nightcrawler_swift-0.10.0 spec/lib/nightcrawler_swift/options_spec.rb
nightcrawler_swift-0.9.0 spec/lib/nightcrawler_swift/options_spec.rb
nightcrawler_swift-0.8.1 spec/lib/nightcrawler_swift/options_spec.rb
nightcrawler_swift-0.8.0 spec/lib/nightcrawler_swift/options_spec.rb
nightcrawler_swift-0.7.0 spec/lib/nightcrawler_swift/options_spec.rb
nightcrawler_swift-0.6.0 spec/lib/nightcrawler_swift/options_spec.rb