<commit_before>require "spec_helper"
require "heroku/command/base"

module Heroku::Command
  describe Base do
    before do
      @base = Base.new
      @base.stub!(:display)
      @client = mock('heroku client', :host => 'heroku.com')
    end

    describe "confirming" do
      it "confirms the app via --confirm" do
        @base.stub(:app).and_return("myapp")
        @base.stub(:options).and_return(:confirm => "myapp")
        @base.confirm_command.should be_true
      end

      it "does not confirms the app via --confirm on a mismatch" do
        @base.stub(:app).and_return("myapp")
        @base.stub(:options).and_return(:confirm => "badapp")
        lambda { @base.confirm_command}.should raise_error CommandFailed
      end

      it "confirms the app interactively via ask" do
        @base.stub(:app).and_return("myapp")
        @base.stub(:ask).and_return("myapp")
        @base.confirm_command.should be_true
      end

      it "fails if the interactive confirm doesn't match" do
        @base.stub(:app).and_return("myapp")
        @base.stub(:ask).and_return("badresponse")
        @base.confirm_command.should be_false
      end
    end

    context "detecting the app" do
      it "attempts to find the app via the --app option" do
        @base.stub!(:options).and_return(:app => "myapp")
        @base.app.should == "myapp"
      end

      it "read remotes from git config" do
        Dir.stub(:chdir)
        @base.should_receive(:git).with('remote -v').and_return(<<-REMOTES)
<EMAIL>\<EMAIL>:myapp-staging.git (fetch)
<EMAIL>:myapp-staging.git (push)
<EMAIL>\<EMAIL>:myapp.git (fetch)
<EMAIL>:myapp.git (push)
<EMAIL>:other.git (fetch)
<EMAIL>:other.git (push)
        REMOTES

        @heroku = mock<commit_msg>fix for base_spec when not a git repo closes #280<commit_after>require "spec_helper"
require "heroku/command/base"

module Heroku::Command
  describe Base do
    before do
      @base = Base.new
      @base.stub!(:display)
      @client = mock('heroku client', :host => 'heroku.com')
    end

    describe "confirming" do
      it "confirms the app via --confirm" do
        @base.stub(:app).and_return("myapp")
        @base.stub(:options).and_return(:confirm => "myapp")
        @base.confirm_command.should be_true
      end

      it "does not confirms the app via --confirm on a mismatch" do
        @base.stub(:app).and_return("myapp")
        @base.stub(:options).and_return(:confirm => "badapp")
        lambda { @base.confirm_command}.should raise_error CommandFailed
      end

      it "confirms the app interactively via ask" do
        @base.stub(:app).and_return("myapp")
        @base.stub(:ask).and_return("myapp")
        @base.confirm_command.should be_true
      end

      it "fails if the interactive confirm doesn't match" do
        @base.stub(:app).and_return("myapp")
        @base.stub(:ask).and_return("badresponse")
        @base.confirm_command.should be_false
      end
    end

    context "detecting the app" do
      it "attempts to find the app via the --app option" do
        @base.stub!(:options).and_return(:app => "myapp")
        @base.app.should == "myapp"
      end

      it "read remotes from git config" do
        Dir.stub(:chdir)
        File.should_receive(:exists?).with(".git").and_return(true)
        @base.should_receive(:git).with('remote -v').and_return(<<-REMOTES)
<EMAIL>:myapp-staging.git (fetch)
<EMAIL>:myapp-staging.git (push)
<EMAIL>:myapp.git (fetch)
<EMAIL>:myapp.git (push)
<EMAIL>:other.git (fetch)
<EMAIL>:other.git (push)
        REMOTES

        @heroku = mock
{'fraction_non_alphanumeric': 0.1392156862745098, 'fraction_numerical': 0.0008403361344537816, 'mean_word_length': 2.868905742145179, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, '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': '6938137', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1166, 'n_words': 269}