pra 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 990d69dd58accffc7a9a697b26589334785b0eed
4
- data.tar.gz: e075ae03f303e947c04b7275d22cb3b58a72e03f
3
+ metadata.gz: a2be92bf55869e2dd6b07043ef8bd1826698895d
4
+ data.tar.gz: 105bfd005ecf099bb7b25a8b61131a4155b0a724
5
5
  SHA512:
6
- metadata.gz: e6fc9ec8e865363b814e8e453a8918aeb1a483dae88ac5ad3fc37d64b5c410e7c7eb0cda259ef90f71e293eb518fd579f4a6f2369601f08c57b4f8e1f6ecdf33
7
- data.tar.gz: f8b78ff247073c23f30e38df0a3601a6493a3c4490748572dc7d9eec0fefdee879fa9ec4293a0ac34094bddaa4b52435f10222064c4a6f900f673f84d0084c9c
6
+ metadata.gz: f83912cc359bfd70f36747b7c7493ed06906073fc2715b91dcede0fb9b42eb6be1212b8c519c42f4ba4acaa4445217705cc747011815543d3dc2b8f5514350c4
7
+ data.tar.gz: 85833ebe12ef250ed4c355d183ae2aced925c4e6e8b7fbaea22f804e698133d398eca30f8a0ba7f8174cd81b3f80520a24b7a7d25e001ff10a32f196447b52fd
data/ChangeLog.md CHANGED
@@ -6,6 +6,15 @@ versions as well as provide a rough history.
6
6
 
7
7
  #### Next Release
8
8
 
9
+ #### v1.0.0
10
+
11
+ * Added connection failure handling so it stays running
12
+ ([\#1](https://github.com/reachlocal/pra/issues/1))
13
+ * Added user notification of connection failures
14
+ ([\#1](https://github.com/reachlocal/pra/issues/1))
15
+ * Added error logging to `~/.pra.error.log`
16
+ ([\#1](https://github.com/reachlocal/pra/issues/1))
17
+
9
18
  #### v0.1.1
10
19
 
11
20
  * Fixed up the gemspec to include homepage on rubygems.org
data/README.md CHANGED
@@ -57,6 +57,37 @@ file to get you started. Then simply replace the appropriate fields and the
57
57
  **repositories** sections for all the pull sources with the repository
58
58
  information for the repositories you want to watch for open pull requests.
59
59
 
60
+ ### GitHub Authentication
61
+
62
+ #### Multi-Factor Authentication
63
+
64
+ Sadly, at the moment `pra` doesn't support GitHub's Multi-Factor
65
+ Authentication. There is a ticket for this
66
+ ( [\#5](https://github.com/reachlocal/pra/issues/5) ).
67
+
68
+ #### OAuth
69
+
70
+ It is also lacking support for GitHub's OAuth mechanism. There is a ticket for
71
+ this ( [\#6](https://github.com/reachlocal/pra/issues/6) ).
72
+
73
+ #### HTTP Basic Auth
74
+
75
+ The HTTP Basic Auth will work as long as you don't have multi-factor
76
+ authentication enabled for your account.
77
+
78
+ #### Personal Access Token
79
+
80
+ Personal Access Token authentication is currently supported and this is the
81
+ recommended authentication mechanism to use right now. It is the only
82
+ authentication mechanism you can use at the moment if you have multi-factor
83
+ authentication enabled.
84
+
85
+ Simply go to your GitHub **Account Settings**, select **Applications**, click
86
+ the **Create new token** button in the **Personal Access Token** section. Give
87
+ it the name "Pra" and submit. This will generate your personal access token.
88
+ Then simply put your personal access token in the `~/.pra.json` as your GitHub
89
+ username and "x-oauth-basic" as your GitHub password.
90
+
60
91
  ## Usage
61
92
 
62
93
  Once you have configured `pra` as described above you can launch it by simply
data/lib/pra/app.rb CHANGED
@@ -2,6 +2,7 @@ require 'thread'
2
2
 
3
3
  require 'pra/window_system_factory'
4
4
  require 'pra/pull_request_service'
5
+ require 'pra/error_log'
5
6
 
6
7
  Thread.abort_on_exception=true
7
8
 
@@ -22,8 +23,21 @@ module Pra
22
23
 
23
24
  def fetch_and_refresh_pull_requests
24
25
  @window_system.fetching_pull_requests
25
- pull_requests = Pra::PullRequestService.fetch_pull_requests
26
- @window_system.refresh_pull_requests(pull_requests)
26
+ new_pull_requests = []
27
+
28
+ Pra::PullRequestService.fetch_pull_requests do |fetch|
29
+ fetch.on_success do |pull_requests|
30
+ new_pull_requests += pull_requests
31
+ end
32
+
33
+ fetch.on_error do |error|
34
+ Pra::ErrorLog.log(error)
35
+ @window_system.fetch_failed
36
+ end
37
+ end
38
+
39
+ @window_system.refresh_pull_requests(new_pull_requests)
40
+
27
41
  Kernel.sleep(5 * 60)
28
42
  end
29
43
 
data/lib/pra/config.rb CHANGED
@@ -25,6 +25,10 @@ module Pra
25
25
  return File.join(self.users_home_directory, '.pra.json')
26
26
  end
27
27
 
28
+ def self.error_log_path
29
+ return File.join(self.users_home_directory, '.pra.errors.log')
30
+ end
31
+
28
32
  def self.users_home_directory
29
33
  return ENV['HOME']
30
34
  end
@@ -1,4 +1,5 @@
1
1
  require 'pra/window_system'
2
+ require 'pra/config'
2
3
  require 'launchy'
3
4
  require 'curses'
4
5
  require 'thread'
@@ -22,6 +23,12 @@ module Pra
22
23
 
23
24
  def fetching_pull_requests
24
25
  output_string(3, 0, "Fetching pull requests...")
26
+ Curses.setpos(4,0)
27
+ Curses.clrtoeol
28
+ end
29
+
30
+ def fetch_failed
31
+ output_string(4, 0, "Failed to fetch pull requests on 1 or more pull sources. Check #{Pra::Config.error_log_path} for details.")
25
32
  end
26
33
 
27
34
  def refresh_pull_requests(pull_requests)
@@ -99,13 +106,16 @@ module Pra
99
106
  }
100
107
  end
101
108
 
109
+ HEADER_LINE = 6
110
+ LIST_START_LINE = HEADER_LINE + 2
111
+
102
112
  def draw_current_pull_requests
103
113
  @state_lock.synchronize {
104
114
  output_string(3, 0, "#{@current_pull_requests.length} Pull Requests")
105
- output_string(5, 0, "repository title from_reference to_reference author service")
106
- output_string(6, 0, "--------------------------------------------------------------------------------------------------------------------------------")
115
+ output_string(HEADER_LINE, 0, "repository title from_reference to_reference author service")
116
+ output_string(HEADER_LINE + 1, 0, "--------------------------------------------------------------------------------------------------------------------------------")
107
117
 
108
- (7...7+@previous_number_of_pull_requests).each do |i|
118
+ (LIST_START_LINE...LIST_START_LINE+@previous_number_of_pull_requests).each do |i|
109
119
  Curses.setpos(i,0)
110
120
  Curses.clrtoeol
111
121
  Curses.refresh
@@ -113,9 +123,9 @@ module Pra
113
123
 
114
124
  @current_pull_requests.each_with_index do |pull_request, index|
115
125
  if index == @selected_pull_request_index
116
- output_highlighted_string(7 + index, 0, "#{pull_request.repository.ljust(15)[0..14]}\t#{pull_request.title.ljust(20)[0..19]}\t#{pull_request.from_reference.ljust(20)[0..19]}\t#{pull_request.to_reference.ljust(20)[0..19]}\t#{pull_request.author.ljust(20)[0..19]}\t#{pull_request.service_id.ljust(10)[0..9]}")
126
+ output_highlighted_string(LIST_START_LINE + index, 0, "#{pull_request.repository.ljust(15)[0..14]}\t#{pull_request.title.ljust(20)[0..19]}\t#{pull_request.from_reference.ljust(20)[0..19]}\t#{pull_request.to_reference.ljust(20)[0..19]}\t#{pull_request.author.ljust(20)[0..19]}\t#{pull_request.service_id.ljust(10)[0..9]}")
117
127
  else
118
- output_string(7 + index, 0, "#{pull_request.repository.ljust(15)[0..14]}\t#{pull_request.title.ljust(20)[0..19]}\t#{pull_request.from_reference.ljust(20)[0..19]}\t#{pull_request.to_reference.ljust(20)[0..19]}\t#{pull_request.author.ljust(20)[0..19]}\t#{pull_request.service_id.ljust(10)[0..9]}")
128
+ output_string(LIST_START_LINE + index, 0, "#{pull_request.repository.ljust(15)[0..14]}\t#{pull_request.title.ljust(20)[0..19]}\t#{pull_request.from_reference.ljust(20)[0..19]}\t#{pull_request.to_reference.ljust(20)[0..19]}\t#{pull_request.author.ljust(20)[0..19]}\t#{pull_request.service_id.ljust(10)[0..9]}")
119
129
  end
120
130
  end
121
131
  }
@@ -0,0 +1,12 @@
1
+ require 'pra/config'
2
+
3
+ module Pra
4
+ class ErrorLog
5
+ def self.log(error)
6
+ File.open(Pra::Config.error_log_path, 'a') do |f|
7
+ f.puts(error.message)
8
+ error.backtrace.each { |line| f.puts(line) }
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,37 @@
1
+ module Pra
2
+ module PullRequestService
3
+ class FetchStatus
4
+ attr_reader :status, :pull_requests, :error
5
+
6
+ def self.success(pull_requests)
7
+ new(:success, pull_requests)
8
+ end
9
+
10
+ def self.error(error)
11
+ new(:error, :no_pull_requests, error)
12
+ end
13
+
14
+ def initialize(status, pull_requests, error = nil)
15
+ @status = status
16
+ @pull_requests = pull_requests
17
+ @error = error
18
+ end
19
+
20
+ def on_success &block
21
+ yield(@pull_requests) if success?
22
+ end
23
+
24
+ def on_error &block
25
+ yield(@error) if error?
26
+ end
27
+
28
+ def success?
29
+ status == :success
30
+ end
31
+
32
+ def error?
33
+ status == :error
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,14 +1,20 @@
1
1
  require 'pra/config'
2
2
  require 'pra/pull_source_factory'
3
+ require 'pra/pull_request_service/fetch_status'
3
4
 
4
5
  module Pra
5
6
  module PullRequestService
6
7
  def self.fetch_pull_requests
7
- pull_requests = []
8
8
  pull_sources.each do |pull_source|
9
- pull_requests.concat(pull_source.pull_requests)
9
+ yield fetch_with_status(pull_source)
10
10
  end
11
- return pull_requests
11
+ end
12
+
13
+ def self.fetch_with_status(pull_source)
14
+ pull_requests = pull_source.pull_requests
15
+ FetchStatus.success(pull_requests)
16
+ rescue Exception => error
17
+ FetchStatus.error(error)
12
18
  end
13
19
 
14
20
  def self.pull_sources
data/lib/pra/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pra
2
- VERSION = "0.1.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -18,6 +18,14 @@ module Pra
18
18
  raise PureVirtualMethodNotImplemented, "the 'fetching_pull_requests' method needs to be implemented."
19
19
  end
20
20
 
21
+ # This method is a pure virtual method and is called by the system
22
+ # when an error occurs while fetching pull requests. It is intended to
23
+ # be a notification to the window system so that it can notify the user
24
+ # that fetching pull requests failed.
25
+ def fetch_failed
26
+ raise PureVirtualMethodNotImplemented, "the 'fetch_failed' method needs to be implemented."
27
+ end
28
+
21
29
  # This method is a pure virtual method and is intendend for the inheriting
22
30
  # class to implement it to handle refreshing the pull requests within in
23
31
  # the window system. This method is called evertime the pull request
@@ -34,30 +34,49 @@ describe Pra::App do
34
34
  end
35
35
 
36
36
  describe "#fetch_and_refresh_pull_requests" do
37
- it "notifies the window system it is starting to fetch pull requests" do
38
- Kernel.stub(:sleep)
39
- Pra::PullRequestService.stub(:fetch_pull_requests)
40
- window_system_double = double('window system', refresh_pull_requests: nil)
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)
41
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
42
59
  expect(window_system_double).to receive(:fetching_pull_requests)
43
60
  subject.fetch_and_refresh_pull_requests
44
61
  end
45
62
 
46
63
  it "fetches the pull requests from all of the sources" do
47
- Kernel.stub(:sleep)
48
- window_system_double = double('window system', refresh_pull_requests: nil, fetching_pull_requests: nil)
49
- subject.instance_variable_set(:@window_system, window_system_double)
50
64
  expect(Pra::PullRequestService).to receive(:fetch_pull_requests)
51
65
  subject.fetch_and_refresh_pull_requests
52
66
  end
53
67
 
54
- it "tells the window system to refresh pull requests" do
55
- Kernel.stub(:sleep)
56
- pull_requests = double('fetched pull requests')
57
- Pra::PullRequestService.stub(:fetch_pull_requests).and_return(pull_requests)
58
- window_system_double = double('window system', fetching_pull_requests: nil)
59
- subject.instance_variable_set(:@window_system, window_system_double)
60
- expect(window_system_double).to receive(:refresh_pull_requests).with(pull_requests)
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)
61
80
  subject.fetch_and_refresh_pull_requests
62
81
  end
63
82
 
@@ -93,6 +93,15 @@ describe Pra::Config do
93
93
  end
94
94
  end
95
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
+
96
105
  describe ".users_home_directory" do
97
106
  subject { Pra::Config }
98
107
 
@@ -0,0 +1,30 @@
1
+ require 'pra/error_log'
2
+
3
+ describe Pra::ErrorLog do
4
+ describe '.log' do
5
+ let(:log_path) { double('log path') }
6
+ let(:file) { double('file object', puts: nil) }
7
+ let(:message) { double('error message') }
8
+ let(:backtrace) { ['backtrace line 1', 'backtrace line 2'] }
9
+ let(:error) { double('error', message: message, backtrace: backtrace) }
10
+
11
+ it 'opens the log file for appending' do
12
+ allow(Pra::Config).to receive(:error_log_path).and_return(log_path)
13
+ expect(File).to receive(:open).with(log_path, 'a')
14
+ Pra::ErrorLog.log(double)
15
+ end
16
+
17
+ it 'prints the error message to the file' do
18
+ allow(File).to receive(:open).and_yield(file)
19
+ expect(file).to receive(:puts).with(message)
20
+ Pra::ErrorLog.log(error)
21
+ end
22
+
23
+ it 'prints the backtrace to the file' do
24
+ allow(File).to receive(:open).and_yield(file)
25
+ expect(file).to receive(:puts).with('backtrace line 1')
26
+ expect(file).to receive(:puts).with('backtrace line 2')
27
+ Pra::ErrorLog.log(error)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,127 @@
1
+ require 'pra/pull_request_service/fetch_status'
2
+
3
+ describe Pra::PullRequestService::FetchStatus do
4
+ describe '.new' do
5
+ it 'assigns the status' do
6
+ status = double
7
+ fetch = Pra::PullRequestService::FetchStatus.new(status, double)
8
+ expect(fetch.status).to eq(status)
9
+ end
10
+
11
+ it 'assigns the pull requests' do
12
+ pulls = [double]
13
+ fetch = Pra::PullRequestService::FetchStatus.new(double, pulls)
14
+ expect(fetch.pull_requests).to eq(pulls)
15
+ end
16
+
17
+ it 'assigns the error' do
18
+ error = double
19
+ fetch = Pra::PullRequestService::FetchStatus.new(double, double, error)
20
+ expect(fetch.error).to eq(error)
21
+ end
22
+ end
23
+
24
+ describe '.success' do
25
+ let(:pulls) { double }
26
+ subject { Pra::PullRequestService::FetchStatus.success(pulls) }
27
+
28
+ it 'sets the status to success' do
29
+ expect(subject.status).to eq(:success)
30
+ end
31
+
32
+ it 'assigns the pull requests' do
33
+ expect(subject.pull_requests).to eq(pulls)
34
+ end
35
+ end
36
+
37
+ describe '.error' do
38
+ let(:error) { double }
39
+ subject { Pra::PullRequestService::FetchStatus.error(error) }
40
+
41
+ it 'sets the status to error' do
42
+ expect(subject.status).to eq(:error)
43
+ end
44
+
45
+ it 'sets the pull requests to a dummy value' do
46
+ expect(subject.pull_requests).to eq(:no_pull_requests)
47
+ end
48
+ end
49
+
50
+ describe '#success?' do
51
+ context 'when status is :success' do
52
+ subject { Pra::PullRequestService::FetchStatus.new(:success, double) }
53
+
54
+ it 'returns true' do
55
+ expect(subject.success?).to be_true
56
+ end
57
+ end
58
+
59
+ context 'when status is not :success' do
60
+ subject { Pra::PullRequestService::FetchStatus.new(double, double) }
61
+
62
+ it 'returns false' do
63
+ expect(subject.success?).to be_false
64
+ end
65
+ end
66
+ end
67
+
68
+ describe '#error?' do
69
+ context 'when status is :error' do
70
+ subject { Pra::PullRequestService::FetchStatus.new(:error, double) }
71
+
72
+ it 'returns true' do
73
+ expect(subject.error?).to be_true
74
+ end
75
+ end
76
+
77
+ context 'when status is not :error' do
78
+ subject { Pra::PullRequestService::FetchStatus.new(double, double) }
79
+
80
+ it 'returns false' do
81
+ expect(subject.error?).to be_false
82
+ end
83
+ end
84
+ end
85
+
86
+ describe '#on_success' do
87
+ let(:pulls) { double }
88
+ let(:error) { double }
89
+
90
+ context 'when status is success' do
91
+ subject { Pra::PullRequestService::FetchStatus.success(pulls) }
92
+
93
+ it 'yields the pull requests to the block' do
94
+ expect { |success_block| subject.on_success(&success_block) }.to yield_with_args(pulls)
95
+ end
96
+ end
97
+
98
+ context 'when status is not success' do
99
+ subject { Pra::PullRequestService::FetchStatus.error(double) }
100
+
101
+ it 'does not yield' do
102
+ expect {|success_block| subject.on_success(&success_block) }.not_to yield_control
103
+ end
104
+ end
105
+ end
106
+
107
+ describe '#on_error' do
108
+ let(:pulls) { double }
109
+ let(:error) { double }
110
+
111
+ context 'when status is error' do
112
+ subject { Pra::PullRequestService::FetchStatus.error(error) }
113
+
114
+ it 'yields the error to the block' do
115
+ expect { |error_block| subject.on_error(&error_block) }.to yield_with_args(error)
116
+ end
117
+ end
118
+
119
+ context 'when status is not error' do
120
+ subject { Pra::PullRequestService::FetchStatus.success(double) }
121
+
122
+ it 'does not yield' do
123
+ expect {|error_block| subject.on_error(&error_block) }.not_to yield_control
124
+ end
125
+ end
126
+ end
127
+ end
@@ -2,27 +2,67 @@ require_relative '../../../lib/pra/pull_request_service'
2
2
 
3
3
  describe Pra::PullRequestService do
4
4
  describe ".fetch_pull_requests" do
5
+ let(:pull_request_one) { double('pull request one') }
6
+ let(:pull_request_two) { double('pull request two') }
7
+ let(:pull_source_one) { double('good pull source one', :pull_requests => [pull_request_one]) }
8
+ let(:pull_source_two) { double('good pull source two', :pull_requests => [pull_request_two]) }
9
+
5
10
  it "gets all the pull-request sources" do
6
11
  subject.should_receive(:pull_sources).and_return([])
7
12
  subject.fetch_pull_requests
8
13
  end
9
14
 
10
15
  it "gets the pull requests from each pull-request source" do
11
- pull_source_one = double('pull source one')
12
- pull_source_two = double('pull source two')
13
- subject.stub(:pull_sources).and_return([pull_source_one, pull_source_two])
14
- pull_source_one.should_receive(:pull_requests).and_return([])
15
- pull_source_two.should_receive(:pull_requests).and_return([])
16
- subject.fetch_pull_requests
16
+ allow(subject).to receive(:pull_sources).and_return([pull_source_one, pull_source_two])
17
+ expect(subject).to receive(:fetch_with_status).with(pull_source_one)
18
+ expect(subject).to receive(:fetch_with_status).with(pull_source_two)
19
+ subject.fetch_pull_requests {}
20
+ end
21
+
22
+ it "yields each pull source with its fetch status object" do
23
+ status1 = double
24
+ status2 = double
25
+ allow(subject).to receive(:pull_sources).and_return([pull_source_one, pull_source_two])
26
+ allow(subject).to receive(:fetch_with_status).with(pull_source_one).and_return(status1)
27
+ allow(subject).to receive(:fetch_with_status).with(pull_source_two).and_return(status2)
28
+ expect { |b| subject.fetch_pull_requests(&b) }.to yield_successive_args(status1, status2)
29
+ end
30
+ end
31
+
32
+ describe '.fetch_with_status' do
33
+ let(:pulls) { double('pull requests') }
34
+ let(:error) { Exception.new('error fetching pull requests') }
35
+ let(:good_source) { double('good pull source', :pull_requests => pulls) }
36
+ let(:bad_source) { double('bad pull source') }
37
+
38
+ before do
39
+ allow(bad_source).to receive(:pull_requests).and_raise(error)
17
40
  end
18
41
 
19
- it "returns an array of all the pull-requests from each of the sources" do
20
- pull_request_one = double('pull request one')
21
- pull_request_two = double('pull request two')
22
- pull_source_one = double('pull source one', :pull_requests => [pull_request_one])
23
- pull_source_two = double('pull source two', :pull_requests => [pull_request_two])
24
- subject.stub(:pull_sources).and_return([pull_source_one, pull_source_two])
25
- subject.fetch_pull_requests.should eq([pull_request_one, pull_request_two])
42
+ context 'when it fetches successfully' do
43
+ it 'builds a success status object for the requests from each pull source' do
44
+ expect(Pra::PullRequestService::FetchStatus).to receive(:success).with(pulls)
45
+ subject.fetch_with_status(good_source)
46
+ end
47
+
48
+ it 'returns the status object' do
49
+ status = double('success status object')
50
+ allow(Pra::PullRequestService::FetchStatus).to receive(:success).with(pulls).and_return(status)
51
+ expect(subject.fetch_with_status(good_source)).to eq(status)
52
+ end
53
+ end
54
+
55
+ context 'when fetching raises an exception' do
56
+ it 'builds an error status object with the error' do
57
+ expect(Pra::PullRequestService::FetchStatus).to receive(:error).with(error)
58
+ subject.fetch_with_status(bad_source)
59
+ end
60
+
61
+ it 'returns the status object' do
62
+ status = double('error status object')
63
+ allow(Pra::PullRequestService::FetchStatus).to receive(:error).and_return(status)
64
+ expect(subject.fetch_with_status(bad_source)).to eq(status)
65
+ end
26
66
  end
27
67
  end
28
68
 
@@ -13,6 +13,12 @@ describe Pra::WindowSystem do
13
13
  end
14
14
  end
15
15
 
16
+ describe "#fetch_failed" do
17
+ it "raises a message stating that the pure virtual method has not been implemented" do
18
+ expect { subject.fetch_failed }.to raise_error(Pra::WindowSystem::PureVirtualMethodNotImplemented)
19
+ end
20
+ end
21
+
16
22
  describe "#refresh_pull_requests" do
17
23
  it "raises a message stating that the pure virtual method has not been implemented" do
18
24
  expect { subject.refresh_pull_requests(double('pull requests')) }.to raise_error(Pra::WindowSystem::PureVirtualMethodNotImplemented)
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: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew De Ponte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-15 00:00:00.000000000 Z
11
+ date: 2013-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,9 +102,11 @@ files:
102
102
  - lib/pra/app.rb
103
103
  - lib/pra/config.rb
104
104
  - lib/pra/curses_window_system.rb
105
+ - lib/pra/error_log.rb
105
106
  - lib/pra/github_pull_source.rb
106
107
  - lib/pra/pull_request.rb
107
108
  - lib/pra/pull_request_service.rb
109
+ - lib/pra/pull_request_service/fetch_status.rb
108
110
  - lib/pra/pull_source.rb
109
111
  - lib/pra/pull_source_factory.rb
110
112
  - lib/pra/stash_pull_source.rb
@@ -115,7 +117,9 @@ files:
115
117
  - spec/lib/pra/app_spec.rb
116
118
  - spec/lib/pra/config_spec.rb
117
119
  - spec/lib/pra/curses_window_system_spec.rb
120
+ - spec/lib/pra/error_log_spec.rb
118
121
  - spec/lib/pra/github_pull_source_spec.rb
122
+ - spec/lib/pra/pull_request_service/fetch_status_spec.rb
119
123
  - spec/lib/pra/pull_request_service_spec.rb
120
124
  - spec/lib/pra/pull_request_spec.rb
121
125
  - spec/lib/pra/pull_source_factory_spec.rb
@@ -152,7 +156,9 @@ test_files:
152
156
  - spec/lib/pra/app_spec.rb
153
157
  - spec/lib/pra/config_spec.rb
154
158
  - spec/lib/pra/curses_window_system_spec.rb
159
+ - spec/lib/pra/error_log_spec.rb
155
160
  - spec/lib/pra/github_pull_source_spec.rb
161
+ - spec/lib/pra/pull_request_service/fetch_status_spec.rb
156
162
  - spec/lib/pra/pull_request_service_spec.rb
157
163
  - spec/lib/pra/pull_request_spec.rb
158
164
  - spec/lib/pra/pull_source_factory_spec.rb