pgit 0.0.4 → 1.0.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.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.agignore +3 -0
  3. data/.travis.yml +1 -0
  4. data/README.markdown +32 -9
  5. data/Rakefile +12 -0
  6. data/bin/pgit +167 -25
  7. data/lib/pgit.rb +40 -10
  8. data/lib/pgit/bilateral/handle_back.rb +22 -0
  9. data/lib/pgit/bilateral/handle_choose_story.rb +31 -0
  10. data/lib/pgit/bilateral/story.rb +44 -0
  11. data/lib/pgit/command.rb +83 -0
  12. data/lib/pgit/command/add.rb +36 -0
  13. data/lib/pgit/command/application.rb +21 -0
  14. data/lib/pgit/command/edit.rb +36 -0
  15. data/lib/pgit/command/remove.rb +36 -0
  16. data/lib/pgit/command/run.rb +32 -0
  17. data/lib/pgit/command/show.rb +53 -0
  18. data/lib/pgit/configuration.rb +27 -3
  19. data/lib/pgit/current_project.rb +9 -45
  20. data/lib/pgit/current_project/validator.rb +2 -1
  21. data/lib/pgit/error/external.rb +11 -0
  22. data/lib/pgit/error/user.rb +12 -0
  23. data/lib/pgit/helpers/heredoc.rb +17 -0
  24. data/lib/pgit/helpers/query_methods.rb +63 -0
  25. data/lib/pgit/helpers/string_extensions.rb +29 -0
  26. data/lib/pgit/installer/bash_auto_completion.rb +57 -0
  27. data/lib/pgit/pivotal/collection_request.rb +21 -0
  28. data/lib/pgit/pivotal/individual_request.rb +47 -0
  29. data/lib/pgit/pivotal/iteration.rb +6 -0
  30. data/lib/pgit/pivotal/iterations.rb +15 -0
  31. data/lib/pgit/pivotal/project.rb +6 -0
  32. data/lib/pgit/pivotal/projects.rb +20 -0
  33. data/lib/pgit/pivotal/query.rb +8 -0
  34. data/lib/pgit/pivotal/request.rb +33 -0
  35. data/lib/pgit/pivotal/request/query.rb +25 -0
  36. data/lib/pgit/pivotal/story.rb +38 -0
  37. data/lib/pgit/pivotal_request_validator.rb +1 -1
  38. data/lib/pgit/project.rb +78 -0
  39. data/lib/pgit/project/add.rb +28 -0
  40. data/lib/pgit/project/application.rb +21 -0
  41. data/lib/pgit/project/interactive_adder.rb +41 -0
  42. data/lib/pgit/project/remove.rb +41 -0
  43. data/lib/pgit/project/reuse_api_token_adder.rb +48 -0
  44. data/lib/pgit/response_handler.rb +16 -0
  45. data/lib/pgit/root.rb +5 -0
  46. data/lib/pgit/status.rb +16 -0
  47. data/lib/pgit/story_branch/application.rb +3 -3
  48. data/lib/pgit/{name_parser.rb → story_branch/name_parser.rb} +0 -0
  49. data/lib/pgit/story_branch/story_id_parser.rb +11 -0
  50. data/lib/pgit/validators/project_validator.rb +20 -0
  51. data/lib/pgit/version.rb +1 -1
  52. data/lib/pivotal +0 -0
  53. data/pgit.gemspec +5 -0
  54. data/spec/fixtures/iterations +1 -0
  55. data/spec/pgit/bilateral/handle_back_spec.rb +29 -0
  56. data/spec/pgit/bilateral/handle_choose_story_spec.rb +17 -0
  57. data/spec/pgit/bilateral/story_spec.rb +178 -0
  58. data/spec/pgit/command/add_spec.rb +68 -0
  59. data/spec/pgit/command/application_spec.rb +110 -0
  60. data/spec/pgit/command/edit_spec.rb +61 -0
  61. data/spec/pgit/command/remove_spec.rb +76 -0
  62. data/spec/pgit/command/run_spec.rb +49 -0
  63. data/spec/pgit/command/show_spec.rb +95 -0
  64. data/spec/pgit/command_spec.rb +299 -0
  65. data/spec/pgit/configuration_spec.rb +121 -18
  66. data/spec/pgit/current_project/validator_spec.rb +2 -1
  67. data/spec/pgit/current_project_spec.rb +20 -71
  68. data/spec/pgit/{external_error_spec.rb → error/external_spec.rb} +3 -3
  69. data/spec/pgit/error/user_spec.rb +17 -0
  70. data/spec/pgit/helpers/heredoc_spec.rb +33 -0
  71. data/spec/pgit/helpers/query_methods_spec.rb +24 -0
  72. data/spec/pgit/helpers/string_extensions_spec.rb +49 -0
  73. data/spec/pgit/installer/bash_auto_completion_spec.rb +134 -0
  74. data/spec/pgit/pivotal/individual_request_spec.rb +32 -0
  75. data/spec/pgit/pivotal/iteration_spec.rb +19 -0
  76. data/spec/pgit/pivotal/iterations_spec.rb +37 -0
  77. data/spec/pgit/pivotal/project_spec.rb +9 -0
  78. data/spec/pgit/pivotal/projects_spec.rb +48 -0
  79. data/spec/pgit/pivotal/request/query_spec.rb +24 -0
  80. data/spec/pgit/pivotal/story_spec.rb +113 -0
  81. data/spec/pgit/pivotal_request_validator_spec.rb +3 -3
  82. data/spec/pgit/project/add_spec.rb +52 -0
  83. data/spec/pgit/project/application_spec.rb +69 -0
  84. data/spec/pgit/project/interactive_adder_spec.rb +45 -0
  85. data/spec/pgit/project/remove_spec.rb +86 -0
  86. data/spec/pgit/project/reuse_api_token_adder_spec.rb +41 -0
  87. data/spec/pgit/project_spec.rb +513 -0
  88. data/spec/pgit/status_spec.rb +40 -0
  89. data/spec/pgit/story_branch/application_spec.rb +5 -8
  90. data/spec/pgit/story_branch/name_parser_spec.rb +3 -3
  91. data/spec/pgit/story_branch/story_id_parser_spec.rb +17 -0
  92. data/spec/pgit/validators/project_validator_spec.rb +39 -0
  93. metadata +146 -21
  94. data/lib/pgit/configuration/layout_error.rb +0 -9
  95. data/lib/pgit/configuration/missing_attributes_error.rb +0 -10
  96. data/lib/pgit/configuration/not_found_error.rb +0 -10
  97. data/lib/pgit/configuration/project_missing_error.rb +0 -10
  98. data/lib/pgit/configuration/validator.rb +0 -41
  99. data/lib/pgit/current_project/no_paths_match_working_dir_error.rb +0 -10
  100. data/lib/pgit/external_error.rb +0 -9
  101. data/lib/pgit/installer/configuration.rb +0 -34
  102. data/lib/pgit/story.rb +0 -44
  103. data/spec/pgit/configuration/missing_attributes_error_spec.rb +0 -30
  104. data/spec/pgit/configuration/not_found_error_spec.rb +0 -17
  105. data/spec/pgit/configuration/project_missing_error_spec.rb +0 -30
  106. data/spec/pgit/configuration/validator_spec.rb +0 -79
  107. data/spec/pgit/current_project/no_paths_match_working_dir_error_spec.rb +0 -17
  108. data/spec/pgit/installer/configuration_spec.rb +0 -162
  109. data/spec/pgit/story_spec.rb +0 -35
@@ -1,10 +0,0 @@
1
- module PGit
2
- class CurrentProject
3
- class NoPathsMatchWorkingDirError < PGit::Error
4
- def initialize
5
- @message = "None of the project paths matches the working directory"
6
- super(@message)
7
- end
8
- end
9
- end
10
- end
@@ -1,9 +0,0 @@
1
- module PGit
2
- class ExternalError < PGit::Error
3
- def initialize(message)
4
- @message = message
5
-
6
- super @message
7
- end
8
- end
9
- end
@@ -1,34 +0,0 @@
1
- module PGit
2
- module Installer
3
- class Configuration
4
- FILEPATH = "~/.pgit.rc.yml"
5
- def initialize(glob_opts, opts, args)
6
- @expanded_path = File.expand_path(FILEPATH)
7
-
8
- if File.exists? @expanded_path
9
- warn "#{FILEPATH} already exists"
10
- else
11
- ask_continue
12
- end
13
- end
14
-
15
- def ask_continue
16
- puts "*** Installing example pgit configuration file under #{FILEPATH}. Continue? [Y/n]"
17
- if STDIN.gets.chomp.match(/y/i)
18
- puts "Saving example pgit config in #{FILEPATH}..."
19
- write_example_pgit_rc_file
20
- else
21
- puts "Aborting installation..."
22
- end
23
- end
24
-
25
- def write_example_pgit_rc_file
26
- File.open(@expanded_path, 'w') do |f|
27
- YAML.dump(PGit::Configuration.default_options, f)
28
- end
29
-
30
- puts "Saved! Please edit #{FILEPATH} and add the proper Pivotal Tracker API tokens, id, and file paths for each project"
31
- end
32
- end
33
- end
34
- end
@@ -1,44 +0,0 @@
1
- #
2
- # Wrapper for a Pivotal Tracker story
3
- #
4
-
5
- module PGit
6
- class Story
7
- class << self
8
- def get(id, current_project)
9
- @id = id
10
- @project_id = current_project.id
11
- @api_token = current_project.api_token
12
-
13
- define_methods(get!)
14
-
15
- new
16
- end
17
-
18
- def define_methods(json)
19
- JSON.parse(json).each do |key, value|
20
- define_method key do
21
- value
22
- end
23
- end
24
- end
25
-
26
- def api_version
27
- "v5"
28
- end
29
-
30
- def get!
31
- validator = PGit::PivotalRequestValidator.new `#{get_request}`
32
- validator.request
33
- end
34
-
35
- def link
36
- "'https://www.pivotaltracker.com/services/#{api_version}/projects/#{@project_id}/stories/#{@id}'"
37
- end
38
-
39
- def get_request
40
- "curl -X GET -H 'X-TrackerToken: #{@api_token}' #{link}"
41
- end
42
- end
43
- end
44
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'PGit::Configuration::MissingAttributesError' do
4
- it 'should inherit from PGit::Error' do
5
- ancestors = PGit::Configuration::MissingAttributesError.ancestors
6
-
7
- expect(ancestors).to include (PGit::Error)
8
- end
9
-
10
- it 'should complain saying that a project must exist' do
11
- error_message = <<-ERROR
12
- /Users/edderic/some/config/path.yml must have a path, id, and api_token for each project.
13
- Please have the following layout:
14
- ---
15
- projects:
16
- - api_token: somepivotalatoken124
17
- id: '12345'
18
- path: "~/some/path/to/a/pivotal-git/project"
19
- - api_token: somepivotalatoken124
20
- id: '23429070'
21
- path: "~/some/other/pivotal-git/project"
22
- ERROR
23
- error_message.gsub!(/^\s{6}/,'')
24
- fake_path = "/Users/edderic/some/config/path.yml"
25
- missing_attributes_error = PGit::Configuration::MissingAttributesError.new(fake_path)
26
- message = missing_attributes_error.instance_eval{ @message }
27
-
28
- expect(message).to eq error_message
29
- end
30
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'PGit::Configuration::NotFoundError' do
4
- it 'should inherit from PGit::Error' do
5
- ancestors = PGit::Configuration::NotFoundError.ancestors
6
-
7
- expect(ancestors).to include (PGit::Error)
8
- end
9
-
10
- it 'should complain that the Configuration file does not exist' do
11
- fake_config_path = "/Users/edderic/some/path/to/.pgit.rc.yml"
12
- not_found_error = PGit::Configuration::NotFoundError.new(fake_config_path)
13
- message = not_found_error.instance_eval{ @message }
14
-
15
- expect(message).to eq "#{fake_config_path} configuration file does not exist. Please run `pgit install`"
16
- end
17
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'PGit::Configuration::ProjectMissingError' do
4
- it 'should inherit from PGit::Error' do
5
- ancestors = PGit::Configuration::ProjectMissingError.ancestors
6
-
7
- expect(ancestors).to include (PGit::Error)
8
- end
9
-
10
- it 'should complain saying that a project must exist' do
11
- error_message = <<-ERROR
12
- /Users/edderic/some/config/path.yml needs at least one project.
13
- Please have the following layout:
14
- ---
15
- projects:
16
- - api_token: somepivotalatoken124
17
- id: '12345'
18
- path: "~/some/path/to/a/pivotal-git/project"
19
- - api_token: somepivotalatoken124
20
- id: '23429070'
21
- path: "~/some/other/pivotal-git/project"
22
- ERROR
23
- error_message.gsub!(/^\s{6}/,'')
24
- fake_path = "/Users/edderic/some/config/path.yml"
25
- project_missing_error = PGit::Configuration::ProjectMissingError.new(fake_path)
26
- message = project_missing_error.instance_eval{ @message }
27
-
28
- expect(message).to eq error_message
29
- end
30
- end
@@ -1,79 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'PGit::Configuration::Validator' do
4
- describe '#new(configuration_path)' do
5
- describe 'empty file' do
6
- it 'should complain that there should be at least one project' do
7
- fake_path = "~/some/config/path.yml"
8
- fake_expanded_path = "/Users/edderic/some/config/path.yml"
9
- fake_file = double('file')
10
- fake_yaml = {}
11
-
12
- allow(File).to receive(:expand_path).with(fake_path).and_return(fake_expanded_path)
13
- allow(File).to receive(:expand_path).with('.')
14
- allow(File).to receive(:exists?).with(fake_expanded_path).and_return(true)
15
- allow(File).to receive(:open).with(fake_expanded_path, 'r').and_return(fake_file)
16
- allow(YAML).to receive(:load).with(fake_file).and_return(fake_yaml)
17
-
18
- expect do
19
- PGit::Configuration::Validator.new(fake_path)
20
- end.to raise_error(PGit::Configuration::ProjectMissingError)
21
- end
22
- end
23
-
24
- describe 'has projects but is missing a token' do
25
- it 'should raise an error' do
26
- fake_path = "~/some/config/path.yml"
27
- fake_expanded_path = "/Users/edderic/some/config/path.yml"
28
- fake_file = double('file')
29
- fake_projects = [ { path: 'fake_path',
30
- api_token: 'fake_token'
31
- }]
32
- fake_yaml = { 'projects' => fake_projects }
33
-
34
- allow(File).to receive(:expand_path).with(fake_path).and_return(fake_expanded_path)
35
- allow(File).to receive(:expand_path).with('.')
36
- allow(File).to receive(:exists?).with(fake_expanded_path).and_return(true)
37
- allow(File).to receive(:open).with(fake_expanded_path, 'r').and_return(fake_file)
38
- allow(YAML).to receive(:load).with(fake_file).and_return(fake_yaml)
39
-
40
- expect do
41
- PGit::Configuration::Validator.new(fake_path)
42
- end.to raise_error(PGit::Configuration::MissingAttributesError)
43
- end
44
- end
45
-
46
- describe 'configuration_path exists' do
47
- it '#yaml should return the yaml file' do
48
- fake_path = "~/some/config/path.yml"
49
- fake_expanded_path = "/Users/edderic/some/config/path.yml"
50
- fake_file = double('file')
51
- fake_projects = [ { "path" => 'fake_path',
52
- "id" => 'fake_id',
53
- "api_token" => 'fake_token'
54
- }]
55
-
56
- fake_yaml = { 'projects' => fake_projects }
57
-
58
- allow(File).to receive(:expand_path).with(fake_path).and_return(fake_expanded_path)
59
- allow(File).to receive(:exists?).with(fake_expanded_path).and_return(true)
60
- allow(File).to receive(:open).with(fake_expanded_path, 'r').and_return(fake_file)
61
- allow(YAML).to receive(:load).with(fake_file).and_return(fake_yaml)
62
-
63
- configuration = PGit::Configuration::Validator.new(fake_path)
64
-
65
- expect(configuration.yaml).to eq fake_yaml
66
- end
67
- end
68
-
69
- describe 'configuration path does not exist' do
70
- it 'should throw an error' do
71
- file_path = '~/.edderic-dotfiles/config/project.yml'
72
- fake_expanded_path = "/home/edderic/.edderic-dotfiles/config/project.yml"
73
- allow(File).to receive(:exists?).and_return(false)
74
-
75
- expect{ PGit::Configuration::Validator.new(file_path) }.to raise_error(PGit::Configuration::NotFoundError)
76
- end
77
- end
78
- end
79
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'PGit::CurrentProject::NoPathsMatchWorkingDirError' do
4
- it 'should have PGit::Error as an ancestor' do
5
- ancestors = PGit::CurrentProject::NoPathsMatchWorkingDirError.ancestors
6
-
7
- expect(ancestors).to include PGit::Error
8
- end
9
-
10
- it 'should have the appropriate message' do
11
- matches = []
12
- error = PGit::CurrentProject::NoPathsMatchWorkingDirError.new
13
- message = error.instance_eval { @message }
14
-
15
- expect(message).to eq "None of the project paths matches the working directory"
16
- end
17
- end
@@ -1,162 +0,0 @@
1
- require 'pgit'
2
-
3
- describe 'PGit::Installer::Configuration' do
4
- describe '::FILEPATH' do
5
- it 'should eq ~/.pgit.rc.yml' do
6
- expect(PGit::Installer::Configuration::FILEPATH).to eq '~/.pgit.rc.yml'
7
- end
8
- end
9
-
10
- describe "#{PGit::Installer::Configuration::FILEPATH} exists" do
11
- it 'should say that the file already exists' do
12
- global_opts = {}
13
- opts = { }
14
- args = {}
15
- message = "#{PGit::Installer::Configuration::FILEPATH} already exists"
16
- default_file_path = "#{PGit::Installer::Configuration::FILEPATH}"
17
- file_expanded_path = "/home/edderic/.pgit.rc.yml"
18
-
19
- allow(File).to receive(:expand_path).
20
- with(".")
21
- allow(File).to receive(:expand_path).
22
- with(default_file_path).and_return(file_expanded_path)
23
- allow(File).to receive(:exists?).
24
- with(file_expanded_path).and_return(true)
25
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:warn).with(message)
26
-
27
- installer = PGit::Installer::Configuration.new(global_opts, opts, args)
28
-
29
- expect(installer).to have_received(:warn).with(message)
30
- end
31
- end
32
-
33
- describe '~/pgit.rc.yml does not exist' do
34
- it 'should ask to continue or not' do
35
- global_opts = {}
36
- opts = { }
37
- args = {}
38
-
39
- message = "*** Installing example pgit configuration file under #{PGit::Installer::Configuration::FILEPATH}. " +
40
- "Continue? [Y/n]"
41
- confirmation_message = "Saving example pgit config in #{PGit::Installer::Configuration::FILEPATH}..."
42
- edit_message = "Saved! Please edit #{PGit::Installer::Configuration::FILEPATH} and add the proper Pivotal Tracker API tokens, id, and file paths for each project"
43
- answer = instance_double("String", chomp: 'y')
44
- expanded_path = "/home/edderic/.pgit.rc.yml"
45
- fake_writable_file = double('File')
46
- allow(File).to receive(:expand_path).with("#{PGit::Installer::Configuration::FILEPATH}").and_return(expanded_path)
47
- allow(File).to receive(:exists?).with(expanded_path).and_return(false)
48
- allow(File).to receive(:open).with(expanded_path, 'w').and_return(fake_writable_file)
49
- allow(STDIN).to receive(:gets).and_return(answer)
50
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(message)
51
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(confirmation_message)
52
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(edit_message)
53
- installer = PGit::Installer::Configuration.new(global_opts, opts, args)
54
-
55
- expect(installer).to have_received(:puts).with(message)
56
- end
57
-
58
- describe 'user answers "y"' do
59
- it "should show the save message" do
60
- global_opts = {}
61
- opts = { }
62
- args = {}
63
-
64
- first_message = "*** Installing example pgit configuration file under #{PGit::Installer::Configuration::FILEPATH}. " +
65
- "Continue? [Y/n]"
66
- save_message = "Saving example pgit config in #{PGit::Installer::Configuration::FILEPATH}..."
67
- expanded_path = "/home/edderic/.pgit.rc.yml"
68
- edit_message = "Saved! Please edit #{PGit::Installer::Configuration::FILEPATH} and add the proper Pivotal Tracker API tokens, id, and file paths for each project"
69
- fake_writable_file = double('File')
70
- allow(File).to receive(:expand_path).with("#{PGit::Installer::Configuration::FILEPATH}").and_return(expanded_path)
71
- allow(File).to receive(:exists?).with(expanded_path).and_return(false)
72
- allow(File).to receive(:open).with(expanded_path, 'w').and_return(fake_writable_file)
73
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(edit_message)
74
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(first_message)
75
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(save_message)
76
-
77
- answer = instance_double("String", chomp: 'Y')
78
- allow(STDIN).to receive(:gets).and_return(answer)
79
-
80
- installer = PGit::Installer::Configuration.new(global_opts, opts, args)
81
-
82
- expect(installer).to have_received(:puts).with(save_message)
83
- end
84
-
85
- it "should save the file under #{PGit::Installer::Configuration::FILEPATH}" do
86
- global_opts = {}
87
- opts = { }
88
- args = {}
89
-
90
- first_message = "*** Installing example pgit configuration file under #{PGit::Installer::Configuration::FILEPATH}. " +
91
- "Continue? [Y/n]"
92
- save_message = "Saving example pgit config in #{PGit::Installer::Configuration::FILEPATH}..."
93
- expanded_path = "/home/edderic/.pgit.rc.yml"
94
- fake_writable_file = double('File')
95
- edit_message = "Saved! Please edit #{PGit::Installer::Configuration::FILEPATH} and add the proper Pivotal Tracker API tokens, id, and file paths for each project"
96
- allow(File).to receive(:expand_path).with(PGit::Installer::Configuration::FILEPATH).and_return(expanded_path)
97
- allow(File).to receive(:exists?).with(expanded_path).and_return(false)
98
- allow(File).to receive(:open).with(expanded_path, 'w').and_return(fake_writable_file)
99
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(first_message)
100
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(save_message)
101
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(edit_message)
102
-
103
- answer = instance_double("String", chomp: 'Y')
104
- allow(STDIN).to receive(:gets).and_return(answer)
105
-
106
- installer = PGit::Installer::Configuration.new(global_opts, opts, args)
107
-
108
- expect(File).to have_received(:open).with(expanded_path, 'w')
109
- end
110
-
111
- it 'should ask the user to edit the config file' do
112
- global_opts = {}
113
- opts = { }
114
- args = {}
115
-
116
- first_message = "*** Installing example pgit configuration file under #{PGit::Installer::Configuration::FILEPATH}. " +
117
- "Continue? [Y/n]"
118
- save_message = "Saving example pgit config in #{PGit::Installer::Configuration::FILEPATH}..."
119
- edit_message = "Saved! Please edit #{PGit::Installer::Configuration::FILEPATH} and add the proper Pivotal Tracker API tokens, id, and file paths for each project"
120
- expanded_path = "/home/edderic/.pgit.rc.yml"
121
- fake_writable_file = double('File')
122
- allow(File).to receive(:expand_path).with(PGit::Installer::Configuration::FILEPATH).and_return(expanded_path)
123
- allow(File).to receive(:exists?).with(expanded_path).and_return(false)
124
- allow(File).to receive(:open).with(expanded_path, 'w').and_return(fake_writable_file)
125
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(first_message)
126
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(edit_message)
127
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(save_message)
128
-
129
- answer = instance_double("String", chomp: 'Y')
130
- allow(STDIN).to receive(:gets).and_return(answer)
131
-
132
- installer = PGit::Installer::Configuration.new(global_opts, opts, args)
133
-
134
- expect(installer).to have_received(:puts).with(edit_message)
135
- end
136
- end
137
-
138
- describe 'user answers with "n"' do
139
- it "should show the abort message" do
140
- message = "Aborting installation..."
141
- global_opts = {}
142
- opts = { }
143
- args = {}
144
-
145
- first_message = "*** Installing example pgit configuration file under #{PGit::Installer::Configuration::FILEPATH}. " +
146
- "Continue? [Y/n]"
147
- expanded_path = "/home/edderic/.pgit.rc.yml"
148
- allow(File).to receive(:expand_path).with("#{PGit::Installer::Configuration::FILEPATH}").and_return(expanded_path)
149
- allow(File).to receive(:exists?).with(expanded_path).and_return(false)
150
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(first_message)
151
- allow_any_instance_of(PGit::Installer::Configuration).to receive(:puts).with(message)
152
-
153
- answer = instance_double("String", chomp: 'n')
154
- allow(STDIN).to receive(:gets).and_return(answer)
155
-
156
- installer = PGit::Installer::Configuration.new(global_opts, opts, args)
157
-
158
- expect(installer).to have_received(:puts).with(message)
159
- end
160
- end
161
- end
162
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'PGit::Story' do
4
- describe '#get' do
5
- it 'should generate the story' do
6
- story_id = '123'
7
- current_project = double('current_project', id: '321', api_token: 'abc10xyz')
8
- get_request = "curl -X GET -H 'X-TrackerToken: abc10xyz' 'https://www.pivotaltracker.com/services/v5/projects/321/stories/123'"
9
- fake_good_json = <<-GOOD_JSON
10
- {
11
- "created_at": "2014-11-25T12:00:00Z",
12
- "current_state": "unstarted",
13
- "description": "ignore the droids",
14
- "estimate": 2,
15
- "id": 555,
16
- "kind": "story",
17
- "labels": [],
18
- "name": "Bring me the passengers",
19
- "owner_ids": [],
20
- "project_id": 99,
21
- "requested_by_id": 101,
22
- "story_type": "feature",
23
- "updated_at": "2014-11-25T12:00:00Z",
24
- "url": "http://localhost/story/show/555"
25
- }
26
- GOOD_JSON
27
- allow(PGit::Story).to receive(:`).with(get_request).and_return(fake_good_json)
28
-
29
- story = PGit::Story.get(story_id, current_project)
30
-
31
- expect(story.name).to eq "Bring me the passengers"
32
- expect(story.description).to eq "ignore the droids"
33
- end
34
- end
35
- end