Skip to content

Commit

Permalink
Namespaced the errors under FieldMapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
hopsoft committed Apr 3, 2014
1 parent 362a6bd commit 47d581c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
24 changes: 13 additions & 11 deletions lib/field_mapper/errors.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class StandardNotSet < StandardError; end
class StandardFieldNotFound < StandardError; end
class StandardValueNotFound < StandardError; end
class StandardMismatch < StandardError; end
class TypeNotSpecified < StandardError; end
class TypeNotSupported < StandardError; end
class FieldNotDefined < StandardError; end
class InvalidPlatType < StandardError; end
class InvalidListType < StandardError; end
class InvalidListValue < StandardError; end
class InvalidMarshal < StandardError; end
module FieldMapper
class StandardNotSet < StandardError; end
class StandardFieldNotFound < StandardError; end
class StandardValueNotFound < StandardError; end
class StandardMismatch < StandardError; end
class TypeNotSpecified < StandardError; end
class TypeNotSupported < StandardError; end
class FieldNotDefined < StandardError; end
class InvalidPlatType < StandardError; end
class InvalidListType < StandardError; end
class InvalidListValue < StandardError; end
class InvalidMarshal < StandardError; end
end
2 changes: 1 addition & 1 deletion lib/field_mapper/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module FieldMapper
VERSION = "0.1.1"
VERSION = "0.2.0"
end
2 changes: 1 addition & 1 deletion test/custom/field_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class FieldTest < MicroTest::Test
test "constructor requires type" do
begin
FieldMapper::Custom::Field.new(:foo)
rescue TypeNotSpecified => e
rescue FieldMapper::TypeNotSpecified => e
error = e
end
assert error.present?
Expand Down
4 changes: 2 additions & 2 deletions test/custom/value_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ValueTest < MicroTest::Test
begin
custom_field = FieldMapper::Custom::Field.new(:bar, type: Integer)
FieldMapper::Custom::Value.new(1, field: custom_field, standard_value: 1)
rescue StandardFieldNotFound => e
rescue FieldMapper::StandardFieldNotFound => e
error = e
end
assert error.present?
Expand All @@ -21,7 +21,7 @@ class ValueTest < MicroTest::Test
test "constructor ensures standard_value exists" do
begin
FieldMapper::Custom::Value.new("a", field: @custom_field, standard_value: "a")
rescue StandardValueNotFound => e
rescue FieldMapper::StandardValueNotFound => e
error = e
end
assert error.present?
Expand Down
2 changes: 1 addition & 1 deletion test/standard/field_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class FieldTest < MicroTest::Test
test "constructor requires type" do
begin
FieldMapper::Standard::Field.new(:foo)
rescue TypeNotSpecified => e
rescue FieldMapper::TypeNotSpecified => e
error = e
end
assert error.present?
Expand Down
4 changes: 2 additions & 2 deletions test/types/list_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ class ListTest < MicroTest::Test
test "initialize fails with instance type" do
begin
FieldMapper::Types::List.new("")
rescue InvalidListType => error
rescue FieldMapper::InvalidListType => error
end
assert !error.nil?
end

test "initialize fails with invalid type" do
begin
FieldMapper::Types::List.new(Object)
rescue InvalidListType => error
rescue FieldMapper::InvalidListType => error
end
assert !error.nil?
end
Expand Down
8 changes: 4 additions & 4 deletions test/types/plat_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ class PlatTest < MicroTest::Test
test "initialize fails with instance type" do
begin
FieldMapper::Types::Plat.new("")
rescue InvalidPlatType => error
rescue FieldMapper::InvalidPlatType => error
end
assert !error.nil?
end

test "initialize fails with non plat type" do
begin
FieldMapper::Types::Plat.new(String)
rescue InvalidPlatType => error
rescue FieldMapper::InvalidPlatType => error
end
assert !error.nil?
end

test "initialize succeeds with plat type" do
begin
FieldMapper::Types::Plat.new(Standard::PlatExample)
rescue InvalidPlatType => error
rescue FieldMapper::InvalidPlatType => error
end
assert error.nil?
end

test "[] construction" do
begin
FieldMapper::Types::Plat[Standard::PlatExample]
rescue InvalidPlatType => error
rescue FieldMapper::InvalidPlatType => error
end
assert error.nil?
end
Expand Down

0 comments on commit 47d581c

Please sign in to comment.