spec/noip/credentials_spec.rb in noip-0.1 vs spec/noip/credentials_spec.rb in noip-0.2
- old
+ new
@@ -1,71 +1,20 @@
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
+ subject(:credentials) { Noip::Credentials.new('username', 'password', 'host') }
- describe 'username' do
- subject(:username) { Noip::Credentials.new(username, password, host).username }
+ describe '.username' do
+ subject(:username) { credentials.username }
+ it { is_expected.to eq 'username' }
+ end
- context 'with values provided' do
- let(:username) { 'provided_username'}
- let(:password) { 'provided_password'}
- let(:host) { 'provided_host'}
+ describe '.password' do
+ subject(:password) { credentials.password }
+ it { is_expected.to eq 'password' }
+ end
- 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
+ describe '.host' do
+ subject(:host) { credentials.host }
+ it { is_expected.to eq 'host' }
end
end