zenflow 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gitignore +6 -0
 - data/.rspec +2 -0
 - data/.ruby-gemset +1 -0
 - data/.ruby-version +1 -0
 - data/.zenflow +10 -0
 - data/CHANGELOG.md +0 -0
 - data/Gemfile +3 -0
 - data/Gemfile.lock +95 -0
 - data/Guardfile +6 -0
 - data/LICENSE.md +22 -0
 - data/README.markdown +92 -0
 - data/VERSION.yml +5 -0
 - data/bin/zenflow +17 -0
 - data/lib/zenflow.rb +35 -0
 - data/lib/zenflow/cli.rb +130 -0
 - data/lib/zenflow/commands/deploy.rb +33 -0
 - data/lib/zenflow/commands/feature.rb +10 -0
 - data/lib/zenflow/commands/hotfix.rb +15 -0
 - data/lib/zenflow/commands/release.rb +16 -0
 - data/lib/zenflow/commands/reviews.rb +12 -0
 - data/lib/zenflow/helpers/ask.rb +66 -0
 - data/lib/zenflow/helpers/branch.rb +80 -0
 - data/lib/zenflow/helpers/branch_command.rb +95 -0
 - data/lib/zenflow/helpers/branch_commands/abort.rb +21 -0
 - data/lib/zenflow/helpers/branch_commands/branches.rb +21 -0
 - data/lib/zenflow/helpers/branch_commands/compare.rb +20 -0
 - data/lib/zenflow/helpers/branch_commands/deploy.rb +29 -0
 - data/lib/zenflow/helpers/branch_commands/diff.rb +19 -0
 - data/lib/zenflow/helpers/branch_commands/finish.rb +68 -0
 - data/lib/zenflow/helpers/branch_commands/review.rb +58 -0
 - data/lib/zenflow/helpers/branch_commands/start.rb +39 -0
 - data/lib/zenflow/helpers/branch_commands/update.rb +22 -0
 - data/lib/zenflow/helpers/changelog.rb +100 -0
 - data/lib/zenflow/helpers/config.rb +36 -0
 - data/lib/zenflow/helpers/github.rb +40 -0
 - data/lib/zenflow/helpers/help.rb +37 -0
 - data/lib/zenflow/helpers/log.rb +21 -0
 - data/lib/zenflow/helpers/pull_request.rb +68 -0
 - data/lib/zenflow/helpers/repo.rb +13 -0
 - data/lib/zenflow/helpers/shell.rb +89 -0
 - data/lib/zenflow/helpers/version.rb +87 -0
 - data/lib/zenflow/version.rb +3 -0
 - data/spec/fixtures/VERSION.yml +5 -0
 - data/spec/fixtures/cassettes/create_bad_pull_request.yml +57 -0
 - data/spec/fixtures/cassettes/create_pull_request.yml +68 -0
 - data/spec/fixtures/cassettes/existing_pull_request.yml +145 -0
 - data/spec/fixtures/cassettes/pull_request_by_ref.yml +145 -0
 - data/spec/fixtures/cassettes/pull_request_find.yml +70 -0
 - data/spec/fixtures/cassettes/pull_request_for_non-existent_ref.yml +145 -0
 - data/spec/fixtures/cassettes/pull_request_list.yml +74 -0
 - data/spec/fixtures/cassettes/unexisting_pull_request.yml +145 -0
 - data/spec/spec_helper.rb +36 -0
 - data/spec/support/shared_examples_for_version_number.rb +19 -0
 - data/spec/zenflow/commands/deploy_spec.rb +48 -0
 - data/spec/zenflow/commands/feature_spec.rb +11 -0
 - data/spec/zenflow/commands/hotfix_spec.rb +14 -0
 - data/spec/zenflow/commands/release_spec.rb +15 -0
 - data/spec/zenflow/commands/reviews_spec.rb +15 -0
 - data/spec/zenflow/helpers/ask_spec.rb +115 -0
 - data/spec/zenflow/helpers/branch_command_spec.rb +310 -0
 - data/spec/zenflow/helpers/branch_spec.rb +300 -0
 - data/spec/zenflow/helpers/changelog_spec.rb +188 -0
 - data/spec/zenflow/helpers/cli_spec.rb +277 -0
 - data/spec/zenflow/helpers/github_spec.rb +45 -0
 - data/spec/zenflow/helpers/help_spec.rb +36 -0
 - data/spec/zenflow/helpers/log_spec.rb +31 -0
 - data/spec/zenflow/helpers/pull_request_spec.rb +108 -0
 - data/spec/zenflow/helpers/shell_spec.rb +135 -0
 - data/spec/zenflow/helpers/version_spec.rb +111 -0
 - data/zenflow.gemspec +33 -0
 - metadata +273 -0
 
| 
         @@ -0,0 +1,277 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Zenflow::CLI do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              subject {Zenflow::CLI.new}
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              describe "#version" do
         
     | 
| 
      
 8 
     | 
    
         
            +
                it 'outputs the version number' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                  subject.should_receive(:puts).with("Zenflow #{Zenflow::VERSION}")
         
     | 
| 
      
 10 
     | 
    
         
            +
                  subject.version
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              describe "#help" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                it 'displays helpful information' do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  subject.should_receive(:version)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  $stdout.should_receive(:puts).at_least(:once)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  subject.help
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              describe "#authorize_github" do
         
     | 
| 
      
 23 
     | 
    
         
            +
                context "when a zenflow_token is already saved" do
         
     | 
| 
      
 24 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 25 
     | 
    
         
            +
                    Zenflow::Github.should_receive(:zenflow_token).and_return('super secret token')
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  context "and the user decides to set a new one" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 30 
     | 
    
         
            +
                      Zenflow.should_receive(:Ask).and_return('y')
         
     | 
| 
      
 31 
     | 
    
         
            +
                    end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                    it "authorizes with Github" do
         
     | 
| 
      
 34 
     | 
    
         
            +
                      Zenflow::Github.should_receive(:authorize)
         
     | 
| 
      
 35 
     | 
    
         
            +
                      subject.authorize_github
         
     | 
| 
      
 36 
     | 
    
         
            +
                    end
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  context "and the user decides not to set a new one" do
         
     | 
| 
      
 40 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 41 
     | 
    
         
            +
                      Zenflow.should_receive(:Ask).and_return('n')
         
     | 
| 
      
 42 
     | 
    
         
            +
                    end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    it "does not authorize with Github" do
         
     | 
| 
      
 45 
     | 
    
         
            +
                      Zenflow::Github.should_not_receive(:authorize)
         
     | 
| 
      
 46 
     | 
    
         
            +
                      subject.authorize_github
         
     | 
| 
      
 47 
     | 
    
         
            +
                    end
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                context "when a zenflow_token is not already saved" do
         
     | 
| 
      
 52 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 53 
     | 
    
         
            +
                    Zenflow::Github.should_receive(:zenflow_token).and_return(nil)
         
     | 
| 
      
 54 
     | 
    
         
            +
                  end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                  it "authorizes with Github" do
         
     | 
| 
      
 57 
     | 
    
         
            +
                    Zenflow::Github.should_receive(:authorize)
         
     | 
| 
      
 58 
     | 
    
         
            +
                    subject.authorize_github
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              describe "#already_configured" do
         
     | 
| 
      
 64 
     | 
    
         
            +
                let(:question) {['There is an existing config file. Overwrite it?', {:options => ["y", "N"], :default => "N"}]}
         
     | 
| 
      
 65 
     | 
    
         
            +
                before do
         
     | 
| 
      
 66 
     | 
    
         
            +
                  Zenflow.should_receive(:Log).with('Warning', :color => :red)
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                context "when the user wants to overwrite the configuration" do
         
     | 
| 
      
 70 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 71 
     | 
    
         
            +
                    Zenflow.should_receive(:Ask).with(*question).and_return('y')
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                  it "forces initialization" do
         
     | 
| 
      
 75 
     | 
    
         
            +
                    subject.should_receive(:init).with(true)
         
     | 
| 
      
 76 
     | 
    
         
            +
                    subject.already_configured
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                context "when the user does not want to overwrite the configuration" do
         
     | 
| 
      
 81 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 82 
     | 
    
         
            +
                    Zenflow.should_receive(:Ask).with(*question).and_return('n')
         
     | 
| 
      
 83 
     | 
    
         
            +
                  end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                  it "aborts" do
         
     | 
| 
      
 86 
     | 
    
         
            +
                    Zenflow.should_receive(:Log).with('Aborting...', :color => :red)
         
     | 
| 
      
 87 
     | 
    
         
            +
                    lambda{ subject.already_configured}.should raise_error(SystemExit)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
              end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
              describe "#configure_branch" do
         
     | 
| 
      
 93 
     | 
    
         
            +
                context "when the user wants to configure a staging branch" do
         
     | 
| 
      
 94 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 95 
     | 
    
         
            +
                    Zenflow.should_receive(:Ask).with("Use a branch for staging releases and hotfixes?", :options => ["Y", "n"], :default => "Y").and_return('y')
         
     | 
| 
      
 96 
     | 
    
         
            +
                  end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                  it 'names the staging branch whatever the user wants' do
         
     | 
| 
      
 99 
     | 
    
         
            +
                    Zenflow.should_receive(:Ask).with("What is the name of that branch?", :default => "staging").and_return('staging')
         
     | 
| 
      
 100 
     | 
    
         
            +
                    Zenflow::Config.should_receive(:[]=).with(:staging_branch, 'staging')
         
     | 
| 
      
 101 
     | 
    
         
            +
                    subject.configure_branch(:staging_branch, "Use a branch for staging releases and hotfixes?", 'staging')
         
     | 
| 
      
 102 
     | 
    
         
            +
                  end
         
     | 
| 
      
 103 
     | 
    
         
            +
                end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                context "when the user does not want to configure a staging branch" do
         
     | 
| 
      
 106 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 107 
     | 
    
         
            +
                    Zenflow.should_receive(:Ask).with("Use a branch for staging releases and hotfixes?", :options => ["Y", "n"], :default => "Y").and_return('n')
         
     | 
| 
      
 108 
     | 
    
         
            +
                  end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                  it 'names the staging branch whatever the user wants' do
         
     | 
| 
      
 111 
     | 
    
         
            +
                    Zenflow::Config.should_receive(:[]=).with(:staging_branch, false)
         
     | 
| 
      
 112 
     | 
    
         
            +
                    subject.configure_branch(:staging_branch, "Use a branch for staging releases and hotfixes?", 'staging')
         
     | 
| 
      
 113 
     | 
    
         
            +
                  end
         
     | 
| 
      
 114 
     | 
    
         
            +
                end
         
     | 
| 
      
 115 
     | 
    
         
            +
              end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
              describe "#configure_project" do
         
     | 
| 
      
 118 
     | 
    
         
            +
                it 'asks the user to name their project' do
         
     | 
| 
      
 119 
     | 
    
         
            +
                  Zenflow.should_receive(:Ask).with("What is the name of this project?", :required => true).and_return('zenflow')
         
     | 
| 
      
 120 
     | 
    
         
            +
                  Zenflow.should_receive(:Log).with("Project")
         
     | 
| 
      
 121 
     | 
    
         
            +
                  Zenflow::Config.should_receive(:[]=).with(:project, 'zenflow')
         
     | 
| 
      
 122 
     | 
    
         
            +
                  subject.configure_project
         
     | 
| 
      
 123 
     | 
    
         
            +
                end
         
     | 
| 
      
 124 
     | 
    
         
            +
              end
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
              describe "#configure_branches" do
         
     | 
| 
      
 127 
     | 
    
         
            +
                it 'configures branches for the project' do
         
     | 
| 
      
 128 
     | 
    
         
            +
                  Zenflow.should_receive(:Ask).with("What is the name of the main development branch?", :default => "master").and_return('master')
         
     | 
| 
      
 129 
     | 
    
         
            +
                  Zenflow.should_receive(:Log).with("Branches")
         
     | 
| 
      
 130 
     | 
    
         
            +
                  Zenflow::Config.should_receive(:[]=).with(:development_branch, 'master')
         
     | 
| 
      
 131 
     | 
    
         
            +
                  subject.should_receive(:configure_branch).exactly(3).times
         
     | 
| 
      
 132 
     | 
    
         
            +
                  subject.configure_branches
         
     | 
| 
      
 133 
     | 
    
         
            +
                end
         
     | 
| 
      
 134 
     | 
    
         
            +
              end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
              describe "#configure_remotes" do
         
     | 
| 
      
 137 
     | 
    
         
            +
                context "when the user wants to configure a backup remote" do
         
     | 
| 
      
 138 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 139 
     | 
    
         
            +
                    Zenflow.should_receive(:Ask).with("Use a backup remote?", :options => ["Y", "n"], :default => "n").and_return('y')
         
     | 
| 
      
 140 
     | 
    
         
            +
                  end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                  it 'configures the primary remote and a backup remote' do
         
     | 
| 
      
 143 
     | 
    
         
            +
                    Zenflow.should_receive(:Ask).with("What is the name of your primary remote?", :default => "origin").and_return('origin')
         
     | 
| 
      
 144 
     | 
    
         
            +
                    Zenflow::Config.should_receive(:[]=).with(:remote, 'origin')
         
     | 
| 
      
 145 
     | 
    
         
            +
                    Zenflow.should_receive(:Ask).with("What is the name of your backup remote?", :default => "backup").and_return('backup')
         
     | 
| 
      
 146 
     | 
    
         
            +
                    Zenflow::Config.should_receive(:[]=).with(:backup_remote, 'backup')
         
     | 
| 
      
 147 
     | 
    
         
            +
                    subject.configure_remotes
         
     | 
| 
      
 148 
     | 
    
         
            +
                  end
         
     | 
| 
      
 149 
     | 
    
         
            +
                end
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
                context "when the user does not want to configure a backup remote" do
         
     | 
| 
      
 152 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 153 
     | 
    
         
            +
                    Zenflow.should_receive(:Ask).with("Use a backup remote?", :options => ["Y", "n"], :default => "n").and_return('n')
         
     | 
| 
      
 154 
     | 
    
         
            +
                  end
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
                  it 'configures the primary remote and a backup remote' do
         
     | 
| 
      
 157 
     | 
    
         
            +
                    Zenflow.should_receive(:Ask).with("What is the name of your primary remote?", :default => "origin").and_return('origin')
         
     | 
| 
      
 158 
     | 
    
         
            +
                    Zenflow::Config.should_receive(:[]=).with(:remote, 'origin')
         
     | 
| 
      
 159 
     | 
    
         
            +
                    Zenflow.should_not_receive(:Ask).with("What is the name of your backup remote?", :default => "backup")
         
     | 
| 
      
 160 
     | 
    
         
            +
                    Zenflow::Config.should_receive(:[]=).with(:backup_remote, false)
         
     | 
| 
      
 161 
     | 
    
         
            +
                    subject.configure_remotes
         
     | 
| 
      
 162 
     | 
    
         
            +
                  end
         
     | 
| 
      
 163 
     | 
    
         
            +
                end
         
     | 
| 
      
 164 
     | 
    
         
            +
              end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
              describe "#set_up_changelog" do
         
     | 
| 
      
 167 
     | 
    
         
            +
                context "when the changelog doesn't already exist" do
         
     | 
| 
      
 168 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 169 
     | 
    
         
            +
                    File.should_receive(:exist?).with("CHANGELOG.md").and_return(false)
         
     | 
| 
      
 170 
     | 
    
         
            +
                    Zenflow.should_receive(:Log).with("Changelog Management")
         
     | 
| 
      
 171 
     | 
    
         
            +
                  end
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
                  context "when the user wants to set up a changelog" do
         
     | 
| 
      
 174 
     | 
    
         
            +
                    it 'sets up the changelog' do
         
     | 
| 
      
 175 
     | 
    
         
            +
                      Zenflow.should_receive(:Ask).with("Set up a changelog?", :options => ["Y", "n"], :default => "Y").and_return('y')
         
     | 
| 
      
 176 
     | 
    
         
            +
                      Zenflow::Changelog.should_receive(:create)
         
     | 
| 
      
 177 
     | 
    
         
            +
                      subject.set_up_changelog
         
     | 
| 
      
 178 
     | 
    
         
            +
                    end
         
     | 
| 
      
 179 
     | 
    
         
            +
                  end
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
                  context "when the user does not want to set up a changelog" do
         
     | 
| 
      
 182 
     | 
    
         
            +
                    it 'does not set up the changelog' do
         
     | 
| 
      
 183 
     | 
    
         
            +
                      Zenflow.should_receive(:Ask).with("Set up a changelog?", :options => ["Y", "n"], :default => "Y").and_return('n')
         
     | 
| 
      
 184 
     | 
    
         
            +
                      Zenflow::Changelog.should_not_receive(:create)
         
     | 
| 
      
 185 
     | 
    
         
            +
                      subject.set_up_changelog
         
     | 
| 
      
 186 
     | 
    
         
            +
                    end
         
     | 
| 
      
 187 
     | 
    
         
            +
                  end
         
     | 
| 
      
 188 
     | 
    
         
            +
                end
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                context "when the changelog already exists" do
         
     | 
| 
      
 191 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 192 
     | 
    
         
            +
                    File.should_receive(:exist?).with("CHANGELOG.md").and_return(true)
         
     | 
| 
      
 193 
     | 
    
         
            +
                  end
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
                  it 'does not set up the changelog' do
         
     | 
| 
      
 196 
     | 
    
         
            +
                    Zenflow.should_not_receive(:Log).with("Changelog Management")
         
     | 
| 
      
 197 
     | 
    
         
            +
                    Zenflow.should_not_receive(:Ask).with("Set up a changelog?", :options => ["Y", "n"], :default => "Y")
         
     | 
| 
      
 198 
     | 
    
         
            +
                    Zenflow::Changelog.should_not_receive(:create)
         
     | 
| 
      
 199 
     | 
    
         
            +
                    subject.set_up_changelog
         
     | 
| 
      
 200 
     | 
    
         
            +
                  end
         
     | 
| 
      
 201 
     | 
    
         
            +
                end
         
     | 
| 
      
 202 
     | 
    
         
            +
              end
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
      
 204 
     | 
    
         
            +
              describe "#confirm_some_stuff" do
         
     | 
| 
      
 205 
     | 
    
         
            +
                it "confirms staging deployment and code review requirements" do
         
     | 
| 
      
 206 
     | 
    
         
            +
                  Zenflow.should_receive(:Log).with("Confirmations")
         
     | 
| 
      
 207 
     | 
    
         
            +
                  Zenflow.should_receive(:Ask).with("Require deployment to a staging environment?", :options => ["Y", "n"], :default => "Y").and_return('y')
         
     | 
| 
      
 208 
     | 
    
         
            +
                  Zenflow::Config.should_receive(:[]=).with(:confirm_staging, true)
         
     | 
| 
      
 209 
     | 
    
         
            +
                  Zenflow.should_receive(:Ask).with("Require code reviews?", :options => ["Y", "n"], :default => "Y").and_return('n')
         
     | 
| 
      
 210 
     | 
    
         
            +
                  Zenflow::Config.should_receive(:[]=).with(:confirm_review, false)
         
     | 
| 
      
 211 
     | 
    
         
            +
                  subject.confirm_some_stuff
         
     | 
| 
      
 212 
     | 
    
         
            +
                end
         
     | 
| 
      
 213 
     | 
    
         
            +
              end
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
              describe "#init" do
         
     | 
| 
      
 216 
     | 
    
         
            +
                context "when zenflow has not been configured" do
         
     | 
| 
      
 217 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 218 
     | 
    
         
            +
                    Zenflow::Config.should_receive(:configured?).and_return(false)
         
     | 
| 
      
 219 
     | 
    
         
            +
                  end
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
                  it 'configures zenflow' do
         
     | 
| 
      
 222 
     | 
    
         
            +
                    subject.should_not_receive(:already_configured)
         
     | 
| 
      
 223 
     | 
    
         
            +
                    subject.should_receive(:set_up_github)
         
     | 
| 
      
 224 
     | 
    
         
            +
                    subject.should_receive(:authorize_github)
         
     | 
| 
      
 225 
     | 
    
         
            +
                    subject.should_receive(:configure_project)
         
     | 
| 
      
 226 
     | 
    
         
            +
                    subject.should_receive(:configure_branches)
         
     | 
| 
      
 227 
     | 
    
         
            +
                    subject.should_receive(:configure_remotes)
         
     | 
| 
      
 228 
     | 
    
         
            +
                    subject.should_receive(:confirm_some_stuff)
         
     | 
| 
      
 229 
     | 
    
         
            +
                    subject.should_receive(:set_up_changelog)
         
     | 
| 
      
 230 
     | 
    
         
            +
                    Zenflow::Config.should_receive(:save!)
         
     | 
| 
      
 231 
     | 
    
         
            +
                    subject.init
         
     | 
| 
      
 232 
     | 
    
         
            +
                  end
         
     | 
| 
      
 233 
     | 
    
         
            +
                end
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
                context "when zenflow has already been configured" do
         
     | 
| 
      
 236 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 237 
     | 
    
         
            +
                    Zenflow::Config.should_receive(:configured?).and_return(true)
         
     | 
| 
      
 238 
     | 
    
         
            +
                  end
         
     | 
| 
      
 239 
     | 
    
         
            +
             
     | 
| 
      
 240 
     | 
    
         
            +
                  context 'and it is forced to initialize' do
         
     | 
| 
      
 241 
     | 
    
         
            +
                    it 'configures zenflow' do
         
     | 
| 
      
 242 
     | 
    
         
            +
                      subject.should_not_receive(:already_configured)
         
     | 
| 
      
 243 
     | 
    
         
            +
                      subject.should_receive(:set_up_github)
         
     | 
| 
      
 244 
     | 
    
         
            +
                      subject.should_receive(:authorize_github)
         
     | 
| 
      
 245 
     | 
    
         
            +
                      subject.should_receive(:configure_project)
         
     | 
| 
      
 246 
     | 
    
         
            +
                      subject.should_receive(:configure_branches)
         
     | 
| 
      
 247 
     | 
    
         
            +
                      subject.should_receive(:configure_remotes)
         
     | 
| 
      
 248 
     | 
    
         
            +
                      subject.should_receive(:confirm_some_stuff)
         
     | 
| 
      
 249 
     | 
    
         
            +
                      subject.should_receive(:set_up_changelog)
         
     | 
| 
      
 250 
     | 
    
         
            +
                      Zenflow::Config.should_receive(:save!)
         
     | 
| 
      
 251 
     | 
    
         
            +
                      subject.init(true)
         
     | 
| 
      
 252 
     | 
    
         
            +
                    end
         
     | 
| 
      
 253 
     | 
    
         
            +
                  end
         
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
      
 255 
     | 
    
         
            +
                  context 'and it is forced to initialize' do
         
     | 
| 
      
 256 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 257 
     | 
    
         
            +
                      Zenflow.should_receive(:Log).with('Warning', :color => :red)
         
     | 
| 
      
 258 
     | 
    
         
            +
                      Zenflow.should_receive(:Ask).and_return('n')
         
     | 
| 
      
 259 
     | 
    
         
            +
                      Zenflow.should_receive(:Log).with('Aborting...', :color => :red)
         
     | 
| 
      
 260 
     | 
    
         
            +
                    end
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
                    it 'calls already_configured' do
         
     | 
| 
      
 263 
     | 
    
         
            +
                      subject.should_receive(:already_configured).and_call_original
         
     | 
| 
      
 264 
     | 
    
         
            +
                      subject.should_not_receive(:authorize_github)
         
     | 
| 
      
 265 
     | 
    
         
            +
                      subject.should_not_receive(:configure_project)
         
     | 
| 
      
 266 
     | 
    
         
            +
                      subject.should_not_receive(:configure_branches)
         
     | 
| 
      
 267 
     | 
    
         
            +
                      subject.should_not_receive(:configure_remotes)
         
     | 
| 
      
 268 
     | 
    
         
            +
                      subject.should_not_receive(:confirm_some_stuff)
         
     | 
| 
      
 269 
     | 
    
         
            +
                      subject.should_not_receive(:set_up_changelog)
         
     | 
| 
      
 270 
     | 
    
         
            +
                      Zenflow::Config.should_not_receive(:save!)
         
     | 
| 
      
 271 
     | 
    
         
            +
                      lambda{ subject.init}.should raise_error(SystemExit)
         
     | 
| 
      
 272 
     | 
    
         
            +
                    end
         
     | 
| 
      
 273 
     | 
    
         
            +
                  end
         
     | 
| 
      
 274 
     | 
    
         
            +
                end
         
     | 
| 
      
 275 
     | 
    
         
            +
              end
         
     | 
| 
      
 276 
     | 
    
         
            +
             
     | 
| 
      
 277 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,45 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Zenflow::Github do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe '.user' do
         
     | 
| 
      
 5 
     | 
    
         
            +
                let(:user){'github-user'}
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                before(:each){
         
     | 
| 
      
 8 
     | 
    
         
            +
                  Zenflow::Shell.should_receive(:run).and_return(user)
         
     | 
| 
      
 9 
     | 
    
         
            +
                }
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                it "returns the user" do
         
     | 
| 
      
 12 
     | 
    
         
            +
                  expect(Zenflow::Github.user).to eq(user)
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              describe '.authorize' do
         
     | 
| 
      
 17 
     | 
    
         
            +
                context "when authorization fails" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 19 
     | 
    
         
            +
                    Zenflow.should_receive("Log").with("Authorizing with GitHub... Enter your GitHub password.")
         
     | 
| 
      
 20 
     | 
    
         
            +
                    Zenflow::Github.should_receive(:user).and_return('adamkittelson')
         
     | 
| 
      
 21 
     | 
    
         
            +
                    Zenflow::Shell.should_receive(:run).and_return('{"message": "failed to authorize, bummer"}')
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  it "logs that something went wrong" do
         
     | 
| 
      
 25 
     | 
    
         
            +
                    Zenflow.should_receive("Log").with("Something went wrong. Error from GitHub was: failed to authorize, bummer")
         
     | 
| 
      
 26 
     | 
    
         
            +
                    Zenflow::Github.authorize
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                context "when authorization succeeds" do
         
     | 
| 
      
 31 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 32 
     | 
    
         
            +
                    Zenflow.should_receive("Log").with("Authorizing with GitHub... Enter your GitHub password.")
         
     | 
| 
      
 33 
     | 
    
         
            +
                    Zenflow::Github.should_receive(:user).and_return('adamkittelson')
         
     | 
| 
      
 34 
     | 
    
         
            +
                    Zenflow::Shell.should_receive(:run).with(%{curl -u "adamkittelson" https://api.github.com/authorizations -d '{"scopes":["repo"], "note":"Zenflow"}' --silent}, :silent => true).and_return('{"token": "super secure token"}')
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  it "adds the token to git config and logs a happy message of success" do
         
     | 
| 
      
 38 
     | 
    
         
            +
                    Zenflow::Shell.should_receive(:run).with("git config --global zenflow.token super secure token", :silent => true)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    Zenflow.should_receive("Log").with("Authorized!")
         
     | 
| 
      
 40 
     | 
    
         
            +
                    Zenflow::Github.authorize
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Zenflow::Help do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              describe "Zenflow.Help" do
         
     | 
| 
      
 6 
     | 
    
         
            +
                it "initializes and returns a new Zenflow::Help object" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  expect(Zenflow.Help.class).to eq(Zenflow::Help.new.class)
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              subject { Zenflow::Help.new(:command  => 'test-help',
         
     | 
| 
      
 12 
     | 
    
         
            +
                                          :summary  => "tests Zenflow::Help",
         
     | 
| 
      
 13 
     | 
    
         
            +
                                          :usage    => "test-help (optional please)",
         
     | 
| 
      
 14 
     | 
    
         
            +
                                          :commands => ['test-help', 'spec-help'])}
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              it "has an amazing banner" do
         
     | 
| 
      
 17 
     | 
    
         
            +
                expect(subject.banner).to eq("\e[36m- Summary ------------------------------\e[0m\ntests Zenflow::Help\n\n\e[36m- Usage --------------------------------\e[0m\ntest-help (optional please)\n\n\e[36m- Available Commands -------------------\e[0m\n[\"test-help\", \"spec-help\"]\n\n\e[36m- Options ------------------------------\e[0m")
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              context "#unknown_command" do
         
     | 
| 
      
 21 
     | 
    
         
            +
                describe "when the command is missing" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  it "logs the error and exits" do
         
     | 
| 
      
 23 
     | 
    
         
            +
                    Zenflow.should_receive(:Log).with "Missing command", :color => :red
         
     | 
| 
      
 24 
     | 
    
         
            +
                    lambda {Zenflow::Help.new.unknown_command}.should raise_error(SystemExit)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                describe "when the command is present" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  it "logs the error and exits" do
         
     | 
| 
      
 30 
     | 
    
         
            +
                    Zenflow.should_receive(:Log).with "Unknown command \"test-unknown_command\"", :color => :red
         
     | 
| 
      
 31 
     | 
    
         
            +
                    lambda {Zenflow::Help.new(:command => 'test-unknown_command').unknown_command}.should raise_error(SystemExit)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Zenflow do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe 'Log' do
         
     | 
| 
      
 5 
     | 
    
         
            +
                context 'with indentation' do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
      
 7 
     | 
    
         
            +
                    Zenflow.stub(:LogToFile)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  it 'indents the text' do
         
     | 
| 
      
 11 
     | 
    
         
            +
                    $stdout.should_receive(:puts).with(/\s+foo/)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    Zenflow.Log('foo', indent: true)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  it 'adds an arrow the text' do
         
     | 
| 
      
 16 
     | 
    
         
            +
                    $stdout.should_receive(:puts).with(/-----> foo/)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    Zenflow.Log('foo', arrows: true)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  it 'colorizes the text' do
         
     | 
| 
      
 21 
     | 
    
         
            +
                    $stdout.should_receive(:puts).with(/\e\[34mfoo/)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    Zenflow.Log('foo', color: :blue, arrows: false)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  it 'does not colorize the text' do
         
     | 
| 
      
 26 
     | 
    
         
            +
                    $stdout.should_receive(:puts).with('foo')
         
     | 
| 
      
 27 
     | 
    
         
            +
                    Zenflow.Log('foo', color: false, arrows: false)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,108 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Zenflow::PullRequest do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before(:each){
         
     | 
| 
      
 5 
     | 
    
         
            +
                Zenflow::Github.stub(:user).and_return('github-user')
         
     | 
| 
      
 6 
     | 
    
         
            +
                Zenflow::Github.stub(:token).and_return('github-token')
         
     | 
| 
      
 7 
     | 
    
         
            +
                Zenflow::Github.stub(:zenflow_token).and_return('zenflow-token')
         
     | 
| 
      
 8 
     | 
    
         
            +
                Zenflow::GithubRequest.base_uri 'https://api.github.com/repos/zencoder/zenflow-example'
         
     | 
| 
      
 9 
     | 
    
         
            +
              }
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              describe '.list', vcr: { cassette_name: "pull request list" } do
         
     | 
| 
      
 12 
     | 
    
         
            +
                let(:pull_requests){Zenflow::PullRequest.list}
         
     | 
| 
      
 13 
     | 
    
         
            +
                it{expect(pull_requests).to be_a_kind_of(Array)}
         
     | 
| 
      
 14 
     | 
    
         
            +
                it{expect(pull_requests.first).to be_a_kind_of(Zenflow::PullRequest)}
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              describe '.find', vcr: { cassette_name: "pull request find" } do
         
     | 
| 
      
 18 
     | 
    
         
            +
                let(:pull_request){Zenflow::PullRequest.find(1)}
         
     | 
| 
      
 19 
     | 
    
         
            +
                it{expect(pull_request).to be_a_kind_of(Zenflow::PullRequest)}
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              describe '.find_by_ref' do
         
     | 
| 
      
 23 
     | 
    
         
            +
                before(:each){Zenflow.should_receive(:Log).with(Regexp.new('Looking up'))}
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                context 'existing ref', vcr: { cassette_name: "pull request by ref" } do
         
     | 
| 
      
 26 
     | 
    
         
            +
                  let(:pull_request){Zenflow::PullRequest.find_by_ref('feature/example')}
         
     | 
| 
      
 27 
     | 
    
         
            +
                  it{expect(pull_request).to be_a_kind_of(Zenflow::PullRequest)}
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                context 'non-existant ref', vcr: { cassette_name: "pull request for non-existent ref" } do
         
     | 
| 
      
 31 
     | 
    
         
            +
                  let(:pull_request){Zenflow::PullRequest.find_by_ref('feature/foo')}
         
     | 
| 
      
 32 
     | 
    
         
            +
                  it{expect(pull_request).to be_nil}
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              describe '.find_by_ref!' do
         
     | 
| 
      
 37 
     | 
    
         
            +
                before(:each){Zenflow.should_receive(:Log).with(Regexp.new('Looking up'))}
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                context 'existing ref', vcr: { cassette_name: "pull request by ref" } do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  let(:pull_request){Zenflow::PullRequest.find_by_ref!('feature/example')}
         
     | 
| 
      
 41 
     | 
    
         
            +
                  it{expect(pull_request).to be_a_kind_of(Zenflow::PullRequest)}
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                context 'non-existent ref', vcr: { cassette_name: "pull request for non-existent ref" } do
         
     | 
| 
      
 45 
     | 
    
         
            +
                  let(:ref){'feature/foo'}
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                  it 'logs the failure' do
         
     | 
| 
      
 48 
     | 
    
         
            +
                    Zenflow.should_receive(:Log).with(Regexp.new(ref), color: :red)
         
     | 
| 
      
 49 
     | 
    
         
            +
                    expect{Zenflow::PullRequest.find_by_ref!(ref)}.to raise_error(SystemExit)
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              describe '.exist?' do
         
     | 
| 
      
 55 
     | 
    
         
            +
                before(:each){Zenflow.should_receive(:Log).with(Regexp.new('Looking up'))}
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                context 'a valid pull', vcr: { cassette_name: "existing pull request" } do
         
     | 
| 
      
 58 
     | 
    
         
            +
                  it{expect(Zenflow::PullRequest.exist?('feature/example')).to be_true}
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                context 'an invalid pull', vcr: { cassette_name: "unexisting pull request" } do
         
     | 
| 
      
 62 
     | 
    
         
            +
                  it{expect(Zenflow::PullRequest.exist?('feature/foo')).to be_false}
         
     | 
| 
      
 63 
     | 
    
         
            +
                end
         
     | 
| 
      
 64 
     | 
    
         
            +
              end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
              describe '.create', vcr: { cassette_name: "create pull request" } do
         
     | 
| 
      
 67 
     | 
    
         
            +
                let(:request_options) do
         
     | 
| 
      
 68 
     | 
    
         
            +
                  {
         
     | 
| 
      
 69 
     | 
    
         
            +
                    base: 'master',
         
     | 
| 
      
 70 
     | 
    
         
            +
                    head: 'feature/new-branch',
         
     | 
| 
      
 71 
     | 
    
         
            +
                    title: 'Feaure: new-branch',
         
     | 
| 
      
 72 
     | 
    
         
            +
                    body: 'making a new pull request'
         
     | 
| 
      
 73 
     | 
    
         
            +
                  }
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
                it{ expect(Zenflow::PullRequest.create(request_options)).to(
         
     | 
| 
      
 76 
     | 
    
         
            +
                  be_a_kind_of(Zenflow::PullRequest)
         
     | 
| 
      
 77 
     | 
    
         
            +
                ) }
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              describe '#valid?' do
         
     | 
| 
      
 81 
     | 
    
         
            +
                context 'good request', vcr: { cassette_name: "create pull request" } do
         
     | 
| 
      
 82 
     | 
    
         
            +
                  let(:request){Zenflow::PullRequest.create({})}
         
     | 
| 
      
 83 
     | 
    
         
            +
                  it{expect(request.valid?).to be_true}
         
     | 
| 
      
 84 
     | 
    
         
            +
                end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                context 'bad request', vcr: { cassette_name: "create bad pull request" } do
         
     | 
| 
      
 87 
     | 
    
         
            +
                  let(:request_options) do
         
     | 
| 
      
 88 
     | 
    
         
            +
                    {
         
     | 
| 
      
 89 
     | 
    
         
            +
                      base: 'master',
         
     | 
| 
      
 90 
     | 
    
         
            +
                      head: 'feature/phoney',
         
     | 
| 
      
 91 
     | 
    
         
            +
                      title: 'this feature does not exist',
         
     | 
| 
      
 92 
     | 
    
         
            +
                      body: 'gonna fail'
         
     | 
| 
      
 93 
     | 
    
         
            +
                    }
         
     | 
| 
      
 94 
     | 
    
         
            +
                  end
         
     | 
| 
      
 95 
     | 
    
         
            +
                  let(:request){Zenflow::PullRequest.create()}
         
     | 
| 
      
 96 
     | 
    
         
            +
                  it{expect(request.valid?).to be_false}
         
     | 
| 
      
 97 
     | 
    
         
            +
                end
         
     | 
| 
      
 98 
     | 
    
         
            +
              end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
              describe '#[]' do
         
     | 
| 
      
 101 
     | 
    
         
            +
                context 'good request', vcr: { cassette_name: "create pull request" } do
         
     | 
| 
      
 102 
     | 
    
         
            +
                  let(:request){Zenflow::PullRequest.create({})}
         
     | 
| 
      
 103 
     | 
    
         
            +
                  it{expect(request["comments"]).to_not be_nil}
         
     | 
| 
      
 104 
     | 
    
         
            +
                  it{expect(request["fdsfa"]).to be_nil}
         
     | 
| 
      
 105 
     | 
    
         
            +
                end
         
     | 
| 
      
 106 
     | 
    
         
            +
              end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
            end
         
     |