Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit 1d9d191

Browse files
committed
closes #7
1 parent ea79bc5 commit 1d9d191

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lib/hyper-operation/railway/validations.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def add_error(param, symbol, message, *args, &block)
2424
add_validation do
2525
begin
2626
add_error(param, symbol, message) if instance_eval(&block)
27+
true
2728
rescue Exit => e
2829
raise e unless e.state == :failed
2930
add_error(param, symbol, message)

spec/hyper-operation/validation_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@
8383
expect(errors.symbolic).to eq("foo" => :manchu)
8484
end
8585

86+
it "can skip explicit errors using the add_error macro" do
87+
MyOperation.class_eval do
88+
add_error(:foo, :manchu, "to you!") { false }
89+
end
90+
result = MyOperation.run
91+
expect(result).to be_resolved
92+
end
93+
8694
it "can add explicit errors using the add_error macro after an abort" do
8795
MyOperation.class_eval do
8896
add_error(:foo, :manchu, "to you!") { abort! }

spec/test_app/test_db_name

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)