assert-moar 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assert_moar/version.rb +1 -1
- data/lib/minitest/assertions.rb +15 -1
- data/test/lib/minitest/assertions_test.rb +21 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b595017d995e899c740e8e73050f8d76bf3fb7b
|
4
|
+
data.tar.gz: 7b1e2418576d038218a1a097df0b871e2befe08d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4b3efcf9894fdca235c6ee6cac5ed032fd0578ec119c54640e40a2dadbfbd6e72bb158b3228578d41276183df4010a546ab33c2dcd1c8a2f76344d0a70fa342
|
7
|
+
data.tar.gz: f3e5bfc9bc9ccdc5f594e16268f3696d9c0b6a2b02126e343845c8966958e569a47e50abf64d8f11a4c31ff7d3cfdac105482c4b47e4ceeccc30890580163b83
|
data/lib/assert_moar/version.rb
CHANGED
data/lib/minitest/assertions.rb
CHANGED
@@ -35,7 +35,21 @@ module MiniTest::Assertions
|
|
35
35
|
object.send("#{property}_file_name=", tmp)
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def assert_validates_uniqueness_of(object, property)
|
39
|
+
assert_valid object
|
40
|
+
object2 = object.clone
|
41
|
+
refute object2.valid?, "Expected object not to be valid"
|
42
|
+
refute_nil object2.errors[property.to_sym], "Expected errors to exist for #{property}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def refute_validates_uniqueness_of(object, property)
|
46
|
+
assert_valid object
|
47
|
+
object2 = object.clone
|
48
|
+
assert_valid object2
|
49
|
+
assert_nil object2.errors[property.to_sym]
|
50
|
+
end
|
51
|
+
|
52
|
+
def assert_valid(object)
|
39
53
|
assert object.valid?, "Expected object to be valid"
|
40
54
|
end
|
41
55
|
|
@@ -10,6 +10,12 @@ class Minitest::AssertionTest < Minitest::Test
|
|
10
10
|
@assertion_count = 1
|
11
11
|
end
|
12
12
|
|
13
|
+
def invalid_clone(object)
|
14
|
+
clone = object.class.new(:property)
|
15
|
+
clone.property = nil
|
16
|
+
clone
|
17
|
+
end
|
18
|
+
|
13
19
|
def test_assert_valid
|
14
20
|
double = spy
|
15
21
|
double.property = "foo"
|
@@ -45,6 +51,21 @@ class Minitest::AssertionTest < Minitest::Test
|
|
45
51
|
@tc.refute_validates_attachment_presence_of(spy, :property)
|
46
52
|
end
|
47
53
|
|
54
|
+
def test_assert_uniqueness_of
|
55
|
+
@assertion_count = 3
|
56
|
+
double = spy
|
57
|
+
double.property = "foo"
|
58
|
+
double.stub(:clone, invalid_clone(double)) do
|
59
|
+
@tc.assert_validates_uniqueness_of(double, :property)
|
60
|
+
end
|
61
|
+
assert_equal "foo", double.property
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_refute_uniqueness_of
|
65
|
+
@assertion_count = 3
|
66
|
+
@tc.refute_validates_uniqueness_of(spy(nil), :property)
|
67
|
+
end
|
68
|
+
|
48
69
|
def teardown
|
49
70
|
assert_equal(@assertion_count, @tc.assertions,
|
50
71
|
"expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}") if @tc.passed?
|