Skip to content

Commit

Permalink
Implement chaining.
Browse files Browse the repository at this point in the history
  • Loading branch information
splattael committed Jan 27, 2010
1 parent 79c0134 commit 1fcbbab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ def validate(value = nil)

def append(&block)
@validators << block
self
end
end
5 changes: 5 additions & 0 deletions test/test_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ def v(value=nil, &block)
asserts("validates 1") { !v(1) }
end

context "chaining" do
asserts("valid") { v(1) { is_a?(Fixnum).equals(1) }}
asserts("invalid") { !v(1) { is_a?(Fixnum).equals(2) }}
end

context "equals" do
asserts("valid 1") { v(1) { equals 1 } }
asserts("invalid 2") { !v(2) { equals 1 } }
Expand Down

0 comments on commit 1fcbbab

Please sign in to comment.