require 'spec_helper' tmpdir = Dir.mktmpdir GITHUB_FP = "SHA1 Fingerprint=A0:C4:A7:46:00:ED:A7:2D:C0:BE:CB:9A:8C:B6:07:CA:58:EE:74:5E" GITHUB_CERT = < "the-account" File.should_receive(:open) invoke end end describe_command 'init -a the-account' do it "writes config file" do File.should_receive(:open) invoke end end end describe_command 'init -a the-account -h foobar' do it "can't get the cert" do expect { invoke }.to raise_error(GLI::CustomExit, /unable to retrieve certificate/i) end end # KEG: These tests have a nasty habit of hanging # describe_command 'init -a the-account -h google.com' do # it "writes the config and cert" do # HighLine.any_instance.stub(:ask).and_return "yes" # File.should_receive(:open).twice # invoke # end # end # describe_command 'init -a the-account -h https://google.com' do # it "writes the config and cert" do # HighLine.any_instance.stub(:ask).and_return "yes" # File.should_receive(:open).twice # invoke # end # end describe_command 'init -a the-account -h localhost -c the-cert' do it "writes config and cert files" do File.should_receive(:open).twice invoke end end context "in a temp dir" do describe_command "init -f #{tmpdir}/.conjurrc -a the-account -h localhost -c the-cert" do it "writes config and cert files" do invoke expect(YAML.load(File.read(File.join(tmpdir, ".conjurrc")))).to eq({ account: 'the-account', appliance_url: "https://localhost/api", cert_file: "#{tmpdir}/conjur-the-account.pem", plugins: [], }.stringify_keys) File.read(File.join(tmpdir, "conjur-the-account.pem")).should == "the-cert\n" end end end end end