pgit 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/README.markdown +3 -0
- data/bin/pgit +1 -1
- data/lib/pgit.rb +11 -1
- data/lib/pgit/configuration.rb +2 -43
- data/lib/pgit/configuration/layout_error.rb +9 -0
- data/lib/pgit/configuration/missing_attributes_error.rb +10 -0
- data/lib/pgit/configuration/not_found_error.rb +10 -0
- data/lib/pgit/configuration/project_missing_error.rb +10 -0
- data/lib/pgit/configuration/validator.rb +41 -0
- data/lib/pgit/current_project.rb +1 -7
- data/lib/pgit/current_project/no_paths_match_working_dir_error.rb +10 -0
- data/lib/pgit/current_project/validator.rb +11 -0
- data/lib/pgit/error.rb +4 -0
- data/lib/pgit/external_error.rb +9 -0
- data/lib/pgit/installer/configuration.rb +34 -0
- data/lib/pgit/pivotal_request_validator.rb +27 -0
- data/lib/pgit/story.rb +2 -6
- data/lib/pgit/version.rb +1 -1
- data/pgit.gemspec +2 -0
- data/spec/pgit/configuration/missing_attributes_error_spec.rb +30 -0
- data/spec/pgit/configuration/not_found_error_spec.rb +17 -0
- data/spec/pgit/configuration/project_missing_error_spec.rb +30 -0
- data/spec/pgit/configuration/validator_spec.rb +79 -0
- data/spec/pgit/configuration_spec.rb +22 -124
- data/spec/pgit/current_branch_spec.rb +1 -1
- data/spec/pgit/current_project/no_paths_match_working_dir_error_spec.rb +17 -0
- data/spec/pgit/current_project/validator_spec.rb +11 -0
- data/spec/pgit/current_project_spec.rb +17 -18
- data/spec/pgit/external_error_spec.rb +21 -0
- data/spec/pgit/installer/configuration_spec.rb +162 -0
- data/spec/pgit/pgit_spec.rb +2 -0
- data/spec/pgit/pivotal_request_validator_spec.rb +86 -0
- data/spec/pgit/story_branch/application_spec.rb +1 -1
- data/spec/pgit/story_branch_spec.rb +1 -1
- data/spec/pgit/story_spec.rb +1 -20
- data/spec/spec_helper.rb +101 -0
- metadata +52 -5
- data/lib/pgit/installer.rb +0 -32
- data/spec/pgit/application_spec.rb +0 -16
- data/spec/pgit/installer_spec.rb +0 -158
data/spec/pgit/story_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'PGit::Story' do
|
4
4
|
describe '#get' do
|
@@ -31,24 +31,5 @@ describe 'PGit::Story' do
|
|
31
31
|
expect(story.name).to eq "Bring me the passengers"
|
32
32
|
expect(story.description).to eq "ignore the droids"
|
33
33
|
end
|
34
|
-
|
35
|
-
describe 'if there is an error' do
|
36
|
-
it 'should raise an error' do
|
37
|
-
story_id = '123'
|
38
|
-
current_project = double('current_project', id: '321', api_token: 'abc10xyz')
|
39
|
-
get_request = "curl -X GET -H 'X-TrackerToken: abc10xyz' 'https://www.pivotaltracker.com/services/v5/projects/321/stories/123'"
|
40
|
-
fake_json_str_with_error = <<-ERROR_JSON
|
41
|
-
{
|
42
|
-
"code": "unfound_resource",
|
43
|
-
"kind": "error",
|
44
|
-
"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."
|
45
|
-
}
|
46
|
-
ERROR_JSON
|
47
|
-
|
48
|
-
allow(PGit::Story).to receive(:`).with(get_request).and_return(fake_json_str_with_error)
|
49
|
-
|
50
|
-
expect{ PGit::Story.get(story_id, current_project) }.to raise_error(fake_json_str_with_error)
|
51
|
-
end
|
52
|
-
end
|
53
34
|
end
|
54
35
|
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
10
|
+
# a separate helper file that requires the additional dependencies and performs
|
11
|
+
# the additional setup, and require it from the spec files that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
require 'simplecov'
|
18
|
+
require 'coveralls'
|
19
|
+
|
20
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
21
|
+
SimpleCov::Formatter::HTMLFormatter,
|
22
|
+
Coveralls::SimpleCov::Formatter
|
23
|
+
]
|
24
|
+
|
25
|
+
SimpleCov.start
|
26
|
+
|
27
|
+
require 'pgit'
|
28
|
+
|
29
|
+
RSpec.configure do |config|
|
30
|
+
# rspec-expectations config goes here. You can use an alternate
|
31
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
32
|
+
# assertions if you prefer.
|
33
|
+
config.expect_with :rspec do |expectations|
|
34
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
35
|
+
# and `failure_message` of custom matchers include text for helper methods
|
36
|
+
# defined using `chain`, e.g.:
|
37
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
38
|
+
# # => "be bigger than 2 and smaller than 4"
|
39
|
+
# ...rather than:
|
40
|
+
# # => "be bigger than 2"
|
41
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
42
|
+
end
|
43
|
+
|
44
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
45
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
46
|
+
config.mock_with :rspec do |mocks|
|
47
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
48
|
+
# a real object. This is generally recommended, and will default to
|
49
|
+
# `true` in RSpec 4.
|
50
|
+
mocks.verify_partial_doubles = true
|
51
|
+
end
|
52
|
+
|
53
|
+
# The settings below are suggested to provide a good initial experience
|
54
|
+
# with RSpec, but feel free to customize to your heart's content.
|
55
|
+
=begin
|
56
|
+
# These two settings work together to allow you to limit a spec run
|
57
|
+
# to individual examples or groups you care about by tagging them with
|
58
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
59
|
+
# get run.
|
60
|
+
config.filter_run :focus
|
61
|
+
config.run_all_when_everything_filtered = true
|
62
|
+
|
63
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
64
|
+
# For more details, see:
|
65
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
66
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
67
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
68
|
+
config.disable_monkey_patching!
|
69
|
+
|
70
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
71
|
+
# be too noisy due to issues in dependencies.
|
72
|
+
config.warnings = true
|
73
|
+
|
74
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
75
|
+
# file, and it's useful to allow more verbose output when running an
|
76
|
+
# individual spec file.
|
77
|
+
if config.files_to_run.one?
|
78
|
+
# Use the documentation formatter for detailed output,
|
79
|
+
# unless a formatter has already been configured
|
80
|
+
# (e.g. via a command-line flag).
|
81
|
+
config.default_formatter = 'doc'
|
82
|
+
end
|
83
|
+
|
84
|
+
# Print the 10 slowest examples and example groups at the
|
85
|
+
# end of the spec run, to help surface which specs are running
|
86
|
+
# particularly slow.
|
87
|
+
config.profile_examples = 10
|
88
|
+
|
89
|
+
# Run specs in random order to surface order dependencies. If you find an
|
90
|
+
# order dependency and want to debug it, you can fix the order by providing
|
91
|
+
# the seed, which is printed after each run.
|
92
|
+
# --seed 1234
|
93
|
+
config.order = :random
|
94
|
+
|
95
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
96
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
97
|
+
# test failures related to randomization by passing the same `--seed` value
|
98
|
+
# as the one that triggered the failure.
|
99
|
+
Kernel.srand config.seed
|
100
|
+
=end
|
101
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edderic Ugaddan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coveralls
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.9'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: gli
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,6 +88,7 @@ extensions: []
|
|
60
88
|
extra_rdoc_files:
|
61
89
|
- README.markdown
|
62
90
|
files:
|
91
|
+
- ".coveralls.yml"
|
63
92
|
- ".gitignore"
|
64
93
|
- ".rspec"
|
65
94
|
- ".travis.yml"
|
@@ -70,10 +99,20 @@ files:
|
|
70
99
|
- bin/pgit
|
71
100
|
- lib/pgit.rb
|
72
101
|
- lib/pgit/configuration.rb
|
102
|
+
- lib/pgit/configuration/layout_error.rb
|
103
|
+
- lib/pgit/configuration/missing_attributes_error.rb
|
104
|
+
- lib/pgit/configuration/not_found_error.rb
|
105
|
+
- lib/pgit/configuration/project_missing_error.rb
|
106
|
+
- lib/pgit/configuration/validator.rb
|
73
107
|
- lib/pgit/current_branch.rb
|
74
108
|
- lib/pgit/current_project.rb
|
75
|
-
- lib/pgit/
|
109
|
+
- lib/pgit/current_project/no_paths_match_working_dir_error.rb
|
110
|
+
- lib/pgit/current_project/validator.rb
|
111
|
+
- lib/pgit/error.rb
|
112
|
+
- lib/pgit/external_error.rb
|
113
|
+
- lib/pgit/installer/configuration.rb
|
76
114
|
- lib/pgit/name_parser.rb
|
115
|
+
- lib/pgit/pivotal_request_validator.rb
|
77
116
|
- lib/pgit/story.rb
|
78
117
|
- lib/pgit/story_branch.rb
|
79
118
|
- lib/pgit/story_branch/application.rb
|
@@ -83,16 +122,24 @@ files:
|
|
83
122
|
- man/pgit.1.ronn
|
84
123
|
- pgit.gemspec
|
85
124
|
- pgit.rdoc
|
86
|
-
- spec/pgit/
|
125
|
+
- spec/pgit/configuration/missing_attributes_error_spec.rb
|
126
|
+
- spec/pgit/configuration/not_found_error_spec.rb
|
127
|
+
- spec/pgit/configuration/project_missing_error_spec.rb
|
128
|
+
- spec/pgit/configuration/validator_spec.rb
|
87
129
|
- spec/pgit/configuration_spec.rb
|
88
130
|
- spec/pgit/current_branch_spec.rb
|
131
|
+
- spec/pgit/current_project/no_paths_match_working_dir_error_spec.rb
|
132
|
+
- spec/pgit/current_project/validator_spec.rb
|
89
133
|
- spec/pgit/current_project_spec.rb
|
90
|
-
- spec/pgit/
|
134
|
+
- spec/pgit/external_error_spec.rb
|
135
|
+
- spec/pgit/installer/configuration_spec.rb
|
91
136
|
- spec/pgit/pgit_spec.rb
|
137
|
+
- spec/pgit/pivotal_request_validator_spec.rb
|
92
138
|
- spec/pgit/story_branch/application_spec.rb
|
93
139
|
- spec/pgit/story_branch/name_parser_spec.rb
|
94
140
|
- spec/pgit/story_branch_spec.rb
|
95
141
|
- spec/pgit/story_spec.rb
|
142
|
+
- spec/spec_helper.rb
|
96
143
|
homepage: https://github.com/Edderic/pgit
|
97
144
|
licenses:
|
98
145
|
- MIT
|
data/lib/pgit/installer.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
module PGit
|
2
|
-
class Installer
|
3
|
-
def initialize(glob_opts, opts, args)
|
4
|
-
file_path = "~/.pgit.rc.yml"
|
5
|
-
@expanded_path = File.expand_path(file_path)
|
6
|
-
|
7
|
-
if File.exists? @expanded_path
|
8
|
-
raise "Error: #{file_path} already exists"
|
9
|
-
else
|
10
|
-
ask_continue
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def ask_continue
|
15
|
-
puts "*** Installing example pgit configuration file under ~/.pgit.rc.yml. Continue? [Y/n]"
|
16
|
-
if STDIN.gets.chomp.match(/y/i)
|
17
|
-
puts "Saving example pgit config in ~/.pgit.rc.yml..."
|
18
|
-
write_example_pgit_rc_file
|
19
|
-
else
|
20
|
-
puts "Aborting installation..."
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def write_example_pgit_rc_file
|
25
|
-
File.open(@expanded_path, 'w') do |f|
|
26
|
-
YAML.dump(PGit::Configuration.default_options, f)
|
27
|
-
end
|
28
|
-
|
29
|
-
puts "Saved! Please edit ~/.pgit.rc.yml and add the proper Pivotal Tracker API tokens, id, and file paths for each project"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# require_relative '../../../lib/pgit'
|
2
|
-
#
|
3
|
-
# describe 'PGit::Application' do
|
4
|
-
# describe 'no arguments' do
|
5
|
-
# it 'should bring up the usage' do
|
6
|
-
# argv = []
|
7
|
-
# usage_message = "Usage: pgit\n"\
|
8
|
-
# " cob [pivotal-story-id]"
|
9
|
-
# error_message = "POOP"
|
10
|
-
#
|
11
|
-
# expect do
|
12
|
-
# PGit::Application.new(argv)
|
13
|
-
# end.to raise_error(error_message)
|
14
|
-
# end
|
15
|
-
# end
|
16
|
-
# end
|
data/spec/pgit/installer_spec.rb
DELETED
@@ -1,158 +0,0 @@
|
|
1
|
-
require 'pgit'
|
2
|
-
|
3
|
-
describe 'PGit::Installer' do
|
4
|
-
describe '~/pgit.rc.yml exists' do
|
5
|
-
it 'should raise an error' do
|
6
|
-
global_opts = {}
|
7
|
-
opts = { }
|
8
|
-
args = {}
|
9
|
-
message = "Error: ~/.pgit.rc.yml already exists"
|
10
|
-
default_file_path = "~/.pgit.rc.yml"
|
11
|
-
file_expanded_path = "/home/edderic/.pgit.rc.yml"
|
12
|
-
|
13
|
-
allow(File).to receive(:expand_path).
|
14
|
-
with(".")
|
15
|
-
allow(File).to receive(:expand_path).
|
16
|
-
with(default_file_path).and_return(file_expanded_path)
|
17
|
-
allow(File).to receive(:exists?).
|
18
|
-
with(file_expanded_path).and_return(true)
|
19
|
-
|
20
|
-
expect do
|
21
|
-
PGit::Installer.new(global_opts, opts, args)
|
22
|
-
end.to raise_error message
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '~/pgit.rc.yml does not exist' do
|
27
|
-
it 'should ask to continue or not' do
|
28
|
-
global_opts = {}
|
29
|
-
opts = { }
|
30
|
-
args = {}
|
31
|
-
|
32
|
-
message = "*** Installing example pgit configuration file under ~/.pgit.rc.yml. " +
|
33
|
-
"Continue? [Y/n]"
|
34
|
-
confirmation_message = "Saving example pgit config in ~/.pgit.rc.yml..."
|
35
|
-
edit_message = "Saved! Please edit ~/.pgit.rc.yml and add the proper Pivotal Tracker API tokens, id, and file paths for each project"
|
36
|
-
answer = instance_double("String", chomp: 'y')
|
37
|
-
expanded_path = "/home/edderic/.pgit.rc.yml"
|
38
|
-
fake_writable_file = double('File')
|
39
|
-
allow(File).to receive(:expand_path).with("~/.pgit.rc.yml").and_return(expanded_path)
|
40
|
-
allow(File).to receive(:exists?).with(expanded_path).and_return(false)
|
41
|
-
allow(File).to receive(:open).with(expanded_path, 'w').and_return(fake_writable_file)
|
42
|
-
allow(STDIN).to receive(:gets).and_return(answer)
|
43
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(message)
|
44
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(confirmation_message)
|
45
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(edit_message)
|
46
|
-
installer = PGit::Installer.new(global_opts, opts, args)
|
47
|
-
|
48
|
-
expect(installer).to have_received(:puts).with(message)
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'user answers "y"' do
|
52
|
-
it "should show the save message" do
|
53
|
-
global_opts = {}
|
54
|
-
opts = { }
|
55
|
-
args = {}
|
56
|
-
|
57
|
-
first_message = "*** Installing example pgit configuration file under ~/.pgit.rc.yml. " +
|
58
|
-
"Continue? [Y/n]"
|
59
|
-
save_message = "Saving example pgit config in ~/.pgit.rc.yml..."
|
60
|
-
expanded_path = "/home/edderic/.pgit.rc.yml"
|
61
|
-
edit_message = "Saved! Please edit ~/.pgit.rc.yml and add the proper Pivotal Tracker API tokens, id, and file paths for each project"
|
62
|
-
fake_writable_file = double('File')
|
63
|
-
allow(File).to receive(:expand_path).with("~/.pgit.rc.yml").and_return(expanded_path)
|
64
|
-
allow(File).to receive(:exists?).with(expanded_path).and_return(false)
|
65
|
-
allow(File).to receive(:open).with(expanded_path, 'w').and_return(fake_writable_file)
|
66
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(edit_message)
|
67
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(first_message)
|
68
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(save_message)
|
69
|
-
|
70
|
-
answer = instance_double("String", chomp: 'Y')
|
71
|
-
allow(STDIN).to receive(:gets).and_return(answer)
|
72
|
-
|
73
|
-
installer = PGit::Installer.new(global_opts, opts, args)
|
74
|
-
|
75
|
-
expect(installer).to have_received(:puts).with(save_message)
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should save the file under ~/.pgit.rc.yml' do
|
79
|
-
global_opts = {}
|
80
|
-
opts = { }
|
81
|
-
args = {}
|
82
|
-
|
83
|
-
first_message = "*** Installing example pgit configuration file under ~/.pgit.rc.yml. " +
|
84
|
-
"Continue? [Y/n]"
|
85
|
-
save_message = "Saving example pgit config in ~/.pgit.rc.yml..."
|
86
|
-
expanded_path = "/home/edderic/.pgit.rc.yml"
|
87
|
-
fake_writable_file = double('File')
|
88
|
-
edit_message = "Saved! Please edit ~/.pgit.rc.yml and add the proper Pivotal Tracker API tokens, id, and file paths for each project"
|
89
|
-
allow(File).to receive(:expand_path).with("~/.pgit.rc.yml").and_return(expanded_path)
|
90
|
-
allow(File).to receive(:exists?).with(expanded_path).and_return(false)
|
91
|
-
allow(File).to receive(:open).with(expanded_path, 'w').and_return(fake_writable_file)
|
92
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(first_message)
|
93
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(save_message)
|
94
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(edit_message)
|
95
|
-
|
96
|
-
answer = instance_double("String", chomp: 'Y')
|
97
|
-
allow(STDIN).to receive(:gets).and_return(answer)
|
98
|
-
|
99
|
-
installer = PGit::Installer.new(global_opts, opts, args)
|
100
|
-
|
101
|
-
expect(File).to have_received(:open).with(expanded_path, 'w')
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'should ask the user to edit the config file' do
|
105
|
-
global_opts = {}
|
106
|
-
opts = { }
|
107
|
-
args = {}
|
108
|
-
|
109
|
-
first_message = "*** Installing example pgit configuration file under ~/.pgit.rc.yml. " +
|
110
|
-
"Continue? [Y/n]"
|
111
|
-
save_message = "Saving example pgit config in ~/.pgit.rc.yml..."
|
112
|
-
edit_message = "Saved! Please edit ~/.pgit.rc.yml and add the proper Pivotal Tracker API tokens, id, and file paths for each project"
|
113
|
-
expanded_path = "/home/edderic/.pgit.rc.yml"
|
114
|
-
fake_writable_file = double('File')
|
115
|
-
allow(File).to receive(:expand_path).with("~/.pgit.rc.yml").and_return(expanded_path)
|
116
|
-
allow(File).to receive(:exists?).with(expanded_path).and_return(false)
|
117
|
-
allow(File).to receive(:open).with(expanded_path, 'w').and_return(fake_writable_file)
|
118
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(first_message)
|
119
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(edit_message)
|
120
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(save_message)
|
121
|
-
|
122
|
-
answer = instance_double("String", chomp: 'Y')
|
123
|
-
allow(STDIN).to receive(:gets).and_return(answer)
|
124
|
-
|
125
|
-
installer = PGit::Installer.new(global_opts, opts, args)
|
126
|
-
|
127
|
-
expect(installer).to have_received(:puts).with(edit_message)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe 'user answers with "n"' do
|
132
|
-
it "should show the abort message" do
|
133
|
-
message = "Aborting installation..."
|
134
|
-
global_opts = {}
|
135
|
-
opts = { }
|
136
|
-
args = {}
|
137
|
-
|
138
|
-
first_message = "*** Installing example pgit configuration file under ~/.pgit.rc.yml. " +
|
139
|
-
"Continue? [Y/n]"
|
140
|
-
expanded_path = "/home/edderic/.pgit.rc.yml"
|
141
|
-
allow(File).to receive(:expand_path).with("~/.pgit.rc.yml").and_return(expanded_path)
|
142
|
-
allow(File).to receive(:exists?).with(expanded_path).and_return(false)
|
143
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(first_message)
|
144
|
-
allow_any_instance_of(PGit::Installer).to receive(:puts).with(message)
|
145
|
-
|
146
|
-
answer = instance_double("String", chomp: 'n')
|
147
|
-
allow(STDIN).to receive(:gets).and_return(answer)
|
148
|
-
|
149
|
-
installer = PGit::Installer.new(global_opts, opts, args)
|
150
|
-
|
151
|
-
expect(installer).to have_received(:puts).with(message)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
describe 'user answers with something els' do
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|