-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to add i18n interpolation support. Changed how metadata is su…
…pplied and returned.
- Loading branch information
Anthony Smith
committed
Nov 19, 2013
1 parent
cc734ae
commit 5dc7790
Showing
10 changed files
with
153 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Errawr | ||
VERSION = '1.0.0' | ||
VERSION = '1.1.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,64 @@ | ||
require 'spec_helper' | ||
|
||
describe Errawr do | ||
it 'should raise an Errawr::Error exception' do | ||
Errawr.register!(:dummy_error) | ||
expect { Errawr.error!(:dummy_error) }.to raise_error(Errawr::Error) | ||
describe 'error!' do | ||
it 'should raise an Errawr::Error exception' do | ||
Errawr.register!(:dummy_error) | ||
expect { Errawr.error!(:dummy_error) }.to raise_error(Errawr::Error) | ||
end | ||
|
||
it 'should return custom metadata values using #register!' do | ||
Errawr.register!(:some_error, metadata: { name: 'custom_register!_name' }) | ||
begin | ||
Errawr.error!(:some_error) | ||
rescue => e | ||
e.metadata[:name].should == 'custom_register!_name' | ||
end | ||
end | ||
|
||
it 'should return custom metadata values using #error!' do | ||
Errawr.register!(:some_error, metadata: { name: 'custom_register!_name' }) | ||
begin | ||
Errawr.error!(:some_error, metadata: { name: 'custom_error!_name' }) | ||
rescue => e | ||
e.metadata[:name].should == 'custom_error!_name' | ||
end | ||
end | ||
|
||
it 'should return custom metadata values from locale file' do | ||
Errawr.register!(:error_hash) | ||
begin | ||
Errawr.error!(:error_hash) | ||
rescue => e | ||
e.metadata.include?(:name).should be_true | ||
end | ||
end | ||
|
||
it '#register! should override custom metadata values from locale file' do | ||
Errawr.register!(:error_hash, metadata: { name: 'register!_name' }) | ||
begin | ||
Errawr.error!(:error_hash) | ||
rescue => e | ||
e.metadata[:name].should == 'register!_name' | ||
end | ||
end | ||
|
||
it 'should override custom metadata values from #register! and locale file' do | ||
Errawr.register!(:error_hash, metadata: { name: 'register!_name' }) | ||
begin | ||
Errawr.error!(:error_hash, metadata: { name: 'error!_name' }) | ||
rescue => e | ||
e.metadata[:name].should == 'error!_name' | ||
end | ||
end | ||
|
||
it 'should interpolate locales' do | ||
Errawr.register!(:interpolated_error, error_message: 'interpolated message') | ||
begin | ||
Errawr.error!(:interpolated_error) | ||
rescue => e | ||
e.message.should == 'Some error has occurred: interpolated message' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters