Sha256: 93ef3b45cbeaa5480843e604da3ee0f1229e4093a5de4b0e89d16b7614a5a02f

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe PhoneGap::Build::Credentials do

  subject { PhoneGap::Build::Credentials .instance }

  describe '#load' do

    context 'when run in the context fo bundler' do

      before do
        ENV.stub(:[]).with('BUNDLE_GEMFILE').and_return(File.join(ROOT_DIR, 'Gemfile'))
      end

      context 'and a config file exists' do

        let(:config_file) { File.expand_path('config/phonegap.yml', ROOT_DIR) }
        let(:config_double) { double('config') }
        let(:erb_double) { double('erb', :result => config_file) }

        before do
          File.stub(:exists?).with(config_file).and_return true
          File.stub(:read).with(config_file).and_return config_double
          ERB.stub(:new).with(config_double).and_return erb_double
        end


        it 'evaluates any embedded ruby' do
          expect(ERB).to receive(:new).with(config_double).and_return erb_double
          subject.load
        end

        it 'tries to load a phonegap config file' do
          expect(YAML).to receive(:load).with(config_file).and_return({})
          subject.load
        end

        context 'if a token exists in config' do

          before do
            YAML.stub(:load).and_return({'token' => 'BATMAN'})
          end

          it 'populates the credentials using values from the config file' do
            subject.load
            expect(subject.token).to eq 'BATMAN'
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phone_gap-build-0.7.0 spec/phone_gap/build/credentials_spec.rb