pgit 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.agignore +3 -0
- data/.travis.yml +1 -0
- data/README.markdown +32 -9
- data/Rakefile +12 -0
- data/bin/pgit +167 -25
- data/lib/pgit.rb +40 -10
- data/lib/pgit/bilateral/handle_back.rb +22 -0
- data/lib/pgit/bilateral/handle_choose_story.rb +31 -0
- data/lib/pgit/bilateral/story.rb +44 -0
- data/lib/pgit/command.rb +83 -0
- data/lib/pgit/command/add.rb +36 -0
- data/lib/pgit/command/application.rb +21 -0
- data/lib/pgit/command/edit.rb +36 -0
- data/lib/pgit/command/remove.rb +36 -0
- data/lib/pgit/command/run.rb +32 -0
- data/lib/pgit/command/show.rb +53 -0
- data/lib/pgit/configuration.rb +27 -3
- data/lib/pgit/current_project.rb +9 -45
- data/lib/pgit/current_project/validator.rb +2 -1
- data/lib/pgit/error/external.rb +11 -0
- data/lib/pgit/error/user.rb +12 -0
- data/lib/pgit/helpers/heredoc.rb +17 -0
- data/lib/pgit/helpers/query_methods.rb +63 -0
- data/lib/pgit/helpers/string_extensions.rb +29 -0
- data/lib/pgit/installer/bash_auto_completion.rb +57 -0
- data/lib/pgit/pivotal/collection_request.rb +21 -0
- data/lib/pgit/pivotal/individual_request.rb +47 -0
- data/lib/pgit/pivotal/iteration.rb +6 -0
- data/lib/pgit/pivotal/iterations.rb +15 -0
- data/lib/pgit/pivotal/project.rb +6 -0
- data/lib/pgit/pivotal/projects.rb +20 -0
- data/lib/pgit/pivotal/query.rb +8 -0
- data/lib/pgit/pivotal/request.rb +33 -0
- data/lib/pgit/pivotal/request/query.rb +25 -0
- data/lib/pgit/pivotal/story.rb +38 -0
- data/lib/pgit/pivotal_request_validator.rb +1 -1
- data/lib/pgit/project.rb +78 -0
- data/lib/pgit/project/add.rb +28 -0
- data/lib/pgit/project/application.rb +21 -0
- data/lib/pgit/project/interactive_adder.rb +41 -0
- data/lib/pgit/project/remove.rb +41 -0
- data/lib/pgit/project/reuse_api_token_adder.rb +48 -0
- data/lib/pgit/response_handler.rb +16 -0
- data/lib/pgit/root.rb +5 -0
- data/lib/pgit/status.rb +16 -0
- data/lib/pgit/story_branch/application.rb +3 -3
- data/lib/pgit/{name_parser.rb → story_branch/name_parser.rb} +0 -0
- data/lib/pgit/story_branch/story_id_parser.rb +11 -0
- data/lib/pgit/validators/project_validator.rb +20 -0
- data/lib/pgit/version.rb +1 -1
- data/lib/pivotal +0 -0
- data/pgit.gemspec +5 -0
- data/spec/fixtures/iterations +1 -0
- data/spec/pgit/bilateral/handle_back_spec.rb +29 -0
- data/spec/pgit/bilateral/handle_choose_story_spec.rb +17 -0
- data/spec/pgit/bilateral/story_spec.rb +178 -0
- data/spec/pgit/command/add_spec.rb +68 -0
- data/spec/pgit/command/application_spec.rb +110 -0
- data/spec/pgit/command/edit_spec.rb +61 -0
- data/spec/pgit/command/remove_spec.rb +76 -0
- data/spec/pgit/command/run_spec.rb +49 -0
- data/spec/pgit/command/show_spec.rb +95 -0
- data/spec/pgit/command_spec.rb +299 -0
- data/spec/pgit/configuration_spec.rb +121 -18
- data/spec/pgit/current_project/validator_spec.rb +2 -1
- data/spec/pgit/current_project_spec.rb +20 -71
- data/spec/pgit/{external_error_spec.rb → error/external_spec.rb} +3 -3
- data/spec/pgit/error/user_spec.rb +17 -0
- data/spec/pgit/helpers/heredoc_spec.rb +33 -0
- data/spec/pgit/helpers/query_methods_spec.rb +24 -0
- data/spec/pgit/helpers/string_extensions_spec.rb +49 -0
- data/spec/pgit/installer/bash_auto_completion_spec.rb +134 -0
- data/spec/pgit/pivotal/individual_request_spec.rb +32 -0
- data/spec/pgit/pivotal/iteration_spec.rb +19 -0
- data/spec/pgit/pivotal/iterations_spec.rb +37 -0
- data/spec/pgit/pivotal/project_spec.rb +9 -0
- data/spec/pgit/pivotal/projects_spec.rb +48 -0
- data/spec/pgit/pivotal/request/query_spec.rb +24 -0
- data/spec/pgit/pivotal/story_spec.rb +113 -0
- data/spec/pgit/pivotal_request_validator_spec.rb +3 -3
- data/spec/pgit/project/add_spec.rb +52 -0
- data/spec/pgit/project/application_spec.rb +69 -0
- data/spec/pgit/project/interactive_adder_spec.rb +45 -0
- data/spec/pgit/project/remove_spec.rb +86 -0
- data/spec/pgit/project/reuse_api_token_adder_spec.rb +41 -0
- data/spec/pgit/project_spec.rb +513 -0
- data/spec/pgit/status_spec.rb +40 -0
- data/spec/pgit/story_branch/application_spec.rb +5 -8
- data/spec/pgit/story_branch/name_parser_spec.rb +3 -3
- data/spec/pgit/story_branch/story_id_parser_spec.rb +17 -0
- data/spec/pgit/validators/project_validator_spec.rb +39 -0
- metadata +146 -21
- data/lib/pgit/configuration/layout_error.rb +0 -9
- data/lib/pgit/configuration/missing_attributes_error.rb +0 -10
- data/lib/pgit/configuration/not_found_error.rb +0 -10
- data/lib/pgit/configuration/project_missing_error.rb +0 -10
- data/lib/pgit/configuration/validator.rb +0 -41
- data/lib/pgit/current_project/no_paths_match_working_dir_error.rb +0 -10
- data/lib/pgit/external_error.rb +0 -9
- data/lib/pgit/installer/configuration.rb +0 -34
- data/lib/pgit/story.rb +0 -44
- data/spec/pgit/configuration/missing_attributes_error_spec.rb +0 -30
- data/spec/pgit/configuration/not_found_error_spec.rb +0 -17
- data/spec/pgit/configuration/project_missing_error_spec.rb +0 -30
- data/spec/pgit/configuration/validator_spec.rb +0 -79
- data/spec/pgit/current_project/no_paths_match_working_dir_error_spec.rb +0 -17
- data/spec/pgit/installer/configuration_spec.rb +0 -162
- data/spec/pgit/story_spec.rb +0 -35
@@ -3,9 +3,10 @@ require 'spec_helper'
|
|
3
3
|
describe 'PGit::CurrentProject::Validator' do
|
4
4
|
it 'should raise an error if there are no matching projects' do
|
5
5
|
matching_projects = []
|
6
|
+
message = "None of the project paths matches the working directory"
|
6
7
|
|
7
8
|
expect do
|
8
9
|
PGit::CurrentProject::Validator.new(matching_projects)
|
9
|
-
end.to raise_error
|
10
|
+
end.to raise_error(PGit::Error::User, message)
|
10
11
|
end
|
11
12
|
end
|
@@ -1,79 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
# .edderic-dotfiles/config.yml
|
3
|
-
# projects
|
4
|
-
# - path: ~/Therapy-Exercises-Online
|
5
|
-
# id: 12345
|
6
|
-
# api_token: asoeuhot
|
7
|
-
#
|
8
|
-
def successful_setup
|
9
|
-
fake_project_1 = { "path" => "/Therapy-Exercises-Online/some_other_project",
|
10
|
-
"id" => 12345,
|
11
|
-
"api_token" => "astoeuh" }
|
12
|
-
fake_project_2 = { "path" => "~/Therapy-Exercises-Online",
|
13
|
-
"id" => 19191,
|
14
|
-
"api_token" => "astoeuh" }
|
15
|
-
fake_project_list = [ fake_project_1, fake_project_2 ]
|
16
|
-
fake_yaml = { "projects" => fake_project_list }
|
17
|
-
fake_pwd = "/Therapy-Exercises-Online/some_other_project/some_subdirectory"
|
18
|
-
allow(Dir).to receive(:pwd).and_return(fake_pwd)
|
19
|
-
|
20
|
-
fake_configuration = double('configuration', to_yaml: fake_yaml)
|
21
|
-
end
|
22
2
|
|
23
3
|
describe 'PGit::CurrentProject' do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
fake_configuration = double('configuration', to_yaml: fake_yaml)
|
36
|
-
allow(Dir).to receive(:pwd).and_return(fake_pwd)
|
37
|
-
allow(PGit::CurrentProject::Validator).to receive(:new).with []
|
38
|
-
|
39
|
-
PGit::CurrentProject.new(fake_configuration.to_yaml)
|
40
|
-
|
41
|
-
expect(PGit::CurrentProject::Validator).to have_received(:new).with []
|
42
|
-
end
|
4
|
+
it 'instantiates the PGit::Project that exists in the config file and whose path matches the working directory' do
|
5
|
+
matching_path = '/some/matching_path'
|
6
|
+
matching_project = instance_double('PGit::Project',
|
7
|
+
path: matching_path)
|
8
|
+
projects = [matching_project]
|
9
|
+
configuration = instance_double('PGit::Configuration',
|
10
|
+
projects: projects)
|
11
|
+
allow(Dir).to receive(:pwd).and_return(matching_path)
|
12
|
+
proj = PGit::CurrentProject.new(configuration)
|
13
|
+
|
14
|
+
expect(proj.path).to eq matching_path
|
43
15
|
end
|
44
16
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
expect(working_directory).to eq "/Therapy-Exercises-Online/some_other_project"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#id' do
|
59
|
-
it 'should return the correct pivotal tracker project_id' do
|
60
|
-
fake_configuration = successful_setup
|
61
|
-
|
62
|
-
current_project = PGit::CurrentProject.new(fake_configuration.to_yaml)
|
63
|
-
project_id = current_project.id
|
64
|
-
|
65
|
-
expect(project_id).to eq 12345
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '#api_token' do
|
70
|
-
it 'should return the api_token associated to the current project' do
|
71
|
-
fake_configuration = successful_setup
|
72
|
-
|
73
|
-
current_project = PGit::CurrentProject.new(fake_configuration.to_yaml)
|
74
|
-
api_token = current_project.api_token
|
17
|
+
it 'raises an error if the project does not exist' do
|
18
|
+
matching_path = '/some/matching_path'
|
19
|
+
matching_project = instance_double('PGit::Project',
|
20
|
+
path: matching_path)
|
21
|
+
projects = [matching_project]
|
22
|
+
configuration = instance_double('PGit::Configuration',
|
23
|
+
projects: projects)
|
24
|
+
allow(Dir).to receive(:pwd).and_return('/some/non-matching-path')
|
75
25
|
|
76
|
-
|
77
|
-
end
|
26
|
+
expect{ PGit::CurrentProject.new(configuration) }.to raise_error(PGit::Error::User, "Current Project does not exist. See `pgit proj add -h`")
|
78
27
|
end
|
79
28
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'PGit::
|
3
|
+
describe 'PGit::Error::External' do
|
4
4
|
it 'should take in the response' do
|
5
5
|
response = '{
|
6
6
|
"code": "unfound_resource",
|
7
7
|
"kind": "error",
|
8
8
|
"error": "The object you tried to access could not be found. It may have been removed by another user, you may be using the ID of another object type, or you may be trying to access a sub-resource at the wrong point in a tree."
|
9
9
|
}'
|
10
|
-
external_error = PGit::
|
10
|
+
external_error = PGit::Error::External.new(response)
|
11
11
|
message = external_error.instance_eval { @message }
|
12
12
|
|
13
13
|
expect(message).to eq(response)
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should inherit from PGit::Error' do
|
17
|
-
ancestors = PGit::
|
17
|
+
ancestors = PGit::Error::External.ancestors
|
18
18
|
|
19
19
|
expect(ancestors).to include PGit::Error
|
20
20
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'PGit::Error::User' do
|
4
|
+
it 'should save the error' do
|
5
|
+
message = "You did something dumb..."
|
6
|
+
user_error = PGit::Error::User.new(message)
|
7
|
+
|
8
|
+
expect(user_error.message).to eq message
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should be a PGit::Error' do
|
12
|
+
message = "You did something dumb..."
|
13
|
+
ancestors = PGit::Error::User.ancestors
|
14
|
+
|
15
|
+
expect(ancestors).to include(PGit::Error)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'PGit::Helpers::Heredoc' do
|
4
|
+
describe '.remove_front_spaces' do
|
5
|
+
it 'should return the script, formatted nicely' do
|
6
|
+
unprocessed = <<-HEREDOC
|
7
|
+
function get_pgit_commands
|
8
|
+
{
|
9
|
+
if [ -z $2 ]; then
|
10
|
+
COMPREPLY=(`pgit help -c`)
|
11
|
+
else
|
12
|
+
COMPREPLY=(`pgit help -c $2`)
|
13
|
+
fi
|
14
|
+
}
|
15
|
+
complete -F get_pgit_commands pgit
|
16
|
+
HEREDOC
|
17
|
+
|
18
|
+
expected_script =
|
19
|
+
"function get_pgit_commands\n" +
|
20
|
+
"{\n" +
|
21
|
+
" if [ -z $2 ]; then\n" +
|
22
|
+
" COMPREPLY=(`pgit help -c`)\n" +
|
23
|
+
" else\n" +
|
24
|
+
" COMPREPLY=(`pgit help -c $2`)\n" +
|
25
|
+
" fi\n" +
|
26
|
+
"}\n" +
|
27
|
+
"complete -F get_pgit_commands pgit\n"
|
28
|
+
script = PGit::Helpers::Heredoc.remove_front_spaces(unprocessed)
|
29
|
+
|
30
|
+
expect(script).to eq expected_script
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'PGit::Helpers::QueryMethods' do
|
4
|
+
describe '#defaulted_attrs' do
|
5
|
+
it 'should ensure that the class has the given attributes' do
|
6
|
+
class SomeFakeClass
|
7
|
+
include PGit::Helpers::QueryMethods
|
8
|
+
extend PGit::Helpers::QueryMethods
|
9
|
+
|
10
|
+
attr_accessor :some_query, :some_other_query
|
11
|
+
attr_query :some_query, :some_other_query
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@some_query = :no_some_query_given
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
fake = SomeFakeClass.new
|
19
|
+
fake.some_other_query = 'set to non default'
|
20
|
+
|
21
|
+
expect(fake.defaulted_attrs).to include(:some_query.to_s)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'PGit::Helpers::StringExtensions' do
|
4
|
+
describe '#letter?' do
|
5
|
+
it 'should be case insensitive' do
|
6
|
+
expect('h').to be_letter('h')
|
7
|
+
expect('h').to be_letter('H')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should not match when length is greater than 1' do
|
11
|
+
expect('hh').not_to be_letter('h')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#index?' do
|
16
|
+
describe 'without passing an arg' do
|
17
|
+
it 'should tell us if the argument is a (normal person) index' do
|
18
|
+
expect('1').to be_index
|
19
|
+
expect('100').to be_index
|
20
|
+
expect('0').not_to be_index
|
21
|
+
expect('1.1').not_to be_index
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#yes?' do
|
27
|
+
it 'returns true if letter is y and false if not' do
|
28
|
+
expect('y').to be_yes
|
29
|
+
expect('Y').to be_yes
|
30
|
+
expect('2').not_to be_yes
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#no?' do
|
35
|
+
it 'returns false if letter is not and false if not' do
|
36
|
+
expect('n').to be_no
|
37
|
+
expect('N').to be_no
|
38
|
+
expect('y').not_to be_no
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#cancel?' do
|
43
|
+
it 'returns true if letter is c and false if not' do
|
44
|
+
expect('c').to be_cancel
|
45
|
+
expect('C').to be_cancel
|
46
|
+
expect('y').not_to be_cancel
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'PGit::Installer::BashAutoCompletion' do
|
4
|
+
describe 'FILENAME' do
|
5
|
+
it 'should be ~/.pgit_auto_completion' do
|
6
|
+
expect(PGit::Installer::BashAutoCompletion::FILENAME).to eq "~/.pgit_auto_completion"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.script' do
|
11
|
+
it 'should return the script, formatted nicely' do
|
12
|
+
unprocessed = <<-UNPROCESSED
|
13
|
+
function get_pgit_commands
|
14
|
+
{
|
15
|
+
if [ -z $2 ]; then
|
16
|
+
COMPREPLY=(`pgit help -c`)
|
17
|
+
else
|
18
|
+
COMPREPLY=(`pgit help -c $2`)
|
19
|
+
fi
|
20
|
+
}
|
21
|
+
complete -F get_pgit_commands pgit
|
22
|
+
UNPROCESSED
|
23
|
+
|
24
|
+
expected_script = PGit::Helpers::Heredoc.remove_front_spaces(unprocessed)
|
25
|
+
script = PGit::Installer::BashAutoCompletion.script
|
26
|
+
|
27
|
+
expect(script).to eq expected_script
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#write_completer_file' do
|
32
|
+
it "should write the auto completion script to #{PGit::Installer::BashAutoCompletion::FILENAME}" do
|
33
|
+
global_opts = {}
|
34
|
+
global_opts = {}
|
35
|
+
opts = {}
|
36
|
+
args = {}
|
37
|
+
fake_file = instance_double('File')
|
38
|
+
allow(fake_file).to receive(:puts).with(PGit::Installer::BashAutoCompletion.script).and_return(fake_file)
|
39
|
+
allow(fake_file).to receive(:close)
|
40
|
+
short_path = PGit::Installer::BashAutoCompletion::FILENAME
|
41
|
+
short_bashrc_path = "~/.bashrc"
|
42
|
+
expanded_path = "/Users/Edderic/#{PGit::Installer::BashAutoCompletion::FILENAME}"
|
43
|
+
expanded_bashrc_path = "/Users/Edderic/.bashrc"
|
44
|
+
bashrc_lines = [
|
45
|
+
"# some more ls aliases\n",
|
46
|
+
"alias ll='ls -alF'\n",
|
47
|
+
"alias la='ls -A'\n",
|
48
|
+
"alias l='ls -CF'\n" ]
|
49
|
+
message = "Wrote autocompletion script under #{PGit::Installer::BashAutoCompletion::FILENAME}"
|
50
|
+
|
51
|
+
allow(File).to receive(:expand_path).with(short_path).and_return(expanded_path)
|
52
|
+
allow(File).to receive(:open).with(expanded_path, 'w').and_return(fake_file)
|
53
|
+
allow(File).to receive(:readlines).with(expanded_bashrc_path).and_return(bashrc_lines)
|
54
|
+
|
55
|
+
installer = PGit::Installer::BashAutoCompletion.new(global_opts, opts, args)
|
56
|
+
allow(installer).to receive(:puts).with(message)
|
57
|
+
|
58
|
+
installer.write_completer_file
|
59
|
+
|
60
|
+
expect(fake_file).to have_received(:puts).with(PGit::Installer::BashAutoCompletion.script)
|
61
|
+
expect(fake_file).to have_received(:close)
|
62
|
+
expect(installer).to have_received(:puts).with(message)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#source_completer_from_bashrc' do
|
67
|
+
describe '~/.bashrc does have "source ~#{PGit::Installer::BashAutoCompletion::FILENAME}"' do
|
68
|
+
it 'should NOT source it' do
|
69
|
+
global_opts = {}
|
70
|
+
opts = {}
|
71
|
+
args = {}
|
72
|
+
fake_file = instance_double('File')
|
73
|
+
fake_bashrc_file = instance_double('File')
|
74
|
+
allow(fake_bashrc_file).to receive(:puts).with("source #{PGit::Installer::BashAutoCompletion::FILENAME}").and_return(fake_file)
|
75
|
+
allow(fake_bashrc_file).to receive(:close)
|
76
|
+
short_bashrc_path = "~/.bashrc"
|
77
|
+
expanded_bashrc_path = "/Users/Edderic/.bashrc"
|
78
|
+
bashrc_lines = [
|
79
|
+
"# some more ls aliases\n",
|
80
|
+
"alias ll='ls -alF'\n",
|
81
|
+
"alias la='ls -A'\n",
|
82
|
+
"source #{PGit::Installer::BashAutoCompletion::FILENAME}",
|
83
|
+
"alias l='ls -CF'\n" ]
|
84
|
+
message = "Already sourcing #{PGit::Installer::BashAutoCompletion::FILENAME} in ~/.bashrc"
|
85
|
+
|
86
|
+
allow(File).to receive(:expand_path).with(short_bashrc_path).and_return(expanded_bashrc_path)
|
87
|
+
allow(File).to receive(:open).with(expanded_bashrc_path, 'a').and_return(fake_bashrc_file)
|
88
|
+
allow(File).to receive(:readlines).with(expanded_bashrc_path).and_return(bashrc_lines)
|
89
|
+
|
90
|
+
installer = PGit::Installer::BashAutoCompletion.new(global_opts, opts, args)
|
91
|
+
allow(installer).to receive(:puts).with(message)
|
92
|
+
|
93
|
+
installer.source_completer_from_bashrc
|
94
|
+
|
95
|
+
expect(fake_bashrc_file).not_to have_received(:puts).with "source #{PGit::Installer::BashAutoCompletion::FILENAME}"
|
96
|
+
expect(fake_bashrc_file).not_to have_received(:close)
|
97
|
+
expect(installer).to have_received(:puts).with(message)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '~/.bashrc does not have the "source ~#{PGit::Installer::BashAutoCompletion::FILENAME}"' do
|
102
|
+
it 'should source ~#{PGit::Installer::BashAutoCompletion::FILENAME}' do
|
103
|
+
global_opts = {}
|
104
|
+
opts = {}
|
105
|
+
args = {}
|
106
|
+
fake_file = instance_double('File')
|
107
|
+
fake_bashrc_file = instance_double('File')
|
108
|
+
allow(fake_bashrc_file).to receive(:puts).with("source #{PGit::Installer::BashAutoCompletion::FILENAME}").and_return(fake_file)
|
109
|
+
allow(fake_bashrc_file).to receive(:close)
|
110
|
+
short_bashrc_path = "~/.bashrc"
|
111
|
+
expanded_bashrc_path = "/Users/Edderic/.bashrc"
|
112
|
+
bashrc_lines = [
|
113
|
+
"# some more ls aliases\n",
|
114
|
+
"alias ll='ls -alF'\n",
|
115
|
+
"alias la='ls -A'\n",
|
116
|
+
"alias l='ls -CF'\n" ]
|
117
|
+
installation_message = "~/.bashrc will now source #{PGit::Installer::BashAutoCompletion::FILENAME}"
|
118
|
+
|
119
|
+
allow(File).to receive(:expand_path).with(short_bashrc_path).and_return(expanded_bashrc_path)
|
120
|
+
allow(File).to receive(:open).with(expanded_bashrc_path, 'a').and_return(fake_bashrc_file)
|
121
|
+
allow(File).to receive(:readlines).with(expanded_bashrc_path).and_return(bashrc_lines)
|
122
|
+
|
123
|
+
installer = PGit::Installer::BashAutoCompletion.new(global_opts, opts, args)
|
124
|
+
allow(installer).to receive(:puts).with(installation_message)
|
125
|
+
|
126
|
+
installer.source_completer_from_bashrc
|
127
|
+
|
128
|
+
expect(fake_bashrc_file).to have_received(:puts).with "source #{PGit::Installer::BashAutoCompletion::FILENAME}"
|
129
|
+
expect(fake_bashrc_file).to have_received(:close)
|
130
|
+
expect(installer).to have_received(:puts).with(installation_message)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'PGit::Pivotal::IndividualRequest' do
|
4
|
+
describe '#get!' do
|
5
|
+
it 'does a cURL request' do
|
6
|
+
class SomeSubclass < PGit::Pivotal::IndividualRequest
|
7
|
+
attr_reader :api_token, :someattr
|
8
|
+
def initialize
|
9
|
+
@api_token
|
10
|
+
end
|
11
|
+
|
12
|
+
def sublink
|
13
|
+
'some/link'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
json = double('JSON')
|
18
|
+
some_subclass = SomeSubclass.new
|
19
|
+
some_other_subclass = SomeSubclass.new
|
20
|
+
|
21
|
+
api_token = some_subclass.api_token
|
22
|
+
link = "https://www.pivotaltracker.com/services/v5/some/link"
|
23
|
+
get_request = "curl -X GET -H 'X-TrackerToken: #{api_token}' #{link}"
|
24
|
+
allow(JSON).to receive(:parse).with(json).and_return({ 'kind' => 'project', 'someattr' => '123'})
|
25
|
+
allow(some_subclass).to receive(:`).with(get_request).and_return(json)
|
26
|
+
|
27
|
+
some_subclass.get!
|
28
|
+
|
29
|
+
expect(some_subclass).to have_received(:`).with(get_request)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PGit::Pivotal::Iteration do
|
4
|
+
describe '#new with hash' do
|
5
|
+
it 'should instantiate stories' do
|
6
|
+
iterations_string = File.read(File.join(PGit.root, 'spec', 'fixtures', 'iterations'))
|
7
|
+
iteration_hashes = JSON.parse(iterations_string)
|
8
|
+
first_iteration_hash = iteration_hashes.first
|
9
|
+
current_project = instance_double('PGit::CurrentProject', id: 123, api_token: 'haba')
|
10
|
+
allow(PGit::CurrentProject).to receive(:new).and_return(current_project)
|
11
|
+
iteration = PGit::Pivotal::Iteration.new do |iteration|
|
12
|
+
iteration.hash = first_iteration_hash
|
13
|
+
end
|
14
|
+
|
15
|
+
first_story = iteration.stories.first
|
16
|
+
expect(first_story.id).to eq 90501214
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|