Skip to content

Commit 6722d65

Browse files
committed
Set response messages to attributes of client error
1 parent 132ce84 commit 6722d65

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

lib/github_api/error/client_error.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ def initialize(message)
1111
end
1212

1313
def generate_message(attributes)
14-
"\nProblem:\n #{attributes[:problem]}"+
15-
"\nSummary:\n #{attributes[:summary]}"+
16-
"\nResolution:\n #{attributes[:resolution]}"
14+
@problem = attributes[:problem]
15+
@summary = attributes[:summary]
16+
@resolution = attributes[:resolution]
17+
"\nProblem:\n #{@problem}"+
18+
"\nSummary:\n #{@summary}"+
19+
"\nResolution:\n #{@resolution}"
1720
end
1821
end
1922
end # Error

spec/github/error/client_error_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,27 @@
2424
it 'generates resolution line' do
2525
error.generate_message(attributes).should include "Resolution:\n Glue it!"
2626
end
27+
28+
before do
29+
error.generate_message(attributes)
30+
end
31+
32+
describe '#problem' do
33+
it 'returns problem' do
34+
error.problem.should eq attributes[:problem]
35+
end
36+
end
37+
38+
describe '#summary' do
39+
it 'returns summary' do
40+
error.summary.should eq attributes[:summary]
41+
end
42+
end
43+
44+
describe '#resolution' do
45+
it 'returns resolution' do
46+
error.resolution.should eq attributes[:resolution]
47+
end
48+
end
2749
end
2850
end # Github::Error::ClientError

0 commit comments

Comments
 (0)