<commit_before>require 'spec_helper'

describe Travis::Build::Script::Addons::Deploy do
  let(:script) { stub('script') }

  before(:each) { script.stubs(:fold).yields(script) }
  subject { described_class.new(script, config) }

  describe 'minimal config' do
    let(:config) {{ provider: "heroku", password: '<PASSWORD>', email: 'user<EMAIL>' }}

    it 'runs the command' do
      script.expects(:run_stage).with(:before_deploy)
      script.expects(:if).with('($TRAVIS_PULL_REQUEST = false) && ($TRAVIS_BRANCH = master)').yields(script)
      script.expects(:cmd).with('rvm 1.9.3 do gem install dpl', assert: true, echo: false)
      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="heroku" --password="<PASSWORD>" --email="user@<EMAIL>" --fold;
        if [ $? -ne 0 ]; then echo "failed to deploy"; travis_terminate 2; fi
      DPL
      script.expects(:run_stage).with(:after_deploy)
      subject.deploy
    end
  end


  describe 'implicit branches' do
    let(:config) {{ provider: "heroku", app: { staging: "foo", production: "bar" } }}

    before do
      script.stubs(:data).returns(stub('data', branch: 'staging'))
    end

    it 'runs the command' do
      script.expects(:run_stage).with(:before_deploy)
      script.expects(:if).with('($TRAVIS_PULL_REQUEST = false) && ($TRAVIS_BRANCH = staging || $TRAVIS_BRANCH = production)').yields(script)
      script.expects(:cmd).with('rvm 1.9.3 do gem install dpl', assert: true, echo: false)
      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="heroku" --app="foo" --fold;
        if [ $? -ne 0 ]; then echo "failed to deploy"; travis_terminate 2; fi
      DPL
      script.expects(:run_stage).with(:after_deploy)
      subject.deploy
    end
  end

  describe 'on tags' do
    let(:config) {{ provider: "heroku", on: { tags: true } }}

    it 'runs the command' do
      script.expects(:run_stage).with(:before_deploy)
      script.expects(:if).with('($TRAVIS_PULL_REQUEST = false) && ($TRAVIS_BRANCH = master) && ($(git describe --exact-match))').yields(script)
      script.expects(:cmd).with('rvm 1.9.3 do gem install dpl', assert: true, echo: false)
      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="heroku" --fold;
        if [ $? -ne 0 ]; then echo "failed to deploy"; travis_terminate 2; fi
      DPL
      script.expects(:run_stage).with(:after_deploy)
      subject.deploy
    end
  end

  describe 'multiple providers' do
    let(:config) { [{provider: "heroku", password: "<PASSWORD>", email: "<EMAIL>"}, {provider: "nodejitsu", user: "foo", api_key: "bar"}] }

    it 'runs the command' do
      script.expects(:run_stage).with(:before_deploy).twice
      script.expects(:if).with('($TRAVIS_PULL_REQUEST = false) && ($TRAVIS_BRANCH = master)').yields(script).twice
      script.expects(:cmd).with('rvm 1.9.3 do gem install dpl', assert: true, echo: false).twice
      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="heroku" --password="<PASSWORD>" --email="<EMAIL>" --fold;
        if [ $? -ne 0 ]; then echo "failed to deploy"; travis_terminate 2; fi
      DPL
      script.expects(:run_stage).with(:after_deploy).twice

      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="nodejitsu" --user="foo" --api_key="bar" --fold;
        if [ $? -ne 0 ]; then echo "failed to deploy"; travis_terminate 2; fi
      DPL
      subject.deploy
    end
  end

  describe 'allow_failure' do
    let(:config) {{ provider: "heroku", password: '<PASSWORD>', email: 'user@host', allow_failure: true }}

    it 'runs the command' do
      script.expects(:run_stage).with(:before_deploy)
      script.expects(:if).with('($TRAVIS_PULL_REQUEST = false) && ($TRAVIS_BRANCH = master)').yields(script)
      script.expects(:cmd).with('rvm 1.9.3 do gem install dpl', assert: false, echo: false)
      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="heroku" --password="<PASSWORD>" --email="user@host" --fold
      DPL
      script.expects(:run_stage).with(:after_deploy)
      subject.deploy
    end
  end
end
<commit_msg>correct a deploy spec<commit_after>require 'spec_helper'

describe Travis::Build::Script::Addons::Deploy do
  let(:script) { stub('script') }

  before(:each) { script.stubs(:fold).yields(script) }
  subject { described_class.new(script, config) }

  describe 'minimal config' do
    let(:config) {{ provider: "heroku", password: '<PASSWORD>', email: 'user@host' }}

    it 'runs the command' do
      script.expects(:run_stage).with(:before_deploy)
      script.expects(:if).with('($TRAVIS_PULL_REQUEST = false) && ($TRAVIS_BRANCH = master)').yields(script)
      script.expects(:cmd).with('rvm 1.9.3 do gem install dpl', assert: true, echo: false)
      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="heroku" --password="<PASSWORD>" --email="user<EMAIL>" --fold;
        if [ $? -ne 0 ]; then echo "failed to deploy"; travis_terminate 2; fi
      DPL
      script.expects(:run_stage).with(:after_deploy)
      subject.deploy
    end
  end


  describe 'implicit branches' do
    let(:config) {{ provider: "heroku", app: { staging: "foo", production: "bar" } }}

    before do
      script.stubs(:data).returns(stub('data', branch: 'staging'))
    end

    it 'runs the command' do
      script.expects(:run_stage).with(:before_deploy)
      script.expects(:if).with('($TRAVIS_PULL_REQUEST = false) && ($TRAVIS_BRANCH = staging || $TRAVIS_BRANCH = production)').yields(script)
      script.expects(:cmd).with('rvm 1.9.3 do gem install dpl', assert: true, echo: false)
      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="heroku" --app="foo" --fold;
        if [ $? -ne 0 ]; then echo "failed to deploy"; travis_terminate 2; fi
      DPL
      script.expects(:run_stage).with(:after_deploy)
      subject.deploy
    end
  end

  describe 'on tags' do
    let(:config) {{ provider: "heroku", on: { tags: true } }}

    it 'runs the command' do
      script.expects(:run_stage).with(:before_deploy)
      script.expects(:if).with('($TRAVIS_PULL_REQUEST = false) && ($TRAVIS_BRANCH = master) && ($(git describe --tags --exact-match))').yields(script)
      script.expects(:cmd).with('rvm 1.9.3 do gem install dpl', assert: true, echo: false)
      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="heroku" --fold;
        if [ $? -ne 0 ]; then echo "failed to deploy"; travis_terminate 2; fi
      DPL
      script.expects(:run_stage).with(:after_deploy)
      subject.deploy
    end
  end

  describe 'multiple providers' do
    let(:config) { [{provider: "heroku", password: "<PASSWORD>", email: "<EMAIL>"}, {provider: "nodejitsu", user: "foo", api_key: "bar"}] }

    it 'runs the command' do
      script.expects(:run_stage).with(:before_deploy).twice
      script.expects(:if).with('($TRAVIS_PULL_REQUEST = false) && ($TRAVIS_BRANCH = master)').yields(script).twice
      script.expects(:cmd).with('rvm 1.9.3 do gem install dpl', assert: true, echo: false).twice
      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="heroku" --password="<PASSWORD>" --email="<EMAIL>" --fold;
        if [ $? -ne 0 ]; then echo "failed to deploy"; travis_terminate 2; fi
      DPL
      script.expects(:run_stage).with(:after_deploy).twice

      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="nodejitsu" --user="foo" --api_key="bar" --fold;
        if [ $? -ne 0 ]; then echo "failed to deploy"; travis_terminate 2; fi
      DPL
      subject.deploy
    end
  end

  describe 'allow_failure' do
    let(:config) {{ provider: "heroku", password: '<PASSWORD>', email: 'user@host', allow_failure: true }}

    it 'runs the command' do
      script.expects(:run_stage).with(:before_deploy)
      script.expects(:if).with('($TRAVIS_PULL_REQUEST = false) && ($TRAVIS_BRANCH = master)').yields(script)
      script.expects(:cmd).with('rvm 1.9.3 do gem install dpl', assert: false, echo: false)
      script.expects(:cmd).with(<<-DPL.gsub(/\s+/, ' ').strip, assert: false, echo: false)
        rvm 1.9.3 do dpl --provider="heroku" --password="<PASSWORD>" --email="user@host" --fold
      DPL
      script.expects(:run_stage).with(:after_deploy)
      subject.deploy
    end
  end
end

{'fraction_non_alphanumeric': 0.18029823768639855, 'fraction_numerical': 0.009715318572074107, 'mean_word_length': 3.3632331197634304, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '4803123', 'n_tokens_mistral': 3188, 'n_tokens_neox': 3063, 'n_words': 700}