<commit_before>require './spec/spec_helper'

require './lib/gas'

require 'rspec/mocks'
require 'rspec/mocks/standalone'

describe Gas::Ssh do

  before :each do
    @uid = "teddy"
  end

  describe "SSH key file handling..." do

    before :all do
      Gas::Prompter.stub!(:user_wants_to_delete_all_ssh_data?).and_return("l")  # only delete's local keys
    end

    after :all do
      Gas::Prompter.unstub!(:user_wants_to_delete_all_ssh_data?)
    end

    describe "Detecting when files are missing..." do
      it "should detect when an id_rsa isn't in the .gas directory" do
        Gas::Ssh.corresponding_rsa_files_exist?(@uid).should be_false
      end
    end

    describe "Detecting when files exist..." do
      before :each do
        create_user_no_git @uid, @uid, "<EMAIL>"
      end

      after :each do
        delete_user_no_git @uid
      end

      it 'should detect when an id_rsa is already in the .gas directory', :current => true do
        Gas::Ssh.corresponding_rsa_files_exist?(@uid).should be_true
      end

    end

    describe "File System Changes..." do

      before :all do
        @gas_dir = File.expand_path('~/.gas')
        @ssh_dir = File.expand_path('~/.ssh')


        @nickname = "thisaccountmaybedeletedmysteriously"
        @name = "<NAME>"
        @email = "<EMAIL>"

        `rm #{@gas_dir}/#{@nickname}_id_rsa`
        `rm #{@gas_dir}/#{@nickname}_id_rsa.pub`
        Gas.delete(@nickname)

        # make sure that nickname isn't in use
      end


      it 'should create ssh keys in .gas && Gas.remove should be able to remove those files' do
        STDIN.stub!(:gets).and_return("y\n")          # forces the dialogs to
        Gas::Ssh.stub!(:upload_public_key_to_github).and_return(false)

        lambda do
          Gas.add(@nickname,@name,@email)
        end.should change{`ls ~/.gas -1 | wc -l`.to_i}.by(2)   #OMG THIS IS A FUN TEST!!!

        lambda do<commit_msg>commented out some junk in a before filter that probably can be removed<commit_after>require './spec/spec_helper'

require './lib/gas'

require 'rspec/mocks'
require 'rspec/mocks/standalone'

describe Gas::Ssh do

  before :each do
    @uid = "teddy"
  end

  describe "SSH key file handling..." do

    before :all do
      Gas::Prompter.stub!(:user_wants_to_delete_all_ssh_data?).and_return("l")  # only delete's local keys
    end

    after :all do
      Gas::Prompter.unstub!(:user_wants_to_delete_all_ssh_data?)
    end

    describe "Detecting when files are missing..." do
      it "should detect when an id_rsa isn't in the .gas directory" do
        Gas::Ssh.corresponding_rsa_files_exist?(@uid).should be_false
      end
    end

    describe "Detecting when files exist..." do
      before :each do
        create_user_no_git @uid, @uid, "a@b.com"
      end

      after :each do
        delete_user_no_git @uid
      end

      it 'should detect when an id_rsa is already in the .gas directory', :current => true do
        Gas::Ssh.corresponding_rsa_files_exist?(@uid).should be_true
      end
    end

    describe "File System Changes..." do
      before :all do
        # @gas_dir = File.expand_path('~/.gas')
        # @ssh_dir = File.expand_path('~/.ssh')

        @nickname = "thisaccountmaybedeletedmysteriously"
        @name = "<NAME>"
        @email = "<EMAIL>"

        #`rm #{@gas_dir}/#{@nickname}_id_rsa`
        #`rm #{@gas_dir}/#{@nickname}_id_rsa.pub`
        Gas.delete(@nickname)
      end


      it 'should create ssh keys in .gas && Gas.remove should be able to remove those files' do
        STDIN.stub!(:gets).and_return("y\n")          # forces the dialogs to
        Gas::Ssh.stub!(:upload_public_key_to_github).and_return(false)

        lambda do
          Gas.add(@nickname,@name,@email)
        end.should change{`ls ~/.gas -1 | wc -l`.to_i}.by(2)   #OMG THIS IS A FUN TEST!!!

        lambda do
{'fraction_non_alphanumeric': 0.12005174644243208, 'fraction_numerical': 0.001034928848641656, 'mean_word_length': 2.546788990825688, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1436405', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1273, 'n_words': 342}