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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c127ad0f44d56ae95f5a6be9b7cab84235dad3b
4
- data.tar.gz: ba1bb17eb3cdb23907a75393b1f058bb426e6a3c
3
+ metadata.gz: 8b595017d995e899c740e8e73050f8d76bf3fb7b
4
+ data.tar.gz: 7b1e2418576d038218a1a097df0b871e2befe08d
5
5
  SHA512:
6
- metadata.gz: 8993578106bcc32c2d27afe488d601a76924444dc95ba14e017d073d589bad9882be542d813dc13d42aa42f6662d9b88a5ff30804d6de8f6cff72cce12de403d
7
- data.tar.gz: d09a311ba5283bebf24fab23f09a7fc806cdd5cb0f9977ca0835a01955be193614a5c4d3207dfa8abdacd7cca78a52419065d9f9408d7b97e345e90ae748390a
6
+ metadata.gz: d4b3efcf9894fdca235c6ee6cac5ed032fd0578ec119c54640e40a2dadbfbd6e72bb158b3228578d41276183df4010a546ab33c2dcd1c8a2f76344d0a70fa342
7
+ data.tar.gz: f3e5bfc9bc9ccdc5f594e16268f3696d9c0b6a2b02126e343845c8966958e569a47e50abf64d8f11a4c31ff7d3cfdac105482c4b47e4ceeccc30890580163b83
@@ -1,3 +1,3 @@
1
1
  module AssertMoar
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -35,7 +35,21 @@ module MiniTest::Assertions
35
35
  object.send("#{property}_file_name=", tmp)
36
36
  end
37
37
 
38
- def assert_valid object
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?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert-moar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Bohn