vladimerb 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/src/vladimerb.rb +0 -2
- data/test/chain.rb +2 -0
- data/test/greater_than.rb +2 -1
- data/test/join.rb +2 -0
- data/test/lambda.rb +2 -0
- data/test/pattern.rb +2 -0
- data/test/predicate.rb +4 -3
- data/test/require.rb +8 -7
- metadata +1 -1
data/src/vladimerb.rb
CHANGED
data/test/chain.rb
CHANGED
data/test/greater_than.rb
CHANGED
data/test/join.rb
CHANGED
data/test/lambda.rb
CHANGED
data/test/pattern.rb
CHANGED
data/test/predicate.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
require File.dirname(File.expand_path(__FILE__)) + "/test_helper.rb"
|
2
|
-
require File.dirname(File.expand_path(__FILE__)) + "/../src/predicate.rb"
|
3
2
|
|
4
3
|
|
5
4
|
class PredicateTest < Test::Unit::TestCase
|
5
|
+
include Vladimerb
|
6
|
+
|
6
7
|
def tests_against_predicate_and_fails
|
7
8
|
assert_errors Candidate.new("Jill", 24),
|
8
|
-
|
9
|
+
predicate(:name, :nil?, "Name must be nil."),
|
9
10
|
["Name must be nil."]
|
10
11
|
end
|
11
12
|
|
12
13
|
def tests_against_predicate_and_succeeds
|
13
14
|
assert_errors Candidate.new(nil, 24),
|
14
|
-
|
15
|
+
predicate(:name, :nil?, "Name must be nil."),
|
15
16
|
[]
|
16
17
|
end
|
17
18
|
end
|
data/test/require.rb
CHANGED
@@ -1,40 +1,41 @@
|
|
1
1
|
require File.dirname(File.expand_path(__FILE__)) + "/test_helper.rb"
|
2
|
-
require File.dirname(File.expand_path(__FILE__)) + "/../src/required.rb"
|
3
2
|
|
4
3
|
class RequiredTest < Test::Unit::TestCase
|
4
|
+
include Vladimerb
|
5
|
+
|
5
6
|
def test_succeeds_for_candidate_with_name
|
6
7
|
assert_errors Candidate.new("Fred", 50),
|
7
|
-
|
8
|
+
required(:name),
|
8
9
|
[]
|
9
10
|
end
|
10
11
|
|
11
12
|
def test_fails_for_candidate_without_name
|
12
13
|
assert_errors Candidate.new(nil, 24),
|
13
|
-
|
14
|
+
required(:name),
|
14
15
|
["name is required."]
|
15
16
|
end
|
16
17
|
|
17
18
|
def test_fails_for_candidate_with_blank_name
|
18
19
|
assert_errors Candidate.new("", 24),
|
19
|
-
|
20
|
+
required(:name),
|
20
21
|
["name is required."]
|
21
22
|
end
|
22
23
|
|
23
24
|
def test_fails_for_candidate_without_age
|
24
25
|
assert_errors Candidate.new("Bob", nil),
|
25
|
-
|
26
|
+
required(:age),
|
26
27
|
["age is required."]
|
27
28
|
end
|
28
29
|
|
29
30
|
def test_fails_for_required_data_that_do_not_have_empty_method
|
30
31
|
assert_errors Candidate.new("Bob", 20),
|
31
|
-
|
32
|
+
required(:age),
|
32
33
|
[]
|
33
34
|
end
|
34
35
|
|
35
36
|
def test_fails_with_custom_error_message
|
36
37
|
assert_errors Candidate.new(nil, 24),
|
37
|
-
|
38
|
+
required(:name, message: "You gotta have a name!"),
|
38
39
|
["You gotta have a name!"]
|
39
40
|
end
|
40
41
|
end
|