pra 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CODE_OF_CONDUCT.md +13 -0
- data/ChangeLog.md +11 -0
- data/Gemfile +1 -1
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/{bin → exe}/pra +0 -0
- data/lib/pra/config.rb +4 -0
- data/lib/pra/curses_window_system.rb +11 -5
- data/lib/pra/error_log.rb +3 -2
- data/lib/pra/log.rb +12 -0
- data/lib/pra/version.rb +1 -1
- data/pra.gemspec +6 -4
- metadata +27 -39
- data/spec/lib/pra/app_spec.rb +0 -91
- data/spec/lib/pra/config_spec.rb +0 -154
- data/spec/lib/pra/curses_pull_request_presenter_spec.rb +0 -136
- data/spec/lib/pra/curses_window_system_spec.rb +0 -4
- data/spec/lib/pra/error_log_spec.rb +0 -30
- data/spec/lib/pra/github_pull_source_spec.rb +0 -140
- data/spec/lib/pra/pull_request_service/fetch_status_spec.rb +0 -127
- data/spec/lib/pra/pull_request_service_spec.rb +0 -118
- data/spec/lib/pra/pull_request_spec.rb +0 -4
- data/spec/lib/pra/pull_source_factory_spec.rb +0 -40
- data/spec/lib/pra/pull_source_spec.rb +0 -17
- data/spec/lib/pra/stash_pull_source_spec.rb +0 -161
- data/spec/lib/pra/window_system_factory_spec.rb +0 -13
- data/spec/lib/pra/window_system_spec.rb +0 -33
- data/spec/spec_helper.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a063ef78ae81ceafd14952d89b66d26d845d273f
|
4
|
+
data.tar.gz: ed692ee5c5c21002c1b2ca6474ee43f49c75c7c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8037f43d080d52c638a686f28d44098ee7a200653dd0249ce0ded97659ac39aee205ad0c6dd7cffd762bbedda74d70bd4feb11353793e56c475915e1435637ac
|
7
|
+
data.tar.gz: 37c1b7759f3075bbf9dbe4c4c321f5602ffd0f57f78679ace1cbc8cdf801eaf1586ffd0fbf50f395121d702917dfb62653786c5fbc86547179e3e2dee60f199f
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.3
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/ChangeLog.md
CHANGED
@@ -6,6 +6,17 @@ versions as well as provide a rough history.
|
|
6
6
|
|
7
7
|
#### Next Release
|
8
8
|
|
9
|
+
#### v1.7.0
|
10
|
+
|
11
|
+
* Upgrade to latest gem standards
|
12
|
+
* Fix flash on navigation change
|
13
|
+
* Switch to default terminal color scheme
|
14
|
+
* Add light weight logging with timestamps
|
15
|
+
* Add Ruby 2.2.3 support
|
16
|
+
* Add Ruby 2.2.2 support
|
17
|
+
|
18
|
+
#### v1.6.0
|
19
|
+
|
9
20
|
* Switch to using Faraday instead of RestClient.
|
10
21
|
|
11
22
|
#### v1.5.1
|
data/Gemfile
CHANGED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pra"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/{bin → exe}/pra
RENAMED
File without changes
|
data/lib/pra/config.rb
CHANGED
@@ -69,8 +69,9 @@ module Pra
|
|
69
69
|
Curses.init_screen
|
70
70
|
Curses.stdscr.keypad(true)
|
71
71
|
Curses.start_color
|
72
|
+
Curses.use_default_colors
|
72
73
|
Curses.curs_set(0)
|
73
|
-
Curses.init_pair(
|
74
|
+
Curses.init_pair(Curses::COLOR_CYAN, Curses::COLOR_CYAN, Curses::COLOR_WHITE)
|
74
75
|
end
|
75
76
|
|
76
77
|
def output_string(row, col, str)
|
@@ -81,7 +82,7 @@ module Pra
|
|
81
82
|
end
|
82
83
|
|
83
84
|
def output_highlighted_string(row, col, str)
|
84
|
-
Curses.attron(Curses.color_pair(
|
85
|
+
Curses.attron(Curses.color_pair(Curses::COLOR_CYAN)|Curses::A_NORMAL) {
|
85
86
|
output_string(row, col, str)
|
86
87
|
}
|
87
88
|
end
|
@@ -116,9 +117,14 @@ module Pra
|
|
116
117
|
output_string(HEADER_LINE, 0, "repository title from_reference to_reference author assignee service")
|
117
118
|
output_string(HEADER_LINE + 1, 0, "-----------------------------------------------------------------------------------------------------------------------------------------------")
|
118
119
|
|
119
|
-
|
120
|
-
|
121
|
-
|
120
|
+
if @previous_number_of_pull_requests > @current_pull_requests.length
|
121
|
+
num_left_over = @previous_number_of_pull_requests - @current_pull_requests.length
|
122
|
+
start_line_of_left_overs = LIST_START_LINE+@current_pull_requests.length + 1
|
123
|
+
last_line_of_left_overs = LIST_START_LINE+@previous_number_of_pull_requests
|
124
|
+
(start_line_of_left_oversc...last_line_of_left_overs).each do |i|
|
125
|
+
Curses.setpos(i,0)
|
126
|
+
Curses.clrtoeol
|
127
|
+
end
|
122
128
|
Curses.refresh
|
123
129
|
end
|
124
130
|
|
data/lib/pra/error_log.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'pra/config'
|
2
|
+
require 'date'
|
2
3
|
|
3
4
|
module Pra
|
4
5
|
class ErrorLog
|
5
6
|
def self.log(error)
|
6
7
|
File.open(Pra::Config.error_log_path, 'a') do |f|
|
7
|
-
f.puts(error.message)
|
8
|
+
f.puts("#{DateTime.now.iso8601} - #{error.message}")
|
8
9
|
error.backtrace.each { |line| f.puts(line) }
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
12
|
-
end
|
13
|
+
end
|
data/lib/pra/log.rb
ADDED
data/lib/pra/version.rb
CHANGED
data/pra.gemspec
CHANGED
@@ -10,17 +10,19 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["cyphactor@gmail.com"]
|
11
11
|
spec.description = %q{Command Line utility to make you aware of open pull-requests across systems at all times.}
|
12
12
|
spec.summary = %q{CLI tool that shows open pull-requests across systems.}
|
13
|
-
spec.homepage = "http://github.com/
|
13
|
+
spec.homepage = "http://github.com/codebreakdown/pra"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
17
|
-
spec.
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
20
|
spec.require_paths = ["lib"]
|
20
21
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
23
|
spec.add_development_dependency "rake", "~> 10.1"
|
23
24
|
spec.add_development_dependency "rspec", "~> 2.14"
|
25
|
+
spec.add_development_dependency "timecop", "~> 0.8"
|
24
26
|
|
25
27
|
spec.add_dependency "faraday", "~> 0.9"
|
26
28
|
spec.add_dependency "launchy", "~> 2.4"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew De Ponte
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: timecop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.8'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: faraday
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,12 +119,15 @@ extra_rdoc_files: []
|
|
105
119
|
files:
|
106
120
|
- ".gitignore"
|
107
121
|
- ".ruby-version"
|
122
|
+
- CODE_OF_CONDUCT.md
|
108
123
|
- ChangeLog.md
|
109
124
|
- Gemfile
|
110
125
|
- LICENSE.txt
|
111
126
|
- README.md
|
112
127
|
- Rakefile
|
113
|
-
- bin/
|
128
|
+
- bin/console
|
129
|
+
- bin/setup
|
130
|
+
- exe/pra
|
114
131
|
- lib/pra.rb
|
115
132
|
- lib/pra/app.rb
|
116
133
|
- lib/pra/config.rb
|
@@ -118,6 +135,7 @@ files:
|
|
118
135
|
- lib/pra/curses_window_system.rb
|
119
136
|
- lib/pra/error_log.rb
|
120
137
|
- lib/pra/github_pull_source.rb
|
138
|
+
- lib/pra/log.rb
|
121
139
|
- lib/pra/pull_request.rb
|
122
140
|
- lib/pra/pull_request_service.rb
|
123
141
|
- lib/pra/pull_request_service/fetch_status.rb
|
@@ -128,22 +146,7 @@ files:
|
|
128
146
|
- lib/pra/window_system.rb
|
129
147
|
- lib/pra/window_system_factory.rb
|
130
148
|
- pra.gemspec
|
131
|
-
|
132
|
-
- spec/lib/pra/config_spec.rb
|
133
|
-
- spec/lib/pra/curses_pull_request_presenter_spec.rb
|
134
|
-
- spec/lib/pra/curses_window_system_spec.rb
|
135
|
-
- spec/lib/pra/error_log_spec.rb
|
136
|
-
- spec/lib/pra/github_pull_source_spec.rb
|
137
|
-
- spec/lib/pra/pull_request_service/fetch_status_spec.rb
|
138
|
-
- spec/lib/pra/pull_request_service_spec.rb
|
139
|
-
- spec/lib/pra/pull_request_spec.rb
|
140
|
-
- spec/lib/pra/pull_source_factory_spec.rb
|
141
|
-
- spec/lib/pra/pull_source_spec.rb
|
142
|
-
- spec/lib/pra/stash_pull_source_spec.rb
|
143
|
-
- spec/lib/pra/window_system_factory_spec.rb
|
144
|
-
- spec/lib/pra/window_system_spec.rb
|
145
|
-
- spec/spec_helper.rb
|
146
|
-
homepage: http://github.com/reachlocal/pra
|
149
|
+
homepage: http://github.com/codebreakdown/pra
|
147
150
|
licenses:
|
148
151
|
- MIT
|
149
152
|
metadata: {}
|
@@ -163,23 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
166
|
version: '0'
|
164
167
|
requirements: []
|
165
168
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
169
|
+
rubygems_version: 2.4.5.1
|
167
170
|
signing_key:
|
168
171
|
specification_version: 4
|
169
172
|
summary: CLI tool that shows open pull-requests across systems.
|
170
|
-
test_files:
|
171
|
-
- spec/lib/pra/app_spec.rb
|
172
|
-
- spec/lib/pra/config_spec.rb
|
173
|
-
- spec/lib/pra/curses_pull_request_presenter_spec.rb
|
174
|
-
- spec/lib/pra/curses_window_system_spec.rb
|
175
|
-
- spec/lib/pra/error_log_spec.rb
|
176
|
-
- spec/lib/pra/github_pull_source_spec.rb
|
177
|
-
- spec/lib/pra/pull_request_service/fetch_status_spec.rb
|
178
|
-
- spec/lib/pra/pull_request_service_spec.rb
|
179
|
-
- spec/lib/pra/pull_request_spec.rb
|
180
|
-
- spec/lib/pra/pull_source_factory_spec.rb
|
181
|
-
- spec/lib/pra/pull_source_spec.rb
|
182
|
-
- spec/lib/pra/stash_pull_source_spec.rb
|
183
|
-
- spec/lib/pra/window_system_factory_spec.rb
|
184
|
-
- spec/lib/pra/window_system_spec.rb
|
185
|
-
- spec/spec_helper.rb
|
173
|
+
test_files: []
|
data/spec/lib/pra/app_spec.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require_relative "../../../lib/pra/app"
|
2
|
-
|
3
|
-
describe Pra::App do
|
4
|
-
describe "#run" do
|
5
|
-
it "builds the window system" do
|
6
|
-
subject.stub(:spawn_pull_request_fetcher)
|
7
|
-
window_system_double = double('window system', setup: nil, run_loop: nil)
|
8
|
-
expect(Pra::WindowSystemFactory).to receive(:build).with('curses').and_return(window_system_double)
|
9
|
-
subject.run
|
10
|
-
end
|
11
|
-
|
12
|
-
it "sets up the window system" do
|
13
|
-
subject.stub(:spawn_pull_request_fetcher)
|
14
|
-
window_system_double = double('window system', run_loop: nil)
|
15
|
-
Pra::WindowSystemFactory.stub(:build).and_return(window_system_double)
|
16
|
-
expect(window_system_double).to receive(:setup)
|
17
|
-
subject.run
|
18
|
-
end
|
19
|
-
|
20
|
-
it "spawns the pull request fetcher thread" do
|
21
|
-
window_system_double = double('window system', setup: nil, run_loop: nil)
|
22
|
-
Pra::WindowSystemFactory.stub(:build).and_return(window_system_double)
|
23
|
-
expect(subject).to receive(:spawn_pull_request_fetcher)
|
24
|
-
subject.run
|
25
|
-
end
|
26
|
-
|
27
|
-
it "starts the window system run loop" do
|
28
|
-
subject.stub(:spawn_pull_request_fetcher)
|
29
|
-
window_system_double = double('window system', setup: nil, refresh_pull_requests: nil)
|
30
|
-
Pra::WindowSystemFactory.stub(:build).and_return(window_system_double)
|
31
|
-
expect(window_system_double).to receive(:run_loop)
|
32
|
-
subject.run
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#fetch_and_refresh_pull_requests" do
|
37
|
-
let(:pull_request_one) { double }
|
38
|
-
let(:pull_request_two) { double }
|
39
|
-
let(:error) { double('error fetching pull requests', message: double('error message'), backtrace: double('backtrace')) }
|
40
|
-
let(:good_source_one) { double('good pull source one', :pull_requests => [pull_request_one]) }
|
41
|
-
let(:good_source_two) { double('good pull source two', :pull_requests => [pull_request_two])}
|
42
|
-
let(:bad_source) { double('bad pull source') }
|
43
|
-
let(:success_status_one) { Pra::PullRequestService::FetchStatus.success([pull_request_one]) }
|
44
|
-
let(:success_status_two) { Pra::PullRequestService::FetchStatus.success([pull_request_two])}
|
45
|
-
let(:error_status) { Pra::PullRequestService::FetchStatus.error(error) }
|
46
|
-
let(:window_system_double) { double('window system', refresh_pull_requests: nil, fetch_failed: nil, fetching_pull_requests: nil) }
|
47
|
-
|
48
|
-
before do
|
49
|
-
allow(Kernel).to receive(:sleep)
|
50
|
-
allow(Pra::PullRequestService).to receive(:fetch_pull_requests).
|
51
|
-
and_yield(success_status_one).
|
52
|
-
and_yield(error_status).
|
53
|
-
and_yield(success_status_two)
|
54
|
-
allow(Pra::ErrorLog).to receive(:log)
|
55
|
-
subject.instance_variable_set(:@window_system, window_system_double)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "notifies the window system it is starting to fetch pull requests" do
|
59
|
-
expect(window_system_double).to receive(:fetching_pull_requests)
|
60
|
-
subject.fetch_and_refresh_pull_requests
|
61
|
-
end
|
62
|
-
|
63
|
-
it "fetches the pull requests from all of the sources" do
|
64
|
-
expect(Pra::PullRequestService).to receive(:fetch_pull_requests)
|
65
|
-
subject.fetch_and_refresh_pull_requests
|
66
|
-
end
|
67
|
-
|
68
|
-
it "tells the window system to refresh with the fetched pull requests" do
|
69
|
-
expect(window_system_double).to receive(:refresh_pull_requests).with([pull_request_one, pull_request_two])
|
70
|
-
subject.fetch_and_refresh_pull_requests
|
71
|
-
end
|
72
|
-
|
73
|
-
it "tells the window system about failures" do
|
74
|
-
expect(window_system_double).to receive(:fetch_failed)
|
75
|
-
subject.fetch_and_refresh_pull_requests
|
76
|
-
end
|
77
|
-
|
78
|
-
it "logs the errors for pull sources that could not be fetched" do
|
79
|
-
expect(Pra::ErrorLog).to receive(:log).with(error)
|
80
|
-
subject.fetch_and_refresh_pull_requests
|
81
|
-
end
|
82
|
-
|
83
|
-
it "sleeps for the polling frequency" do
|
84
|
-
window_system_double = double('window system', refresh_pull_requests: nil, fetching_pull_requests: nil)
|
85
|
-
subject.instance_variable_set(:@window_system, window_system_double)
|
86
|
-
Pra::PullRequestService.stub(:fetch_pull_requests)
|
87
|
-
expect(Kernel).to receive(:sleep)
|
88
|
-
subject.fetch_and_refresh_pull_requests
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
data/spec/lib/pra/config_spec.rb
DELETED
@@ -1,154 +0,0 @@
|
|
1
|
-
require_relative "../../../lib/pra/config"
|
2
|
-
|
3
|
-
describe Pra::Config do
|
4
|
-
describe "#initialize" do
|
5
|
-
it "assigns the provide default config hash" do
|
6
|
-
config_hash = { some: "hash" }
|
7
|
-
config = Pra::Config.new(config_hash)
|
8
|
-
config.instance_variable_get(:@initial_config).should eq(config_hash)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe ".load_config" do
|
13
|
-
subject { Pra::Config }
|
14
|
-
|
15
|
-
it "parses the config file" do
|
16
|
-
subject.should_receive(:parse_config_file)
|
17
|
-
subject.load_config
|
18
|
-
end
|
19
|
-
|
20
|
-
it "constructs an instance of the config from the parsed config" do
|
21
|
-
parsed_config = double('parsed config file')
|
22
|
-
subject.stub(:parse_config_file).and_return(parsed_config)
|
23
|
-
subject.should_receive(:new).with(parsed_config)
|
24
|
-
subject.load_config
|
25
|
-
end
|
26
|
-
|
27
|
-
it "returns the instance of the config object" do
|
28
|
-
subject.stub(:parse_config_file)
|
29
|
-
config = double('config')
|
30
|
-
subject.stub(:new).and_return(config)
|
31
|
-
subject.load_config.should eq(config)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe ".parse_config_file" do
|
36
|
-
subject { Pra::Config }
|
37
|
-
|
38
|
-
it "reads the users config" do
|
39
|
-
subject.stub(:json_parse)
|
40
|
-
subject.should_receive(:read_config_file)
|
41
|
-
subject.parse_config_file
|
42
|
-
end
|
43
|
-
|
44
|
-
it "json parses the config contents" do
|
45
|
-
config_contents = double('config contents')
|
46
|
-
subject.stub(:read_config_file).and_return(config_contents)
|
47
|
-
subject.should_receive(:json_parse).with(config_contents)
|
48
|
-
subject.parse_config_file
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe ".read_config_file" do
|
53
|
-
subject { Pra::Config }
|
54
|
-
|
55
|
-
it "opens the file" do
|
56
|
-
config_path = double('config path')
|
57
|
-
subject.stub(:config_path).and_return(config_path)
|
58
|
-
File.should_receive(:open).with(config_path, "r").and_return(double('config file').as_null_object)
|
59
|
-
subject.read_config_file
|
60
|
-
end
|
61
|
-
|
62
|
-
it "reads the files contents" do
|
63
|
-
subject.stub(:config_path)
|
64
|
-
file = double('config file').as_null_object
|
65
|
-
File.stub(:open).and_return(file)
|
66
|
-
file.should_receive(:read)
|
67
|
-
subject.read_config_file
|
68
|
-
end
|
69
|
-
|
70
|
-
it "closes the file" do
|
71
|
-
subject.stub(:config_path)
|
72
|
-
file = double('config file', read: nil)
|
73
|
-
File.stub(:open).and_return(file)
|
74
|
-
file.should_receive(:close)
|
75
|
-
subject.read_config_file
|
76
|
-
end
|
77
|
-
|
78
|
-
it "returns the file contents" do
|
79
|
-
subject.stub(:config_path)
|
80
|
-
file = double('config file', close: nil)
|
81
|
-
File.stub(:open).and_return(file)
|
82
|
-
file.stub(:read).and_return('some file contents')
|
83
|
-
subject.read_config_file.should eq('some file contents')
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe ".config_path" do
|
88
|
-
subject { Pra::Config }
|
89
|
-
|
90
|
-
it "returns the joined users home directory and .pra.json to create the path" do
|
91
|
-
subject.stub(:users_home_directory).and_return('/home/someuser')
|
92
|
-
subject.config_path.should eq('/home/someuser/.pra.json')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe ".error_log_path" do
|
97
|
-
subject { Pra::Config }
|
98
|
-
|
99
|
-
it "returns the joined users home directory and .pra.error.log to create the path" do
|
100
|
-
allow(subject).to receive(:users_home_directory).and_return('/home/someuser')
|
101
|
-
expect(subject.error_log_path).to eq('/home/someuser/.pra.errors.log')
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe ".users_home_directory" do
|
106
|
-
subject { Pra::Config }
|
107
|
-
|
108
|
-
it "returns the current users home directory" do
|
109
|
-
ENV['HOME'] = '/home/someuser'
|
110
|
-
subject.users_home_directory.should eq('/home/someuser')
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe ".json_parse" do
|
115
|
-
subject { Pra::Config }
|
116
|
-
|
117
|
-
it "parses the given content as json" do
|
118
|
-
content = double('some json content')
|
119
|
-
JSON.should_receive(:parse).with(content)
|
120
|
-
subject.json_parse(content)
|
121
|
-
end
|
122
|
-
|
123
|
-
it "returns the parsed result" do
|
124
|
-
parsed_json = double('the parsed json')
|
125
|
-
JSON.stub(:parse).and_return(parsed_json)
|
126
|
-
subject.json_parse(double).should eq(parsed_json)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe "#pull_sources" do
|
131
|
-
it "returns the pull sources value out of the config" do
|
132
|
-
pull_source_configs = double('pull source configs')
|
133
|
-
subject.instance_variable_set(:@initial_config, { "pull_sources" => pull_source_configs })
|
134
|
-
subject.pull_sources.should eq(pull_source_configs)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe "#assignee_blacklist" do
|
139
|
-
context 'when config has an assignee blacklist' do
|
140
|
-
it "returns the assignee blacklist value out of the config" do
|
141
|
-
assignee_blacklist_configs = [double('assignee blacklist configs')]
|
142
|
-
subject.instance_variable_set(:@initial_config, { "assignee_blacklist" => assignee_blacklist_configs })
|
143
|
-
subject.assignee_blacklist.should eq(assignee_blacklist_configs)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
context "when config does not have an assignee blacklist" do
|
148
|
-
it "returns an empty array" do
|
149
|
-
subject.instance_variable_set(:@initial_config, {})
|
150
|
-
subject.assignee_blacklist.should eq([])
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|