Sha256: 27006bd8cca9299822db0a982054e86c27d34d29f0964577d63f593f271b490e

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

require 'spec_helper'

describe Noip::Credentials do
  context 'with ENV variables set' do
    before do
      allow(ENV).to receive(:[]).with('NOIP_USERNAME').and_return('env_noip_username')
      allow(ENV).to receive(:[]).with('NOIP_PASSWORD').and_return('env_noip_password')
      allow(ENV).to receive(:[]).with('NOIP_HOST').and_return('env_noip_host')
    end

    describe 'username' do
      subject(:username) { Noip::Credentials.new(username, password, host).username }

      context 'with values provided' do
        let(:username) { 'provided_username'}
        let(:password) { 'provided_password'}
        let(:host)     { 'provided_host'}

        it { is_expected.to eq 'provided_username' }
      end

      context 'with no values provided' do
        let(:username) { nil }
        let(:password) { nil }
        let(:host)     { nil }

        it { is_expected.to eq 'env_noip_username' }
      end
    end

    describe 'password' do
      subject(:password) { Noip::Credentials.new(username, password, host).password }

      context 'with values provided' do
        let(:username) { 'provided_username'}
        let(:password) { 'provided_password'}
        let(:host)     { 'provided_host'}

        it { is_expected.to eq 'provided_password' }
      end

      context 'with no values provided' do
        let(:username) { nil }
        let(:password) { nil }
        let(:host)     { nil }

        it { is_expected.to eq 'env_noip_password' }
      end
    end

    describe 'host' do
      subject(:host) { Noip::Credentials.new(username, password, host).host }

      context 'with values provided' do
        let(:username) { 'provided_username'}
        let(:password) { 'provided_password'}
        let(:host)     { 'provided_host'}

        it { is_expected.to eq 'provided_host' }
      end

      context 'with no values provided' do
        let(:username) { nil }
        let(:password) { nil }
        let(:host)     { nil }

        it { is_expected.to eq 'env_noip_host' }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
noip-0.1 spec/noip/credentials_spec.rb