-
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.
- Loading branch information
1 parent
1c67081
commit 48385b7
Showing
9 changed files
with
80 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.1.0 | ||
2.1.2 |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Errapi | ||
|
||
class Configuration | ||
attr_reader :plugins | ||
|
||
def initialize | ||
@plugins = [] | ||
end | ||
|
||
def plugin plugin | ||
@plugins << plugin | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Errapi | ||
|
||
module Plugins | ||
end | ||
end | ||
|
||
Dir[File.join File.dirname(__FILE__), File.basename(__FILE__, '.*'), '*.rb'].each{ |lib| require lib } |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Errapi::Plugins | ||
|
||
module Message | ||
|
||
module ValidationErrorMixin | ||
attr_accessor :message | ||
end | ||
|
||
def self.build_error error, options | ||
error.message = options[:message] | ||
end | ||
|
||
def self.error_matches? error, criteria | ||
!criteria.key?(:message) || (criteria[:message].kind_of?(Regexp) ? !!error.message.match(criteria[:message]) : error.message == criteria[:message]) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,5 @@ | ||
module Errapi | ||
|
||
class ValidationError | ||
attr_accessor :message, :code, :type, :location | ||
|
||
def initialize message, options = {} | ||
@message = message | ||
@code = options[:code] | ||
@type = options[:type] | ||
@location = options[:location] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'helper' | ||
|
||
RSpec.describe 'errapi' do | ||
|
||
let(:config){ Errapi::Configuration.new } | ||
let(:context){ Errapi::ValidationContext.new config } | ||
|
||
before :each do | ||
config.plugin Errapi::Plugins::Message | ||
end | ||
|
||
it "should collect and find errors" do | ||
|
||
context.add message: 'foo' | ||
context.add message: 'bar' | ||
context.add message: 'baz' | ||
|
||
%w(foo bar baz).each{ |message| expect(context.error?(message: message)).to be(true) } | ||
expect(context.error?(message: /ba/)).to be(true) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.