Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix MetricCollectorDetails error handling
Browse files Browse the repository at this point in the history
Now it uses error classes of Likeno.
diegoamc committed Mar 28, 2016
1 parent 877a5bf commit d754091
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
@is_error = false
begin
KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name!("Avalio")
rescue KalibroClient::Errors::RecordNotFound
rescue Likeno::Errors::RecordNotFound
@is_error = true
end
end
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ def find_metric_by_name(name)

def find_metric_by_name!(name)
metric = self.find_metric_by_name(name)
raise KalibroClient::Errors::RecordNotFound if metric.nil?
raise Likeno::Errors::RecordNotFound if metric.nil?
metric
end

@@ -48,14 +48,14 @@ def find_metric_by_code(metric_code)

def find_metric_by_code!(metric_code)
metric = self.find_metric_by_code(metric_code)
raise KalibroClient::Errors::RecordNotFound if metric.nil?
raise Likeno::Errors::RecordNotFound if metric.nil?
metric
end

def self.find_by_name(metric_collector_name)
begin
self.find_by_name!(metric_collector_name)
rescue KalibroClient::Errors::RecordNotFound
rescue Likeno::Errors::RecordNotFound
nil
end
end
10 changes: 5 additions & 5 deletions spec/entities/processor/metric_collector_details_spec.rb
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@
KalibroClient::Entities::Processor::MetricCollectorDetails.
expects(:find_by_name!).
with(subject.name).
raises(KalibroClient::Errors::RecordNotFound)
raises(Likeno::Errors::RecordNotFound)
end

it 'is expected to return nil' do
@@ -90,12 +90,12 @@
KalibroClient::Entities::Processor::MetricCollectorDetails.
expects(:request).
with(:find, {name: subject.name}).
raises(KalibroClient::Errors::RecordNotFound)
raises(Likeno::Errors::RecordNotFound)
end

it 'should raise a RecordNotFound error' do
expect { KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name!(subject.name)}.
to raise_error(KalibroClient::Errors::RecordNotFound)
to raise_error(Likeno::Errors::RecordNotFound)
end
end

@@ -146,7 +146,7 @@
let(:metric) { subject.supported_metrics["loc"] }

it 'should return nil with an inexistent name' do
expect { subject.find_metric_by_name!("fake name") }.to raise_error(KalibroClient::Errors::RecordNotFound)
expect { subject.find_metric_by_name!("fake name") }.to raise_error(Likeno::Errors::RecordNotFound)
end

it 'should return a metric with an existent name' do
@@ -172,7 +172,7 @@
let(:metric) { subject.supported_metrics["loc"] }

it 'should return nil with an inexistent code' do
expect{subject.find_metric_by_code!("fake code")}.to raise_error(KalibroClient::Errors::RecordNotFound)
expect{subject.find_metric_by_code!("fake code")}.to raise_error(Likeno::Errors::RecordNotFound)
end

it 'should return a metric with an existent code' do

0 comments on commit d754091

Please sign in to comment.