vladimerb 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,5 +38,3 @@ module Vladimerb
38
38
  end
39
39
  end
40
40
 
41
- include Vladimerb
42
-
@@ -1,6 +1,8 @@
1
1
  require_relative "test_helper"
2
2
 
3
3
  class ChainTest < Test::Unit::TestCase
4
+ include Vladimerb
5
+
4
6
  def test_shows_first_error
5
7
  assert_errors Candidate.new(nil, nil),
6
8
  chain(required(:name),
@@ -1,7 +1,8 @@
1
1
  require_relative "test_helper"
2
2
 
3
-
4
3
  class GreaterThanTest < Test::Unit::TestCase
4
+ include Vladimerb
5
+
5
6
  def tests_fails_when_number_not_greater
6
7
  assert_errors Candidate.new("Jill", 12),
7
8
  GreaterThan.new(:age, 18),
@@ -1,6 +1,8 @@
1
1
  require_relative "test_helper.rb"
2
2
 
3
3
  class JoinTest < Test::Unit::TestCase
4
+ include Vladimerb
5
+
4
6
  def test_shows_all_errors
5
7
  assert_errors Candidate.new(nil, nil),
6
8
  join(required(:name),
@@ -1,6 +1,8 @@
1
1
  require_relative "test_helper.rb"
2
2
 
3
3
  class LambdaTest < Test::Unit::TestCase
4
+ include Vladimerb
5
+
4
6
  def tests_against_lambda_and_fails
5
7
  assert_errors Candidate.new(nil, 24),
6
8
  (lambda_validation do |record|
@@ -1,6 +1,8 @@
1
1
  require_relative "test_helper.rb"
2
2
 
3
3
  class PatternTest < Test::Unit::TestCase
4
+ include Vladimerb
5
+
4
6
  def tests_a_value_matches_a_regex
5
7
  assert_errors Candidate.new("Fred", 50),
6
8
  pattern(:name, /ed/),
@@ -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
- Predicate.new(:name, :nil?, "Name must be nil."),
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
- Predicate.new(:name, :nil?, "Name must be nil."),
15
+ predicate(:name, :nil?, "Name must be nil."),
15
16
  []
16
17
  end
17
18
  end
@@ -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
- Required.new(:name),
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
- Required.new(:name),
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
- Required.new(:name),
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
- Required.new(:age),
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
- Required.new(:age),
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
- Required.new(:name, message: "You gotta have a name!"),
38
+ required(:name, message: "You gotta have a name!"),
38
39
  ["You gotta have a name!"]
39
40
  end
40
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vladimerb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: