Permalink
Browse files

Fix naming in error spec.

  • Loading branch information...
1 parent 9649692 commit 9740047ddd87c372906749c7cdeb2d24f64ed2cf @kowshik kowshik committed Feb 19, 2013
Showing with 28 additions and 27 deletions.
  1. +6 −6 lib/schemata/common/error.rb
  2. +1 −0 lib/schemata/common/msgbase.rb
  3. +21 −21 spec/common/error_spec.rb
@@ -1,5 +1,5 @@
module Schemata
- class Error < StandardError
+ class SchemataError < StandardError
attr_reader :source_exception, :source_backtrace
@@ -18,11 +18,11 @@ def backtrace
end
end
- class DecodeError < Error; end
- class EncodeError < Error; end
- class SchemaDefinitionError < Error; end
+ class DecodeError < SchemataError; end
+ class EncodeError < SchemataError; end
+ class SchemaDefinitionError < SchemataError; end
- class UpdateAttributeError < Error
+ class UpdateAttributeError < SchemataError
attr_reader :key
def initialize(key, exception = $!)
@@ -31,7 +31,7 @@ def initialize(key, exception = $!)
end
end
- class IncompatibleVersionError < Error
+ class IncompatibleVersionError < SchemataError
attr_reader :msg_version, :component_version
def initialize(msg_version, component_version)
@@ -43,6 +43,7 @@ def self.define(schema)
field_value
end
end
+
vc_klass
end
View
@@ -3,73 +3,73 @@
describe Schemata do
let(:backtrace) { %w(foo bar) }
- let(:message) { "message" }
- let(:exception) do
- error = StandardError.new(message)
- error.set_backtrace backtrace
+ let(:error_message) { "error message" }
+ let(:custom_error) do
+ error = StandardError.new(error_message)
+ error.set_backtrace(backtrace)
error
end
- describe Schemata::Error do
- context 'when an exception is explicitly passed in' do
+ describe Schemata::SchemataError do
+ context 'when an error is explicitly passed in' do
context 'and a message is not passed in' do
- subject { Schemata::Error.new(exception) }
+ subject { Schemata::SchemataError.new(custom_error) }
- its(:message) { should eq message }
+ its(:message) { should eq error_message }
its(:backtrace) { should be_nil }
end
context 'and a message is passed in' do
- subject { Schemata::Error.new(exception, "other message") }
+ subject { Schemata::SchemataError.new(custom_error, "other message") }
its(:message) { should eq "other message" }
its(:backtrace) { should be_nil }
end
end
- context 'when no exception is passed in' do
+ context 'when no error is passed in' do
context 'and it is a reraise' do
subject do
error = nil
begin
begin
- raise exception
+ raise custom_error
rescue
- raise Schemata::Error.new
+ raise Schemata::SchemataError.new
end
rescue => e
error = e
end
error
end
- its(:message) { should eq message }
+ its(:message) { should eq error_message }
its(:source_backtrace) { should eq backtrace }
- it 'includes the re raised exception' do
+ it 'includes the re raised error' do
expect(subject.backtrace.first).to match /error_spec\.rb/
end
- it 'includes the chained exception' do
+ it 'includes the chained error' do
expect(subject.backtrace.last).to eq "bar"
end
end
- context 'and it is a standlone exception' do
- subject { Schemata::Error.new(nil, message) }
+ context 'and it is a standlone error' do
+ subject { Schemata::SchemataError.new(nil, error_message) }
- its(:message) { should eq message }
+ its(:message) { should eq error_message }
its(:backtrace) { should be_nil }
end
end
end
describe Schemata::UpdateAttributeError do
let(:key) { "key" }
- subject { Schemata::UpdateAttributeError.new(key, exception) }
+ subject { Schemata::UpdateAttributeError.new(key, custom_error) }
- its(:message) { should eq "#{key}: #{message}" }
- its(:to_s) { should eq "#{key}: #{message}" }
+ its(:message) { should eq "#{key}: #{error_message}" }
+ its(:to_s) { should eq "#{key}: #{error_message}" }
its(:key) { should eq key }
its(:backtrace) { should be_nil }
end

0 comments on commit 9740047

Please sign in to comment.